Skip to content

Commit

Permalink
Add announcement for users migrated to the new UI
Browse files Browse the repository at this point in the history
  • Loading branch information
whymarrh committed Feb 5, 2019
1 parent c52ba96 commit f3a7054
Show file tree
Hide file tree
Showing 15 changed files with 122 additions and 50 deletions.
3 changes: 3 additions & 0 deletions app/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1437,6 +1437,9 @@
"typePassword": {
"message": "Type your MetaMask password"
},
"uiMigrationAnnouncement": {
"message": "Welcome to the new MetaMask UI. If you have feedback about the UI or feature requests, please reach out to our support team or on GitHub."
},
"uiWelcome": {
"message": "Welcome to the New UI (Beta)"
},
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/controllers/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class PreferencesController {
useNativeCurrencyAsPrimaryCurrency: true,
},
completedOnboarding: false,
completedUiMigration: false,
completedUiMigration: true,
}, opts.initState)

this.diagnostics = opts.diagnostics
Expand Down
1 change: 1 addition & 0 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ module.exports = class MetamaskController extends EventEmitter {
setAccountLabel: nodeify(preferencesController.setAccountLabel, preferencesController),
setFeatureFlag: nodeify(preferencesController.setFeatureFlag, preferencesController),
setPreference: nodeify(preferencesController.setPreference, preferencesController),
completeUiMigration: nodeify(preferencesController.completeUiMigration, preferencesController),
completeOnboarding: nodeify(preferencesController.completeOnboarding, preferencesController),
addKnownMethodData: nodeify(preferencesController.addKnownMethodData, preferencesController),

Expand Down
30 changes: 30 additions & 0 deletions ui/app/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,11 @@ var actions = {
UPDATE_PREFERENCES: 'UPDATE_PREFERENCES',
setUseNativeCurrencyAsPrimaryCurrencyPreference,

// Migration of users to new UI
setCompletedUiMigration,
completeUiMigration,
COMPLETE_UI_MIGRATION: 'COMPLETE_UI_MIGRATION',

// Onboarding
setCompletedOnboarding,
completeOnboarding,
Expand Down Expand Up @@ -2474,6 +2479,31 @@ function completeOnboarding () {
}
}

function setCompletedUiMigration () {
return dispatch => {
dispatch(actions.showLoadingIndication())
return new Promise((resolve, reject) => {
background.completeUiMigration(err => {
dispatch(actions.hideLoadingIndication())

if (err) {
dispatch(actions.displayWarning(err.message))
return reject(err)
}

dispatch(actions.completeUiMigration())
resolve()
})
})
}
}

function completeUiMigration () {
return {
type: actions.COMPLETE_UI_MIGRATION,
}
}

function setNetworkNonce (networkNonce) {
return {
type: actions.SET_NETWORK_NONCE,
Expand Down
2 changes: 2 additions & 0 deletions ui/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import Settings from './components/pages/settings'
import Authenticated from './higher-order-components/authenticated'
import Initialized from './higher-order-components/initialized'
import Lock from './components/pages/lock'
import UiMigrationAnnouncement from './components/ui-migration-annoucement'
const RestoreVaultPage = require('./components/pages/keychains/restore-vault').default
const RevealSeedConfirmation = require('./components/pages/keychains/reveal-seed')
const AddTokenPage = require('./components/pages/add-token')
Expand Down Expand Up @@ -173,6 +174,7 @@ class App extends Component {
}
}}
>
<UiMigrationAnnouncement />
<Modal />
<Alert
visible={this.props.alertOpen}
Expand Down
2 changes: 2 additions & 0 deletions ui/app/components/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,5 @@
@import './gas-customization/index';

@import './gas-customization/gas-price-button-group/index';

@import './ui-migration-annoucement/index';
14 changes: 0 additions & 14 deletions ui/app/components/modals/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import ConfirmRemoveAccount from './confirm-remove-account'
import ConfirmResetAccount from './confirm-reset-account'
import TransactionConfirmed from './transaction-confirmed'
import CancelTransaction from './cancel-transaction'
import WelcomeBeta from './welcome-beta'
import RejectTransactions from './reject-transactions'
import ClearApprovedOrigins from './clear-approved-origins'
import ConfirmCustomizeGasModal from '../gas-customization/gas-modal-page-container'
Expand Down Expand Up @@ -201,19 +200,6 @@ const MODALS = {
},
},

BETA_UI_NOTIFICATION_MODAL: {
contents: h(WelcomeBeta),
mobileModalStyle: {
...modalContainerMobileStyle,
},
laptopModalStyle: {
...modalContainerLaptopStyle,
},
contentStyle: {
borderRadius: '8px',
},
},

CLEAR_APPROVED_ORIGINS: {
contents: h(ClearApprovedOrigins),
mobileModalStyle: {
Expand Down
1 change: 0 additions & 1 deletion ui/app/components/modals/welcome-beta/index.js

This file was deleted.

30 changes: 0 additions & 30 deletions ui/app/components/modals/welcome-beta/welcome-beta.component.js

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions ui/app/components/ui-migration-annoucement/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {default} from './ui-migration-announcement.container'
22 changes: 22 additions & 0 deletions ui/app/components/ui-migration-annoucement/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.ui-migration-announcement {
position: absolute;
z-index: 9999;
width: 100vw;
height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
background: $white;

p {
box-sizing: border-box;
padding: 1em;
font-size: 12pt;
}

p:last-of-type {
cursor: pointer;
text-decoration: underline;
font-weight: bold;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import PropTypes from 'prop-types'
import React, {PureComponent} from 'react'

export default class UiMigrationAnnouncement extends PureComponent {
static contextTypes = {
t: PropTypes.func.isRequired,
}

static defaultProps = {
shouldShowAnnouncement: true,
};

static propTypes = {
onClose: PropTypes.func.isRequired,
shouldShowAnnouncement: PropTypes.bool,
}

render () {
const { t } = this.context
const { onClose, shouldShowAnnouncement } = this.props

if (!shouldShowAnnouncement) {
return null
}

return (
<div className="ui-migration-announcement">
<p>{t('uiMigrationAnnouncement')}</p>
<p onClick={onClose}>{t('close')}</p>
</div>
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { connect } from 'react-redux'
import UiMigrationAnnouncement from './ui-migration-annoucement.component'
import { setCompletedUiMigration } from '../../actions'

const mapStateToProps = (state) => {
const shouldShowAnnouncement = !state.metamask.completedUiMigration

return {
shouldShowAnnouncement,
}
}

const mapDispatchToProps = dispatch => {
return {
onClose () {
dispatch(setCompletedUiMigration())
},
}
}

export default connect(mapStateToProps, mapDispatchToProps)(UiMigrationAnnouncement)
6 changes: 6 additions & 0 deletions ui/app/reducers/metamask.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,12 @@ function reduceMetamask (state, action) {
})
}

case actions.COMPLETE_UI_MIGRATION: {
return extend(metamaskState, {
completedUiMigration: true,
})
}

default:
return metamaskState

Expand Down

0 comments on commit f3a7054

Please sign in to comment.