Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Allow selection & saving of available views #2131

Merged
merged 4 commits into from
Sep 19, 2016
Merged

Allow selection & saving of available views #2131

merged 4 commits into from
Sep 19, 2016

Conversation

jacogr
Copy link
Contributor

@jacogr jacogr commented Sep 17, 2016

Functionality in action - https://youtu.be/xPSrHKB3VqU

Needed for non-default features. #2130

@jacogr jacogr added A0-pleasereview 🤓 Pull request needs code review. M-UI labels Sep 17, 2016
@parity-cla-bot
Copy link

It looks like this contributor signed our Contributor License Agreement. 👍

Many thanks,

Ethcore CLA Bot

@jacogr jacogr changed the title Allow setting & saving of available views Allow selection & saving of available views Sep 18, 2016
}

onActivate = (tab) => {
const { router } = this.context;
const activeRoute = tab.props['data-route'];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have to use data attributes here?
We could either:

  1. Attach lambda for each Tab::onActivate (less performant?)
  2. Wrap the Tab into another component (not sure if possible?)

I don't feel that data- attributes is the best way to do it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I like those options either. I remember that I spent time researching this and this seemed to be the "least hacky way" in my view :( Thinking about it again, I will try your option #1 though, it may be slightly less problematic. (Still not great)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed with #1. Not happy, but less of a bad option maybe.

}

Object.keys(lsdata).forEach((id) => {
state[`${id}Visible`] = lsdata[id].active;
Copy link
Collaborator

@tomusdrw tomusdrw Sep 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${id}Visible could be wrapped in a separate function to avoid repeating a random string in couple places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

lsdata[id].active = this.state[`${id}Visible`];
});

window.localStorage.setItem(LS_VIEWS, JSON.stringify(lsdata));
Copy link
Collaborator

@tomusdrw tomusdrw Sep 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

writing to localStorage may throw exceptions in certain configurations - might be better to create a Storage wrapper and handle such cases globaly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.g. exception if sandboxed. Yes, not a bad idea I think we will probably start (ab)using it a bit more apart from the current tooltips, signer & views config. Should do it properly. (Going to log that seperately to split these out, since I wouldn't just want to do it for the one place and the rest don't fit in this PR)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomusdrw tomusdrw added A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. and removed A0-pleasereview 🤓 Pull request needs code review. labels Sep 19, 2016
@jacogr jacogr added A0-pleasereview 🤓 Pull request needs code review. and removed A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. labels Sep 19, 2016
@jacogr jacogr merged commit 24710b6 into js Sep 19, 2016
@jacogr jacogr deleted the jg-view-settings branch September 19, 2016 19:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A0-pleasereview 🤓 Pull request needs code review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants