Skip to content

Commit

Permalink
Remove unused components (#7191)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
Gudahtt authored Sep 18, 2019
1 parent 5b309af commit 624139a
Show file tree
Hide file tree
Showing 18 changed files with 1 addition and 189 deletions.
10 changes: 0 additions & 10 deletions ui/app/ducks/send/send-duck.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import SendReducer, {
updateSendErrors,
showGasButtonGroup,
hideGasButtonGroup,
updateSendWarnings,
} from './send.duck.js'

describe('Send Duck', () => {
Expand All @@ -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'
Expand Down Expand Up @@ -176,11 +173,4 @@ describe('Send Duck', () => {
)
})

describe('updateSendWarnings', () => {
assert.deepEqual(
updateSendWarnings('mockWarningObject'),
{ type: UPDATE_SEND_WARNINGS, value: 'mockWarningObject' }
)
})

})
16 changes: 0 additions & 16 deletions ui/app/ducks/send/send.duck.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -17,7 +16,6 @@ const initState = {
toDropdownOpen: false,
gasButtonGroupShown: true,
errors: {},
warnings: {},
}

// Reducer
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const selectors = {
getToDropdownOpen,
getTokens,
sendToIsInError,
sendToIsInWarning,
}

module.exports = selectors
Expand All @@ -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
}

This file was deleted.

This file was deleted.

This file was deleted.

Empty file.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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 {

Expand All @@ -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 = {
Expand All @@ -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
Expand All @@ -42,7 +37,6 @@ export default class SendRowWrapper extends Component {
</div>
<div>
{showError && <SendRowErrorMessage errorType={errorType} />}
{!showError && showWarning && <SendRowWarningMessage warningType={warningType} />}
</div>
</div>
</div>
Expand All @@ -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
Expand All @@ -67,7 +59,6 @@ export default class SendRowWrapper extends Component {
<div className="send-v2__form-label">
{label}
{showError && <SendRowErrorMessage errorType={errorType} />}
{!showError && showWarning && <SendRowWarningMessage warningType={warningType} />}
{customLabelContent}
</div>
<div className="send-v2__form-field">
Expand Down
1 change: 0 additions & 1 deletion ui/app/pages/send/send-header/send-header.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export default class SendHeader extends Component {
clearSend: PropTypes.func,
history: PropTypes.object,
titleKey: PropTypes.string,
subtitleParams: PropTypes.array,
};

static contextTypes = {
Expand Down
3 changes: 1 addition & 2 deletions ui/app/pages/send/send-header/send-header.container.js
Original file line number Diff line number Diff line change
@@ -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),
}
}

Expand Down
14 changes: 0 additions & 14 deletions ui/app/pages/send/send-header/send-header.selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const {

const selectors = {
getTitleKey,
getSubtitleParams,
}

module.exports = selectors
Expand All @@ -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' ]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 } })
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ proxyquire('../send-header.container.js', {
'../../../store/actions': actionSpies,
'./send-header.selectors': {
getTitleKey: (s) => `mockTitleKey:${s}`,
getSubtitleParams: (s) => `mockSubtitleParams:${s}`,
},
})

Expand All @@ -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',
})
})

Expand Down
18 changes: 0 additions & 18 deletions ui/app/pages/send/send-header/tests/send-header-selectors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import proxyquire from 'proxyquire'

const {
getTitleKey,
getSubtitleParams,
} = proxyquire('../send-header.selectors', {
'../send.selectors': {
getSelectedToken: (mockState) => mockState.t,
Expand Down Expand Up @@ -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' ])
})
})

})
6 changes: 0 additions & 6 deletions ui/app/pages/send/send.selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ const selectors = {
getSendTo,
getSendToAccounts,
getSendToNickname,
getSendWarnings,
getTokenBalance,
getTokenExchangeRate,
getUnapprovedTxs,
Expand Down Expand Up @@ -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
}
Expand Down
Loading

0 comments on commit 624139a

Please sign in to comment.