Merge pull request #6082 from whymarrh/migrate-to-new-ui
Migrate all users to the new UIfeature/default_network_editable
commit
697d5adfc8
@ -0,0 +1,29 @@ |
||||
const version = 32 |
||||
const clone = require('clone') |
||||
|
||||
/** |
||||
* The purpose of this migration is to set the {@code completedUiMigration} flag based on the user's UI preferences |
||||
*/ |
||||
module.exports = { |
||||
version, |
||||
migrate: async function (originalVersionedData) { |
||||
const versionedData = clone(originalVersionedData) |
||||
versionedData.meta.version = version |
||||
const state = versionedData.data |
||||
versionedData.data = transformState(state) |
||||
return versionedData |
||||
}, |
||||
} |
||||
|
||||
function transformState (state) { |
||||
const { PreferencesController } = state |
||||
|
||||
if (PreferencesController) { |
||||
const { betaUI } = PreferencesController.featureFlags || {} |
||||
// Users who have been using the "beta" UI are considered to have completed the migration
|
||||
// as they'll see no difference in this version
|
||||
PreferencesController.completedUiMigration = betaUI |
||||
} |
||||
|
||||
return state |
||||
} |
@ -1 +0,0 @@ |
||||
export { default } from './welcome-beta.container' |
@ -1,30 +0,0 @@ |
||||
import React from 'react' |
||||
import PropTypes from 'prop-types' |
||||
import Modal, { ModalContent } from '../../modal' |
||||
|
||||
const TransactionConfirmed = (props, context) => { |
||||
const { t } = context |
||||
const { hideModal } = props |
||||
|
||||
return ( |
||||
<Modal |
||||
onSubmit={() => hideModal()} |
||||
submitText={t('ok')} |
||||
> |
||||
<ModalContent |
||||
title={t('uiWelcome')} |
||||
description={t('uiWelcomeMessage')} |
||||
/> |
||||
</Modal> |
||||
) |
||||
} |
||||
|
||||
TransactionConfirmed.contextTypes = { |
||||
t: PropTypes.func, |
||||
} |
||||
|
||||
TransactionConfirmed.propTypes = { |
||||
hideModal: PropTypes.func, |
||||
} |
||||
|
||||
export default TransactionConfirmed |
@ -1,4 +0,0 @@ |
||||
import WelcomeBeta from './welcome-beta.component' |
||||
import withModalProps from '../../../higher-order-components/with-modal-props' |
||||
|
||||
export default withModalProps(WelcomeBeta) |
@ -0,0 +1 @@ |
||||
export {default} from './ui-migration-announcement.container' |
@ -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; |
||||
} |
||||
} |
@ -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> |
||||
) |
||||
} |
||||
} |
@ -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) |
@ -1,65 +0,0 @@ |
||||
const inherits = require('util').inherits |
||||
const Component = require('react').Component |
||||
const connect = require('react-redux').connect |
||||
const h = require('react-hyperscript') |
||||
const { HashRouter } = require('react-router-dom') |
||||
const App = require('./app') |
||||
const OldApp = require('../../old-ui/app/app') |
||||
const { getShouldUseNewUi } = require('./selectors') |
||||
const { setFeatureFlag } = require('./actions') |
||||
const I18nProvider = require('./i18n-provider') |
||||
|
||||
function mapStateToProps (state) { |
||||
return { |
||||
isMascara: state.metamask.isMascara, |
||||
shouldUseNewUi: getShouldUseNewUi(state), |
||||
} |
||||
} |
||||
|
||||
function mapDispatchToProps (dispatch) { |
||||
return { |
||||
setFeatureFlagWithModal: () => { |
||||
return dispatch(setFeatureFlag('betaUI', true, 'BETA_UI_NOTIFICATION_MODAL')) |
||||
}, |
||||
setFeatureFlagWithoutModal: () => { |
||||
return dispatch(setFeatureFlag('betaUI', true)) |
||||
}, |
||||
} |
||||
} |
||||
module.exports = connect(mapStateToProps, mapDispatchToProps)(SelectedApp) |
||||
|
||||
inherits(SelectedApp, Component) |
||||
function SelectedApp () { |
||||
Component.call(this) |
||||
} |
||||
|
||||
SelectedApp.prototype.componentWillReceiveProps = function (nextProps) { |
||||
// Code commented out until we begin auto adding users to NewUI
|
||||
const { |
||||
// isUnlocked,
|
||||
// setFeatureFlagWithModal,
|
||||
setFeatureFlagWithoutModal, |
||||
isMascara, |
||||
// firstTime,
|
||||
} = this.props |
||||
|
||||
// if (isMascara || firstTime) {
|
||||
if (isMascara) { |
||||
setFeatureFlagWithoutModal() |
||||
} |
||||
// } else if (!isUnlocked && nextProps.isUnlocked && (nextProps.autoAdd)) {
|
||||
// setFeatureFlagWithModal()
|
||||
// }
|
||||
} |
||||
|
||||
SelectedApp.prototype.render = function () { |
||||
const { shouldUseNewUi } = this.props |
||||
const newUi = h(HashRouter, { |
||||
hashType: 'noslash', |
||||
}, [ |
||||
h(I18nProvider, [ |
||||
h(App), |
||||
]), |
||||
]) |
||||
return shouldUseNewUi ? newUi : h(OldApp) |
||||
} |
Loading…
Reference in new issue