diff options
Diffstat (limited to 'ui/app')
-rw-r--r-- | ui/app/actions.js | 44 | ||||
-rw-r--r-- | ui/app/app.js | 16 | ||||
-rw-r--r-- | ui/app/components/drop-menu-item.js | 3 | ||||
-rw-r--r-- | ui/app/components/network.js | 12 | ||||
-rw-r--r-- | ui/app/config.js | 2 | ||||
-rw-r--r-- | ui/app/first-time/disclaimer.js | 12 | ||||
-rw-r--r-- | ui/app/notice.js | 118 | ||||
-rw-r--r-- | ui/app/reducers/app.js | 6 | ||||
-rw-r--r-- | ui/app/reducers/metamask.js | 13 |
9 files changed, 201 insertions, 25 deletions
diff --git a/ui/app/actions.js b/ui/app/actions.js index 61f15b6cc..1c32c9bb1 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -13,6 +13,13 @@ var actions = { // remote state UPDATE_METAMASK_STATE: 'UPDATE_METAMASK_STATE', updateMetamaskState: updateMetamaskState, + // notices + MARK_NOTICE_READ: 'MARK_NOTICE_READ', + markNoticeRead: markNoticeRead, + SHOW_NOTICE: 'SHOW_NOTICE', + showNotice: showNotice, + CLEAR_NOTICES: 'CLEAR_NOTICES', + clearNotices: clearNotices, // intialize screen AGREE_TO_DISCLAIMER: 'AGREE_TO_DISCLAIMER', agreeToDisclaimer: agreeToDisclaimer, @@ -548,6 +555,43 @@ function goBackToInitView () { } // +// notice +// + +function markNoticeRead (notice) { + return (dispatch) => { + dispatch(this.showLoadingIndication()) + background.markNoticeRead(notice, (err, notice) => { + dispatch(this.hideLoadingIndication()) + if (err) { + return dispatch(actions.showWarning(err)) + } + if (notice) { + return dispatch(actions.showNotice(notice)) + } else { + dispatch(this.clearNotices()) + return { + type: actions.SHOW_ACCOUNTS_PAGE, + } + } + }) + } +} + +function showNotice (notice) { + return { + type: actions.SHOW_NOTICE, + value: notice, + } +} + +function clearNotices () { + return { + type: actions.CLEAR_NOTICES, + } +} + +// // config // diff --git a/ui/app/app.js b/ui/app/app.js index 9538a6b93..2fa6415dd 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -15,6 +15,8 @@ const AccountsScreen = require('./accounts') const AccountDetailScreen = require('./account-detail') const SendTransactionScreen = require('./send') const ConfirmTxScreen = require('./conf-tx') +// notice +const NoticeScreen = require('./notice') // other views const ConfigScreen = require('./config') const InfoScreen = require('./info') @@ -40,6 +42,7 @@ function mapStateToProps (state) { // state from plugin isLoading: state.appState.isLoading, isDisclaimerConfirmed: state.metamask.isDisclaimerConfirmed, + noActiveNotices: state.metamask.noActiveNotices, isInitialized: state.metamask.isInitialized, isUnlocked: state.metamask.isUnlocked, currentView: state.appState.currentView, @@ -241,15 +244,6 @@ App.prototype.renderNetworkDropdown = function () { }), h(DropMenuItem, { - label: 'Morden Test Network', - closeMenu: () => this.setState({ isNetworkMenuOpen: false }), - action: () => props.dispatch(actions.setProviderType('morden')), - icon: h('.menu-icon.red-dot'), - activeNetworkRender: props.network, - provider: props.provider, - }), - - h(DropMenuItem, { label: 'Localhost 8545', closeMenu: () => this.setState({ isNetworkMenuOpen: false }), action: () => props.dispatch(actions.setRpcTarget('http://localhost:8545')), @@ -372,6 +366,10 @@ App.prototype.renderPrimary = function () { } } + if (!props.noActiveNotices) { + return h(NoticeScreen, {key: 'NoticeScreen'}) + } + // show current view switch (props.currentView.name) { diff --git a/ui/app/components/drop-menu-item.js b/ui/app/components/drop-menu-item.js index 7cf686cab..9f002234e 100644 --- a/ui/app/components/drop-menu-item.js +++ b/ui/app/components/drop-menu-item.js @@ -44,9 +44,6 @@ DropMenuItem.prototype.activeNetworkRender = function () { case 'Ropsten Test Network': if (provider.type === 'testnet') return h('.check', '✓') break - case 'Morden Test Network': - if (provider.type === 'morden') return h('.check', '✓') - break case 'Localhost 8545': if (activeNetwork === 'http://localhost:8545') return h('.check', '✓') break diff --git a/ui/app/components/network.js b/ui/app/components/network.js index 9cf597648..43dc747b3 100644 --- a/ui/app/components/network.js +++ b/ui/app/components/network.js @@ -40,9 +40,6 @@ Network.prototype.render = function () { } else if (parseInt(networkNumber) === 3) { hoverText = 'Ropsten Test Network' iconName = 'ropsten-test-network' - } else if (parseInt(networkNumber) === 2) { - hoverText = 'Morden Test Network' - iconName = 'morden-test-network' } else { hoverText = 'Unknown Private Network' iconName = 'unknown-private-network' @@ -77,15 +74,6 @@ Network.prototype.render = function () { }}, 'Ropsten Test Net'), ]) - case 'morden-test-network': - return h('.network-indicator', [ - h('.menu-icon.red-dot'), - h('.network-name', { - style: { - color: '#ff6666', - }}, - 'Morden Test Net'), - ]) default: return h('.network-indicator', [ h('i.fa.fa-question-circle.fa-lg', { diff --git a/ui/app/config.js b/ui/app/config.js index 7e49cf048..3730baf6b 100644 --- a/ui/app/config.js +++ b/ui/app/config.js @@ -133,7 +133,7 @@ function currentProviderDisplay (metamaskState) { case 'testnet': title = 'Current Network' - value = 'Morden Test Network' + value = 'Ropsten Test Network' break default: diff --git a/ui/app/first-time/disclaimer.js b/ui/app/first-time/disclaimer.js index 819d4a110..a8bafd39b 100644 --- a/ui/app/first-time/disclaimer.js +++ b/ui/app/first-time/disclaimer.js @@ -6,6 +6,8 @@ const actions = require('../actions') const ReactMarkdown = require('react-markdown') const fs = require('fs') const path = require('path') +const linker = require('extension-link-enabler') +const findDOMNode = require('react-dom').findDOMNode const disclaimer = fs.readFileSync(path.join(__dirname, '..', '..', '..', 'USER_AGREEMENT.md')).toString() module.exports = connect(mapStateToProps)(DisclaimerScreen) @@ -98,3 +100,13 @@ DisclaimerScreen.prototype.render = function () { ]) ) } + +DisclaimerScreen.prototype.componentDidMount = function () { + var node = findDOMNode(this) + linker.setupListener(node) +} + +DisclaimerScreen.prototype.componentWillUnmount = function () { + var node = findDOMNode(this) + linker.teardownListener(node) +} diff --git a/ui/app/notice.js b/ui/app/notice.js new file mode 100644 index 000000000..3c2c746f2 --- /dev/null +++ b/ui/app/notice.js @@ -0,0 +1,118 @@ +const inherits = require('util').inherits +const Component = require('react').Component +const h = require('react-hyperscript') +const ReactMarkdown = require('react-markdown') +const connect = require('react-redux').connect +const actions = require('./actions') +const linker = require('extension-link-enabler') +const findDOMNode = require('react-dom').findDOMNode + +module.exports = connect(mapStateToProps)(Notice) + +function mapStateToProps (state) { + return { + lastUnreadNotice: state.metamask.lastUnreadNotice, + } +} + +inherits(Notice, Component) +function Notice () { + Component.call(this) +} + +Notice.prototype.render = function () { + const props = this.props + const title = props.lastUnreadNotice.title + const date = props.lastUnreadNotice.date + + return ( + h('.flex-column.flex-center.flex-grow', [ + h('h3.flex-center.text-transform-uppercacse.terms-header', { + style: { + background: '#EBEBEB', + color: '#AEAEAE', + width: '100%', + fontSize: '20px', + textAlign: 'center', + padding: 6, + }, + }, [ + title, + ]), + + h('h5.flex-center.text-transform-uppercacse.terms-header', { + style: { + background: '#EBEBEB', + color: '#AEAEAE', + marginBottom: 24, + width: '100%', + fontSize: '20px', + textAlign: 'center', + padding: 6, + }, + }, [ + date, + ]), + + h('style', ` + + .markdown { + overflow-x: hidden; + } + .markdown h1, .markdown h2, .markdown h3 { + margin: 10px 0; + font-weight: bold; + } + + .markdown strong { + font-weight: bold; + } + .markdown em { + font-style: italic; + } + + .markdown p { + margin: 10px 0; + } + + .markdown a { + color: #df6b0e; + } + + `), + + h('div.markdown', { + style: { + background: 'rgb(235, 235, 235)', + height: '310px', + padding: '6px', + width: '90%', + overflowY: 'scroll', + scroll: 'auto', + }, + }, [ + h(ReactMarkdown, { + source: props.lastUnreadNotice.body, + skipHtml: true, + }), + ]), + + h('button', { + onClick: () => props.dispatch(actions.markNoticeRead(props.lastUnreadNotice)), + style: { + marginTop: '18px', + }, + }, 'Continue'), + ]) + ) +} + +Notice.prototype.componentDidMount = function () { + var node = findDOMNode(this) + linker.setupListener(node) +} + +Notice.prototype.componentWillUnmount = function () { + var node = findDOMNode(this) + linker.teardownListener(node) +} diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js index fb6767233..65a3dba49 100644 --- a/ui/app/reducers/app.js +++ b/ui/app/reducers/app.js @@ -258,6 +258,12 @@ function reduceApp (state, action) { forgottenPassword: false, }) + case actions.SHOW_NOTICE: + return extend(appState, { + transForward: true, + isLoading: false, + }) + case actions.REVEAL_ACCOUNT: return extend(appState, { scrollToBottom: true, diff --git a/ui/app/reducers/metamask.js b/ui/app/reducers/metamask.js index 1a4514a21..8679ab062 100644 --- a/ui/app/reducers/metamask.js +++ b/ui/app/reducers/metamask.js @@ -16,6 +16,8 @@ function reduceMetamask (state, action) { currentFiat: 'USD', conversionRate: 0, conversionDate: 'N/A', + noActiveNotices: true, + lastUnreadNotice: undefined, }, state.metamask) switch (action.type) { @@ -25,6 +27,17 @@ function reduceMetamask (state, action) { delete newState.seedWords return newState + case actions.SHOW_NOTICE: + return extend(metamaskState, { + noActiveNotices: false, + lastUnreadNotice: action.value, + }) + + case actions.CLEAR_NOTICES: + return extend(metamaskState, { + noActiveNotices: true, + }) + case actions.UPDATE_METAMASK_STATE: return extend(metamaskState, action.value) |