From 624139a00f43f2e0837fcc1a1ce0a3e9852baa78 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Wed, 18 Sep 2019 18:41:36 -0300 Subject: [PATCH] Remove unused components (#7191) * Remove unused sendWarnings The send warnings state and associated component is no longer used anywhere. * Remove unused subtitleParams The `subtitleParams` SendHeader prop was being ignored. It has been removed, along with associated selectors and tests. --- ui/app/ducks/send/send-duck.test.js | 10 ------- ui/app/ducks/send/send.duck.js | 16 ----------- .../add-recipient/add-recipient.selectors.js | 5 ---- .../send-row-warning-message/index.js | 1 - .../send-row-warning-message.component.js | 27 ------------------ .../send-row-warning-message.container.js | 12 -------- .../send-row-warning-message.scss | 0 ...send-row-warning-message-component.test.js | 28 ------------------- ...send-row-warning-message-container.test.js | 28 ------------------- .../send-row-wrapper.component.js | 9 ------ .../send/send-header/send-header.component.js | 1 - .../send/send-header/send-header.container.js | 3 +- .../send/send-header/send-header.selectors.js | 14 ---------- .../tests/send-header-component.test.js | 1 - .../tests/send-header-container.test.js | 2 -- .../tests/send-header-selectors.test.js | 18 ------------ ui/app/pages/send/send.selectors.js | 6 ---- ui/app/store/actions.js | 9 ------ 18 files changed, 1 insertion(+), 189 deletions(-) delete mode 100644 ui/app/pages/send/send-content/send-row-wrapper/send-row-warning-message/index.js delete mode 100644 ui/app/pages/send/send-content/send-row-wrapper/send-row-warning-message/send-row-warning-message.component.js delete mode 100644 ui/app/pages/send/send-content/send-row-wrapper/send-row-warning-message/send-row-warning-message.container.js delete mode 100644 ui/app/pages/send/send-content/send-row-wrapper/send-row-warning-message/send-row-warning-message.scss delete mode 100644 ui/app/pages/send/send-content/send-row-wrapper/send-row-warning-message/tests/send-row-warning-message-component.test.js delete mode 100644 ui/app/pages/send/send-content/send-row-wrapper/send-row-warning-message/tests/send-row-warning-message-container.test.js diff --git a/ui/app/ducks/send/send-duck.test.js b/ui/app/ducks/send/send-duck.test.js index 92c8dffd8d5c..8248ba032d5e 100644 --- a/ui/app/ducks/send/send-duck.test.js +++ b/ui/app/ducks/send/send-duck.test.js @@ -6,7 +6,6 @@ import SendReducer, { updateSendErrors, showGasButtonGroup, hideGasButtonGroup, - updateSendWarnings, } from './send.duck.js' describe('Send Duck', () => { @@ -20,14 +19,12 @@ describe('Send Duck', () => { toDropdownOpen: false, errors: {}, gasButtonGroupShown: true, - warnings: {}, } const OPEN_FROM_DROPDOWN = 'metamask/send/OPEN_FROM_DROPDOWN' const CLOSE_FROM_DROPDOWN = 'metamask/send/CLOSE_FROM_DROPDOWN' const OPEN_TO_DROPDOWN = 'metamask/send/OPEN_TO_DROPDOWN' const CLOSE_TO_DROPDOWN = 'metamask/send/CLOSE_TO_DROPDOWN' const UPDATE_SEND_ERRORS = 'metamask/send/UPDATE_SEND_ERRORS' - const UPDATE_SEND_WARNINGS = 'metamask/send/UPDATE_SEND_WARNINGS' const RESET_SEND_STATE = 'metamask/send/RESET_SEND_STATE' const SHOW_GAS_BUTTON_GROUP = 'metamask/send/SHOW_GAS_BUTTON_GROUP' const HIDE_GAS_BUTTON_GROUP = 'metamask/send/HIDE_GAS_BUTTON_GROUP' @@ -176,11 +173,4 @@ describe('Send Duck', () => { ) }) - describe('updateSendWarnings', () => { - assert.deepEqual( - updateSendWarnings('mockWarningObject'), - { type: UPDATE_SEND_WARNINGS, value: 'mockWarningObject' } - ) - }) - }) diff --git a/ui/app/ducks/send/send.duck.js b/ui/app/ducks/send/send.duck.js index 90e92140bded..4d212bd03199 100644 --- a/ui/app/ducks/send/send.duck.js +++ b/ui/app/ducks/send/send.duck.js @@ -6,7 +6,6 @@ const CLOSE_FROM_DROPDOWN = 'metamask/send/CLOSE_FROM_DROPDOWN' const OPEN_TO_DROPDOWN = 'metamask/send/OPEN_TO_DROPDOWN' const CLOSE_TO_DROPDOWN = 'metamask/send/CLOSE_TO_DROPDOWN' const UPDATE_SEND_ERRORS = 'metamask/send/UPDATE_SEND_ERRORS' -const UPDATE_SEND_WARNINGS = 'metamask/send/UPDATE_SEND_WARNINGS' const RESET_SEND_STATE = 'metamask/send/RESET_SEND_STATE' const SHOW_GAS_BUTTON_GROUP = 'metamask/send/SHOW_GAS_BUTTON_GROUP' const HIDE_GAS_BUTTON_GROUP = 'metamask/send/HIDE_GAS_BUTTON_GROUP' @@ -17,7 +16,6 @@ const initState = { toDropdownOpen: false, gasButtonGroupShown: true, errors: {}, - warnings: {}, } // Reducer @@ -48,13 +46,6 @@ export default function reducer ({ send: sendState = initState }, action = {}) { ...action.value, }, }) - case UPDATE_SEND_WARNINGS: - return extend(newState, { - warnings: { - ...newState.warnings, - ...action.value, - }, - }) case SHOW_GAS_BUTTON_GROUP: return extend(newState, { gasButtonGroupShown: true, @@ -94,13 +85,6 @@ export function updateSendErrors (errorObject) { } } -export function updateSendWarnings (warningObject) { - return { - type: UPDATE_SEND_WARNINGS, - value: warningObject, - } -} - export function resetSendState () { return { type: RESET_SEND_STATE } } diff --git a/ui/app/pages/send/send-content/add-recipient/add-recipient.selectors.js b/ui/app/pages/send/send-content/add-recipient/add-recipient.selectors.js index a39db78138cf..e07da44c9325 100644 --- a/ui/app/pages/send/send-content/add-recipient/add-recipient.selectors.js +++ b/ui/app/pages/send/send-content/add-recipient/add-recipient.selectors.js @@ -2,7 +2,6 @@ const selectors = { getToDropdownOpen, getTokens, sendToIsInError, - sendToIsInWarning, } module.exports = selectors @@ -15,10 +14,6 @@ function sendToIsInError (state) { return Boolean(state.send.errors.to) } -function sendToIsInWarning (state) { - return Boolean(state.send.warnings.to) -} - function getTokens (state) { return state.metamask.tokens } diff --git a/ui/app/pages/send/send-content/send-row-wrapper/send-row-warning-message/index.js b/ui/app/pages/send/send-content/send-row-wrapper/send-row-warning-message/index.js deleted file mode 100644 index fd4d19ef7499..000000000000 --- a/ui/app/pages/send/send-content/send-row-wrapper/send-row-warning-message/index.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from './send-row-warning-message.container' diff --git a/ui/app/pages/send/send-content/send-row-wrapper/send-row-warning-message/send-row-warning-message.component.js b/ui/app/pages/send/send-content/send-row-wrapper/send-row-warning-message/send-row-warning-message.component.js deleted file mode 100644 index 6ddddbb3df2d..000000000000 --- a/ui/app/pages/send/send-content/send-row-wrapper/send-row-warning-message/send-row-warning-message.component.js +++ /dev/null @@ -1,27 +0,0 @@ -import React, { Component } from 'react' -import PropTypes from 'prop-types' - -export default class SendRowWarningMessage extends Component { - - static propTypes = { - warnings: PropTypes.object, - warningType: PropTypes.string, - }; - - static contextTypes = { - t: PropTypes.func, - }; - - render () { - const { warnings, warningType } = this.props - - const warningMessage = warningType in warnings && warnings[warningType] - - return ( - warningMessage - ?
{this.context.t(warningMessage)}
- : null - ) - } - -} diff --git a/ui/app/pages/send/send-content/send-row-wrapper/send-row-warning-message/send-row-warning-message.container.js b/ui/app/pages/send/send-content/send-row-wrapper/send-row-warning-message/send-row-warning-message.container.js deleted file mode 100644 index 7df14fd961ee..000000000000 --- a/ui/app/pages/send/send-content/send-row-wrapper/send-row-warning-message/send-row-warning-message.container.js +++ /dev/null @@ -1,12 +0,0 @@ -import { connect } from 'react-redux' -import { getSendWarnings } from '../../../send.selectors' -import SendRowWarningMessage from './send-row-warning-message.component' - -export default connect(mapStateToProps)(SendRowWarningMessage) - -function mapStateToProps (state, ownProps) { - return { - warnings: getSendWarnings(state), - warningType: ownProps.warningType, - } -} diff --git a/ui/app/pages/send/send-content/send-row-wrapper/send-row-warning-message/send-row-warning-message.scss b/ui/app/pages/send/send-content/send-row-wrapper/send-row-warning-message/send-row-warning-message.scss deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/ui/app/pages/send/send-content/send-row-wrapper/send-row-warning-message/tests/send-row-warning-message-component.test.js b/ui/app/pages/send/send-content/send-row-wrapper/send-row-warning-message/tests/send-row-warning-message-component.test.js deleted file mode 100644 index bd803d833a5f..000000000000 --- a/ui/app/pages/send/send-content/send-row-wrapper/send-row-warning-message/tests/send-row-warning-message-component.test.js +++ /dev/null @@ -1,28 +0,0 @@ -import React from 'react' -import assert from 'assert' -import { shallow } from 'enzyme' -import SendRowWarningMessage from '../send-row-warning-message.component.js' - -describe('SendRowWarningMessage Component', function () { - let wrapper - - beforeEach(() => { - wrapper = shallow(, { context: { t: str => str + '_t' } }) - }) - - describe('render', () => { - it('should render null if the passed warnings do not contain a warning of warningType', () => { - assert.equal(wrapper.find('.send-v2__warning').length, 0) - assert.equal(wrapper.html(), null) - }) - - it('should render a warning message if the passed warnings contain a warning of warningType', () => { - wrapper.setProps({ warnings: { warning1: 'abc', warning2: 'def', warning3: 'xyz' } }) - assert.equal(wrapper.find('.send-v2__warning').length, 1) - assert.equal(wrapper.find('.send-v2__warning').text(), 'xyz_t') - }) - }) -}) diff --git a/ui/app/pages/send/send-content/send-row-wrapper/send-row-warning-message/tests/send-row-warning-message-container.test.js b/ui/app/pages/send/send-content/send-row-wrapper/send-row-warning-message/tests/send-row-warning-message-container.test.js deleted file mode 100644 index 6c0739f0e826..000000000000 --- a/ui/app/pages/send/send-content/send-row-wrapper/send-row-warning-message/tests/send-row-warning-message-container.test.js +++ /dev/null @@ -1,28 +0,0 @@ -import assert from 'assert' -import proxyquire from 'proxyquire' - -let mapStateToProps - -proxyquire('../send-row-warning-message.container.js', { - 'react-redux': { - connect: (ms) => { - mapStateToProps = ms - return () => ({}) - }, - }, - '../../../send.selectors': { getSendWarnings: (s) => `mockWarnings:${s}` }, -}) - -describe('send-row-warning-message container', () => { - - describe('mapStateToProps()', () => { - - it('should map the correct properties to props', () => { - assert.deepEqual(mapStateToProps('mockState', { warningType: 'someType' }), { - warnings: 'mockWarnings:mockState', - warningType: 'someType' }) - }) - - }) - -}) diff --git a/ui/app/pages/send/send-content/send-row-wrapper/send-row-wrapper.component.js b/ui/app/pages/send/send-content/send-row-wrapper/send-row-wrapper.component.js index 075b86633d3d..9ac81576b410 100644 --- a/ui/app/pages/send/send-content/send-row-wrapper/send-row-wrapper.component.js +++ b/ui/app/pages/send/send-content/send-row-wrapper/send-row-wrapper.component.js @@ -1,7 +1,6 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import SendRowErrorMessage from './send-row-error-message' -import SendRowWarningMessage from './send-row-warning-message' export default class SendRowWrapper extends Component { @@ -10,8 +9,6 @@ export default class SendRowWrapper extends Component { errorType: PropTypes.string, label: PropTypes.string, showError: PropTypes.bool, - showWarning: PropTypes.bool, - warningType: PropTypes.string, }; static contextTypes = { @@ -24,8 +21,6 @@ export default class SendRowWrapper extends Component { errorType = '', label, showError = false, - showWarning = false, - warningType = '', } = this.props const formField = Array.isArray(children) ? children[1] || children[0] : children const customLabelContent = children.length > 1 ? children[0] : null @@ -42,7 +37,6 @@ export default class SendRowWrapper extends Component {
{showError && } - {!showError && showWarning && }
@@ -55,8 +49,6 @@ export default class SendRowWrapper extends Component { errorType = '', label, showError = false, - showWarning = false, - warningType = '', } = this.props const formField = Array.isArray(children) ? children[1] || children[0] : children @@ -67,7 +59,6 @@ export default class SendRowWrapper extends Component {
{label} {showError && } - {!showError && showWarning && } {customLabelContent}
diff --git a/ui/app/pages/send/send-header/send-header.component.js b/ui/app/pages/send/send-header/send-header.component.js index 5bc76fcd39b4..c4c4f866deb1 100644 --- a/ui/app/pages/send/send-header/send-header.component.js +++ b/ui/app/pages/send/send-header/send-header.component.js @@ -9,7 +9,6 @@ export default class SendHeader extends Component { clearSend: PropTypes.func, history: PropTypes.object, titleKey: PropTypes.string, - subtitleParams: PropTypes.array, }; static contextTypes = { diff --git a/ui/app/pages/send/send-header/send-header.container.js b/ui/app/pages/send/send-header/send-header.container.js index 1a9c5e9c0df8..7d57a71e9cd6 100644 --- a/ui/app/pages/send/send-header/send-header.container.js +++ b/ui/app/pages/send/send-header/send-header.container.js @@ -1,14 +1,13 @@ import { connect } from 'react-redux' import { clearSend } from '../../../store/actions' import SendHeader from './send-header.component' -import { getSubtitleParams, getTitleKey } from './send-header.selectors' +import { getTitleKey } from './send-header.selectors' export default connect(mapStateToProps, mapDispatchToProps)(SendHeader) function mapStateToProps (state) { return { titleKey: getTitleKey(state), - subtitleParams: getSubtitleParams(state), } } diff --git a/ui/app/pages/send/send-header/send-header.selectors.js b/ui/app/pages/send/send-header/send-header.selectors.js index 01b90409b21d..cf64caa4716d 100644 --- a/ui/app/pages/send/send-header/send-header.selectors.js +++ b/ui/app/pages/send/send-header/send-header.selectors.js @@ -6,7 +6,6 @@ const { const selectors = { getTitleKey, - getSubtitleParams, } module.exports = selectors @@ -27,16 +26,3 @@ function getTitleKey (state) { return 'sendETH' } } - -function getSubtitleParams (state) { - const isEditing = Boolean(getSendEditingTransactionId(state)) - const token = getSelectedToken(state) - - if (isEditing) { - return [ 'editingTransaction' ] - } else if (token) { - return [ 'onlySendTokensToAccountAddress', [ token.symbol ] ] - } else { - return [ 'onlySendToEtherAddress' ] - } -} diff --git a/ui/app/pages/send/send-header/tests/send-header-component.test.js b/ui/app/pages/send/send-header/tests/send-header-component.test.js index 91ac7e343308..eb74178c7565 100644 --- a/ui/app/pages/send/send-header/tests/send-header-component.test.js +++ b/ui/app/pages/send/send-header/tests/send-header-component.test.js @@ -24,7 +24,6 @@ describe('SendHeader Component', function () { clearSend={propsMethodSpies.clearSend} history={historySpies} titleKey={'mockTitleKey'} - subtitleParams={[ 'mockSubtitleKey', 'mockVal']} />, { context: { t: (str1, str2) => str2 ? str1 + str2 : str1 } }) }) diff --git a/ui/app/pages/send/send-header/tests/send-header-container.test.js b/ui/app/pages/send/send-header/tests/send-header-container.test.js index fdad8aab3261..0ff7491f0de6 100644 --- a/ui/app/pages/send/send-header/tests/send-header-container.test.js +++ b/ui/app/pages/send/send-header/tests/send-header-container.test.js @@ -20,7 +20,6 @@ proxyquire('../send-header.container.js', { '../../../store/actions': actionSpies, './send-header.selectors': { getTitleKey: (s) => `mockTitleKey:${s}`, - getSubtitleParams: (s) => `mockSubtitleParams:${s}`, }, }) @@ -31,7 +30,6 @@ describe('send-header container', () => { it('should map the correct properties to props', () => { assert.deepEqual(mapStateToProps('mockState'), { titleKey: 'mockTitleKey:mockState', - subtitleParams: 'mockSubtitleParams:mockState', }) }) diff --git a/ui/app/pages/send/send-header/tests/send-header-selectors.test.js b/ui/app/pages/send/send-header/tests/send-header-selectors.test.js index d22845f84c26..ad47d0cfa9b9 100644 --- a/ui/app/pages/send/send-header/tests/send-header-selectors.test.js +++ b/ui/app/pages/send/send-header/tests/send-header-selectors.test.js @@ -3,7 +3,6 @@ import proxyquire from 'proxyquire' const { getTitleKey, - getSubtitleParams, } = proxyquire('../send-header.selectors', { '../send.selectors': { getSelectedToken: (mockState) => mockState.t, @@ -32,21 +31,4 @@ describe('send-header selectors', () => { }) }) - describe('getSubtitleParams()', () => { - it('should return the correct params when getSendEditingTransactionId is truthy', () => { - assert.deepEqual(getSubtitleParams({ e: 1, t: true, to: '0x123' }), [ 'editingTransaction' ]) - }) - - it('should return the correct params when getSendEditingTransactionId is falsy and getSelectedToken is truthy', () => { - assert.deepEqual( - getSubtitleParams({ e: null, t: { symbol: 'ABC' }, to: '0x123' }), - [ 'onlySendTokensToAccountAddress', [ 'ABC' ] ] - ) - }) - - it('should return the correct params when getSendEditingTransactionId is falsy and getSelectedToken is falsy', () => { - assert.deepEqual(getSubtitleParams({ e: null, to: '0x123' }), [ 'onlySendToEtherAddress' ]) - }) - }) - }) diff --git a/ui/app/pages/send/send.selectors.js b/ui/app/pages/send/send.selectors.js index 00ecd635a10e..6ca6543ef3a8 100644 --- a/ui/app/pages/send/send.selectors.js +++ b/ui/app/pages/send/send.selectors.js @@ -53,7 +53,6 @@ const selectors = { getSendTo, getSendToAccounts, getSendToNickname, - getSendWarnings, getTokenBalance, getTokenExchangeRate, getUnapprovedTxs, @@ -244,11 +243,6 @@ function getSendToAccounts (state) { const addressBookAccounts = getAddressBook(state) return [...fromAccounts, ...addressBookAccounts] } - -function getSendWarnings (state) { - return state.send.warnings -} - function getTokenBalance (state) { return state.metamask.send.tokenBalance } diff --git a/ui/app/store/actions.js b/ui/app/store/actions.js index 0f90e9eabc9e..3e7929619eea 100644 --- a/ui/app/store/actions.js +++ b/ui/app/store/actions.js @@ -190,7 +190,6 @@ var actions = { UPDATE_SEND_AMOUNT: 'UPDATE_SEND_AMOUNT', UPDATE_SEND_MEMO: 'UPDATE_SEND_MEMO', UPDATE_SEND_ERRORS: 'UPDATE_SEND_ERRORS', - UPDATE_SEND_WARNINGS: 'UPDATE_SEND_WARNINGS', UPDATE_MAX_MODE: 'UPDATE_MAX_MODE', UPDATE_SEND: 'UPDATE_SEND', CLEAR_SEND: 'CLEAR_SEND', @@ -215,7 +214,6 @@ var actions = { setMaxModeTo, updateSend, updateSendErrors, - updateSendWarnings, clearSend, setSelectedAddress, gasLoadingStarted, @@ -1037,13 +1035,6 @@ function updateSendErrors (errorObject) { } } -function updateSendWarnings (warningObject) { - return { - type: actions.UPDATE_SEND_WARNINGS, - value: warningObject, - } -} - function setSendTokenBalance (tokenBalance) { return { type: actions.UPDATE_SEND_TOKEN_BALANCE,