From 7f795240706c013dc4a9ece0e9c9e33897c7fc71 Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 14 Nov 2017 12:34:55 -0330 Subject: Add UI selection --- ui/app/select-app.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 ui/app/select-app.js (limited to 'ui/app/select-app.js') diff --git a/ui/app/select-app.js b/ui/app/select-app.js new file mode 100644 index 000000000..3cba44052 --- /dev/null +++ b/ui/app/select-app.js @@ -0,0 +1,21 @@ +const inherits = require('util').inherits +const Component = require('react').Component +const connect = require('react-redux').connect +const h = require('react-hyperscript') +const App = require('./app') +const OldApp = require('../../old-ui/app/app') + +function mapStateToProps (state) { + return { betaUI: state.metamask.featureFlags.betaUI } +} + +module.exports = connect(mapStateToProps)(SelectedApp) + +inherits(SelectedApp, Component) +function SelectedApp () { Component.call(this) } + +SelectedApp.prototype.render = function () { + const { betaUI } = this.props + const Selected = betaUI ? App : OldApp + return h(Selected) +} -- cgit v1.2.3 From bd5ce9461e5119c13ab8be29db5cdfc57228bac8 Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 6 Dec 2017 20:49:45 -0330 Subject: User is automatically added to new UI if they meet conditions at time of login. --- ui/app/select-app.js | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'ui/app/select-app.js') diff --git a/ui/app/select-app.js b/ui/app/select-app.js index 3cba44052..ffa31b767 100644 --- a/ui/app/select-app.js +++ b/ui/app/select-app.js @@ -4,18 +4,44 @@ const connect = require('react-redux').connect const h = require('react-hyperscript') const App = require('./app') const OldApp = require('../../old-ui/app/app') +const { autoAddToBetaUI } = require('./selectors') +const { setFeatureFlag } = require('./actions') function mapStateToProps (state) { - return { betaUI: state.metamask.featureFlags.betaUI } + return { + betaUI: state.metamask.featureFlags.betaUI, + autoAdd: autoAddToBetaUI(state), + isUnlocked: state.metamask.isUnlocked, + } } -module.exports = connect(mapStateToProps)(SelectedApp) +function mapDispatchToProps (dispatch) { + return { + setFeatureFlagToBeta: () => dispatch(setFeatureFlag('betaUI', true)), + } +} +module.exports = connect(mapStateToProps, mapDispatchToProps)(SelectedApp) inherits(SelectedApp, Component) -function SelectedApp () { Component.call(this) } +function SelectedApp () { + this.state = { + autoAdd: false, + } + Component.call(this) +} + +SelectedApp.prototype.componentWillReceiveProps = function (nextProps) { + const { isUnlocked, setFeatureFlagToBeta } = this.props + + if (!isUnlocked && nextProps.isUnlocked && nextProps.autoAdd) { + this.setState({ autoAdd: nextProps.autoAdd }) + setFeatureFlagToBeta() + } +} SelectedApp.prototype.render = function () { const { betaUI } = this.props + const { autoAdd } = this.state const Selected = betaUI ? App : OldApp return h(Selected) } -- cgit v1.2.3