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

Feature selector #4074

Merged
merged 35 commits into from
Jan 24, 2017
Merged

Feature selector #4074

merged 35 commits into from
Jan 24, 2017

Conversation

jacogr
Copy link
Contributor

@jacogr jacogr commented Jan 6, 2017

Feature selector for development mode -

  • manages switching features on/off under Settings
  • allows components to query active features via store (and adapt display/execution path accordingly)
  • currently only used for the i18n selector in dev mode
  • born out of the need to test features in isolation (e.g. moving ParityBar -> Portal, without de-stabilising non-dev builds)
  • added tests for all components touched as part of the process

@jacogr jacogr added A0-pleasereview 🤓 Pull request needs code review. M7-ui labels Jan 6, 2017
@coveralls
Copy link

Coverage Status

Coverage increased (+0.002%) to 86.553% when pulling dbd5723 on jg-dev-features into 9c00eb4 on master.

@jacogr jacogr added the A1-onice 🌨 Pull request is reviewed well, but should not yet be merged. label Jan 9, 2017
@jacogr jacogr added A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. and removed A0-pleasereview 🤓 Pull request needs code review. A1-onice 🌨 Pull request is reviewed well, but should not yet be merged. labels Jan 10, 2017
# Conflicts:
#	js/src/modals/CreateAccount/NewAccount/newAccount.js
#	js/src/modals/CreateAccount/NewImport/newImport.js
#	js/src/modals/CreateAccount/RawKey/rawKey.js
#	js/src/modals/CreateAccount/RecoveryPhrase/recoveryPhrase.js
#	js/src/modals/CreateAccount/createAccount.js
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 7ecae24 on jg-dev-features into ** on master**.

@jacogr jacogr added A0-pleasereview 🤓 Pull request needs code review. and removed A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. labels Jan 10, 2017
import React, { Component, PropTypes } from 'react';

import defaults, { MODES } from './defaults';
import Store from './store';
Copy link
Contributor

Choose a reason for hiding this comment

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

Not really related to this PR, but I always wondered why we had [module].css, [module].js files, but always (almost) store.js file ? Seems a bit inconsistent no ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When used internally to the module is it just "THE store". When accesses extrenally, we do it via ui/Features/store so the intent is 100% clear. IMHO option having featureStore doesn't add much if any value.

Copy link
Contributor

Choose a reason for hiding this comment

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

So what about having styles.css in ui/Features that would contain the Component style ? It would be "THE style" of the Component. I think it solves the issue when you have multiple tabs open with all the same names (even if the path is added in some editors). One way or the other is fine, it just seems a bit strange

const onCheck = () => feature.mode === MODES.DEVELOPMENT && this.store.toggleActive(key);

return (
<ListItem
Copy link
Contributor

Choose a reason for hiding this comment

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

Might want to have separate methods for rendering each item.


export default class Features extends Component {
static propTypes = {
visible: PropTypes.bool.isRequired
Copy link
Contributor

Choose a reason for hiding this comment

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

When would this prop be passed ? I would thought it could be read from the local storage so we could have access to it even in Production, no ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. will take a look.

leftCheckbox={
<Checkbox
checked={ this.store.active[key] }
disabled={ feature.mode === MODES.TESTING }
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I understand the utility of these checkboxes. Aren't they supposed to toggle which features are shown ? Currently they are disabled in DEV mode. Anyhow I think it would be good to have these available in any environment. (would be hidden in PROD of course)

Copy link
Contributor Author

@jacogr jacogr Jan 23, 2017

Choose a reason for hiding this comment

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

Depends, think it is a bit misleading though -

  1. DEVELOPMENT - it is toggle-able, but off by default - can develop and test without affecting dev mode
  2. TESTING - it is enabled by default, but off for production (in this cse you are probably right, should still be selectable)
  3. PRODUCTION - cannot be switched off, has gone live

{ this.renderModes() }
<LanguageSelector />
<Features />
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks a bit strange, right in the middle between two features : language and logs. Would be better on top or on bottom

@ngotchac ngotchac added A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jan 23, 2017
@jacogr jacogr added A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. and removed A5-grumble 🔥 Pull request has minor issues that must be addressed before merging. labels Jan 23, 2017
@jacogr jacogr added A0-pleasereview 🤓 Pull request needs code review. and removed A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. labels Jan 23, 2017
Copy link
Contributor

@ngotchac ngotchac left a comment

Choose a reason for hiding this comment

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

The checkboxes won't toggle (I think it's because an @observer is missing), and it seems that the values written to localStorage gets overwritten on load of the Features component.

}

@action setActiveFeatures = (features = {}, isProduction) => {
this.active = Object.assign({}, features, this.getDefaultActive(isProduction));
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't the defaults be first, not to overwrite the passed features?

Copy link
Contributor Author

@jacogr jacogr Jan 24, 2017

Choose a reason for hiding this comment

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

There was method to the madness, what it was I don't recall - it has been a bit too long between writing this. Tested specifically for this behaviour -

ui/Features/Store @action setActiveFeatures overrides with defaults:

However, now that dev mode is toggle-able, it would make sense to do it the other way around.

import Store from './store';
import styles from './features.css';

export default class Features extends Component {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing an @observer here

@ngotchac ngotchac added A4-gotissues 💥 Pull request is reviewed and has significant issues which must be addressed. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jan 24, 2017
@jacogr jacogr added A0-pleasereview 🤓 Pull request needs code review. and removed A4-gotissues 💥 Pull request is reviewed and has significant issues which must be addressed. labels Jan 24, 2017
@ngotchac ngotchac added A8-looksgood 🦄 Pull request is reviewed well. and removed A0-pleasereview 🤓 Pull request needs code review. labels Jan 24, 2017
@jacogr jacogr merged commit 155bbc3 into master Jan 24, 2017
@jacogr jacogr deleted the jg-dev-features branch January 24, 2017 16:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A8-looksgood 🦄 Pull request is reviewed well.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants