1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

[NewUI] Hide UI toggle in mascara ()

* Hides old-UI on mascara.

* Improve code clarity in select-app.js
This commit is contained in:
Dan J Miller 2017-12-20 14:52:50 -03:30 committed by Alexander Tseung
parent 109e4e5d96
commit bccbf14b39
4 changed files with 23 additions and 19 deletions

View File

@ -405,7 +405,7 @@ App.prototype.renderDropdown = function () {
h(DropdownMenuItem, { h(DropdownMenuItem, {
closeMenu: () => this.setState({ isMainMenuOpen: !isOpen }), closeMenu: () => this.setState({ isMainMenuOpen: !isOpen }),
onClick: () => { this.props.dispatch(actions.setFeatureFlag('betaUI', true)) }, onClick: () => { this.props.dispatch(actions.setFeatureFlag('betaUI', true, 'BETA_UI_NOTIFICATION_MODAL')) },
}, 'Try Beta!'), }, 'Try Beta!'),
]) ])
} }

View File

@ -1523,10 +1523,7 @@ function updateTokenExchangeRate (token = '') {
} }
} }
function setFeatureFlag (feature, activated) { function setFeatureFlag (feature, activated, notificationType) {
const notificationType = activated
? 'BETA_UI_NOTIFICATION_MODAL'
: 'OLD_UI_NOTIFICATION_MODAL'
return (dispatch) => { return (dispatch) => {
dispatch(actions.showLoadingIndication()) dispatch(actions.showLoadingIndication())
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -1537,7 +1534,7 @@ function setFeatureFlag (feature, activated) {
reject(err) reject(err)
} }
dispatch(actions.updateFeatureFlags(updatedFeatureFlags)) dispatch(actions.updateFeatureFlags(updatedFeatureFlags))
dispatch(actions.showModal({ name: notificationType })) notificationType && dispatch(actions.showModal({ name: notificationType }))
resolve(updatedFeatureFlags) resolve(updatedFeatureFlags)
}) })
}) })

View File

@ -12,35 +12,40 @@ function mapStateToProps (state) {
betaUI: state.metamask.featureFlags.betaUI, betaUI: state.metamask.featureFlags.betaUI,
autoAdd: autoAddToBetaUI(state), autoAdd: autoAddToBetaUI(state),
isUnlocked: state.metamask.isUnlocked, isUnlocked: state.metamask.isUnlocked,
isMascara: state.metamask.isMascara,
} }
} }
function mapDispatchToProps (dispatch) { function mapDispatchToProps (dispatch) {
return { return {
setFeatureFlagToBeta: () => dispatch(setFeatureFlag('betaUI', true)), setFeatureFlagWithModal: () => dispatch(setFeatureFlag('betaUI', true, 'BETA_UI_NOTIFICATION_MODAL')),
setFeatureFlagWithoutModal: () => dispatch(setFeatureFlag('betaUI', true)),
} }
} }
module.exports = connect(mapStateToProps, mapDispatchToProps)(SelectedApp) module.exports = connect(mapStateToProps, mapDispatchToProps)(SelectedApp)
inherits(SelectedApp, Component) inherits(SelectedApp, Component)
function SelectedApp () { function SelectedApp () {
this.state = {
autoAdd: false,
}
Component.call(this) Component.call(this)
} }
SelectedApp.prototype.componentWillReceiveProps = function (nextProps) { SelectedApp.prototype.componentWillReceiveProps = function (nextProps) {
const { isUnlocked, setFeatureFlagToBeta } = this.props const {
isUnlocked,
setFeatureFlagWithModal,
setFeatureFlagWithoutModal,
isMascara,
} = this.props
if (!isUnlocked && nextProps.isUnlocked && nextProps.autoAdd) { if (isMascara) {
this.setState({ autoAdd: nextProps.autoAdd }) setFeatureFlagWithoutModal()
setFeatureFlagToBeta() } else if (!isUnlocked && nextProps.isUnlocked && (nextProps.autoAdd)) {
setFeatureFlagWithModal()
} }
} }
SelectedApp.prototype.render = function () { SelectedApp.prototype.render = function () {
const { betaUI } = this.props const { betaUI, isMascara } = this.props
const Selected = betaUI ? App : OldApp const Selected = betaUI || isMascara ? App : OldApp
return h(Selected) return h(Selected)
} }

View File

@ -250,7 +250,7 @@ class Settings extends Component {
} }
renderSettingsContent () { renderSettingsContent () {
const { warning } = this.props const { warning, isMascara } = this.props
return ( return (
h('div.settings__content', [ h('div.settings__content', [
@ -261,7 +261,7 @@ class Settings extends Component {
this.renderNewRpcUrl(), this.renderNewRpcUrl(),
this.renderStateLogs(), this.renderStateLogs(),
this.renderSeedWords(), this.renderSeedWords(),
this.renderOldUI(), !isMascara && this.renderOldUI(),
]) ])
) )
} }
@ -386,12 +386,14 @@ Settings.propTypes = {
setFeatureFlagToBeta: PropTypes.func, setFeatureFlagToBeta: PropTypes.func,
warning: PropTypes.string, warning: PropTypes.string,
goHome: PropTypes.func, goHome: PropTypes.func,
isMascara: PropTypes.bool,
} }
const mapStateToProps = state => { const mapStateToProps = state => {
return { return {
metamask: state.metamask, metamask: state.metamask,
warning: state.appState.warning, warning: state.appState.warning,
isMascara: state.metamask.isMascara,
} }
} }
@ -403,7 +405,7 @@ const mapDispatchToProps = dispatch => {
displayWarning: warning => dispatch(actions.displayWarning(warning)), displayWarning: warning => dispatch(actions.displayWarning(warning)),
revealSeedConfirmation: () => dispatch(actions.revealSeedConfirmation()), revealSeedConfirmation: () => dispatch(actions.revealSeedConfirmation()),
setUseBlockie: value => dispatch(actions.setUseBlockie(value)), setUseBlockie: value => dispatch(actions.setUseBlockie(value)),
setFeatureFlagToBeta: () => dispatch(actions.setFeatureFlag('betaUI', false)), setFeatureFlagToBeta: () => dispatch(actions.setFeatureFlag('betaUI', false, 'OLD_UI_NOTIFICATION_MODAL')),
} }
} }