mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
Remove unused current view related things (#7843)
* Remove unused functions from `mapDispatchToProps` The actions import was also updated to import only the two actions used, rather than all actions. * Remove unused container component Well, technically it was the props injected by this container that were unused. The container served no purpose, so the component it surrounded is now used directly instead. * Remove both unused `getCurrentViewContext` selectors * Remove unused SHOW_CONFIG_PAGE action * Remove checks for `currentView` with name `config` Now that the SHOW_CONFIG_PAGE action has been removed, it's no longer possible for `currentView.name` to be set to that value. * Remove unused `wallet-view` container props * Delete unused SHOW_SEND_PAGE and SHOW_ADD_TOKEN_PAGE actions * Remove unused `account-menu.container` props * Remove unused SHOW_INFO_PAGE action * Remove unused SET_NEW_ACCOUNT_FORM action
This commit is contained in:
parent
4257858fb5
commit
8225bbe126
@ -17,13 +17,6 @@ describe('config view actions', function () {
|
||||
}
|
||||
freeze(initialState)
|
||||
|
||||
describe('SHOW_CONFIG_PAGE', function () {
|
||||
it('should set appState.currentView.name to config', function () {
|
||||
const result = reducers(initialState, actions.showConfigPage())
|
||||
assert.equal(result.appState.currentView.name, 'config')
|
||||
})
|
||||
})
|
||||
|
||||
describe('SET_RPC_TARGET', function () {
|
||||
it('sets the state.metamask.rpcTarget property of the state to the action.value', function () {
|
||||
const action = {
|
||||
|
@ -1,19 +0,0 @@
|
||||
import assert from 'assert'
|
||||
import freeze from 'deep-freeze-strict'
|
||||
import * as actions from '../../../ui/app/store/actions'
|
||||
import reducers from '../../../ui/app/ducks'
|
||||
|
||||
describe('SHOW_INFO_PAGE', function () {
|
||||
it('sets the state.appState.currentView.name property to info', function () {
|
||||
const initialState = {
|
||||
appState: {
|
||||
activeAddress: 'foo',
|
||||
},
|
||||
}
|
||||
freeze(initialState)
|
||||
|
||||
const action = actions.showInfoPage()
|
||||
const resultingState = reducers(initialState, action)
|
||||
assert.equal(resultingState.appState.currentView.name, 'info')
|
||||
})
|
||||
})
|
@ -146,59 +146,6 @@ describe('App State', () => {
|
||||
assert.equal(state.currentView.name, 'restoreVault')
|
||||
})
|
||||
|
||||
it('shows config page', () => {
|
||||
const state = reduceApp(metamaskState, {
|
||||
type: actions.SHOW_CONFIG_PAGE,
|
||||
value: true,
|
||||
})
|
||||
|
||||
assert.equal(state.currentView.name, 'config')
|
||||
assert.equal(state.currentView.context, '0xAddress')
|
||||
assert.equal(state.transForward, true)
|
||||
})
|
||||
|
||||
it('shows add token page', () => {
|
||||
const state = reduceApp(metamaskState, {
|
||||
type: actions.SHOW_ADD_TOKEN_PAGE,
|
||||
value: true,
|
||||
})
|
||||
|
||||
assert.equal(state.currentView.name, 'add-token')
|
||||
assert.equal(state.currentView.context, '0xAddress')
|
||||
assert.equal(state.transForward, true)
|
||||
})
|
||||
|
||||
it('sets new account form', () => {
|
||||
const state = reduceApp(metamaskState, {
|
||||
type: actions.SET_NEW_ACCOUNT_FORM,
|
||||
formToSelect: 'context',
|
||||
})
|
||||
|
||||
assert.equal(state.currentView.name, 'accountDetail')
|
||||
assert.equal(state.currentView.context, 'context')
|
||||
})
|
||||
|
||||
it('shows info page', () => {
|
||||
const state = reduceApp(metamaskState, {
|
||||
type: actions.SHOW_INFO_PAGE,
|
||||
})
|
||||
|
||||
assert.equal(state.currentView.name, 'info')
|
||||
assert.equal(state.currentView.context, '0xAddress')
|
||||
assert.equal(state.transForward, true)
|
||||
})
|
||||
|
||||
it('shows send page', () => {
|
||||
const state = reduceApp(metamaskState, {
|
||||
type: actions.SHOW_SEND_PAGE,
|
||||
})
|
||||
|
||||
assert.equal(state.currentView.name, 'sendTransaction')
|
||||
assert.equal(state.currentView.context, '0xAddress')
|
||||
assert.equal(state.transForward, true)
|
||||
assert.equal(state.warning, null)
|
||||
})
|
||||
|
||||
it('shows send token page', () => {
|
||||
const state = reduceApp(metamaskState, {
|
||||
type: actions.SHOW_SEND_TOKEN_PAGE,
|
||||
|
@ -152,11 +152,6 @@ describe('Selectors', function () {
|
||||
assert(selectedTokenContract.abi)
|
||||
})
|
||||
|
||||
it('#getCurrentViewContext', () => {
|
||||
const currentViewContext = selectors.getCurrentViewContext(mockState)
|
||||
assert.equal(currentViewContext, '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc')
|
||||
})
|
||||
|
||||
it('#getTotalUnapprovedCount', () => {
|
||||
const totalUnapprovedCount = selectors.getTotalUnapprovedCount(mockState)
|
||||
assert.equal(totalUnapprovedCount, 1)
|
||||
|
@ -7,8 +7,6 @@ import {
|
||||
hideSidebar,
|
||||
lockMetamask,
|
||||
hideWarning,
|
||||
showConfigPage,
|
||||
showInfoPage,
|
||||
showModal,
|
||||
} from '../../../store/actions'
|
||||
import {
|
||||
@ -54,16 +52,6 @@ function mapDispatchToProps (dispatch) {
|
||||
dispatch(hideSidebar())
|
||||
dispatch(toggleAccountMenu())
|
||||
},
|
||||
showConfigPage: () => {
|
||||
dispatch(showConfigPage())
|
||||
dispatch(hideSidebar())
|
||||
dispatch(toggleAccountMenu())
|
||||
},
|
||||
showInfoPage: () => {
|
||||
dispatch(showInfoPage())
|
||||
dispatch(hideSidebar())
|
||||
dispatch(toggleAccountMenu())
|
||||
},
|
||||
showRemoveAccountConfirmationModal: identity => {
|
||||
return dispatch(showModal({ name: 'CONFIRM_REMOVE_ACCOUNT', identity }))
|
||||
},
|
||||
|
@ -6,7 +6,6 @@ import { getNetworkIdentifier } from '../../../selectors/selectors'
|
||||
const mapStateToProps = state => {
|
||||
const {
|
||||
loadingMessage,
|
||||
currentView,
|
||||
} = state.appState
|
||||
const {
|
||||
provider,
|
||||
@ -20,7 +19,7 @@ const mapStateToProps = state => {
|
||||
: [provider.type]
|
||||
|
||||
return {
|
||||
isLoadingNetwork: network === 'loading' && currentView.name !== 'config',
|
||||
isLoadingNetwork: network === 'loading',
|
||||
loadingMessage,
|
||||
lastSelectedProvider,
|
||||
setProviderArgs,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { connect } from 'react-redux'
|
||||
import * as actions from '../../../../store/actions'
|
||||
import { showModal, setAccountLabel } from '../../../../store/actions'
|
||||
import { getSelectedIdentity, getRpcPrefsForCurrentProvider } from '../../../../selectors/selectors'
|
||||
import AccountDetailsModal from './account-details-modal.component'
|
||||
|
||||
@ -14,13 +14,8 @@ const mapStateToProps = (state) => {
|
||||
|
||||
const mapDispatchToProps = (dispatch) => {
|
||||
return {
|
||||
// Is this supposed to be used somewhere?
|
||||
showQrView: (selected, identity) => dispatch(actions.showQrView(selected, identity)),
|
||||
showExportPrivateKeyModal: () => {
|
||||
dispatch(actions.showModal({ name: 'EXPORT_PRIVATE_KEY' }))
|
||||
},
|
||||
hideModal: () => dispatch(actions.hideModal()),
|
||||
setAccountLabel: (address, label) => dispatch(actions.setAccountLabel(address, label)),
|
||||
showExportPrivateKeyModal: () => dispatch(showModal({ name: 'EXPORT_PRIVATE_KEY' })),
|
||||
setAccountLabel: (address, label) => dispatch(setAccountLabel(address, label)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,15 +2,13 @@ import { connect } from 'react-redux'
|
||||
import { withRouter } from 'react-router-dom'
|
||||
import { compose } from 'recompose'
|
||||
import WalletView from './wallet-view.component'
|
||||
import { showSendPage, hideSidebar, setSelectedToken, showAddTokenPage } from '../../../store/actions'
|
||||
import { getMetaMaskAccounts, getSelectedAddress, getSelectedAccount } from '../../../selectors/selectors'
|
||||
import { hideSidebar, setSelectedToken } from '../../../store/actions'
|
||||
import { getSelectedAddress, getSelectedAccount } from '../../../selectors/selectors'
|
||||
|
||||
function mapStateToProps (state) {
|
||||
return {
|
||||
network: state.metamask.network,
|
||||
sidebarOpen: state.appState.sidebar.isOpen,
|
||||
identities: state.metamask.identities,
|
||||
accounts: getMetaMaskAccounts(state),
|
||||
keyrings: state.metamask.keyrings,
|
||||
selectedAddress: getSelectedAddress(state),
|
||||
selectedAccount: getSelectedAccount(state),
|
||||
@ -20,10 +18,8 @@ function mapStateToProps (state) {
|
||||
|
||||
function mapDispatchToProps (dispatch) {
|
||||
return {
|
||||
showSendPage: () => dispatch(showSendPage()),
|
||||
hideSidebar: () => dispatch(hideSidebar()),
|
||||
unsetSelectedToken: () => dispatch(setSelectedToken()),
|
||||
showAddTokenPage: () => dispatch(showAddTokenPage()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,56 +185,6 @@ export default function reduceApp (state, action) {
|
||||
|
||||
return newState
|
||||
|
||||
case actions.SHOW_CONFIG_PAGE:
|
||||
return {
|
||||
...appState,
|
||||
currentView: {
|
||||
name: 'config',
|
||||
context: appState.currentView.context,
|
||||
},
|
||||
transForward: action.value,
|
||||
}
|
||||
|
||||
case actions.SHOW_ADD_TOKEN_PAGE:
|
||||
return {
|
||||
...appState,
|
||||
currentView: {
|
||||
name: 'add-token',
|
||||
context: appState.currentView.context,
|
||||
},
|
||||
transForward: action.value,
|
||||
}
|
||||
|
||||
case actions.SET_NEW_ACCOUNT_FORM:
|
||||
return {
|
||||
...appState,
|
||||
currentView: {
|
||||
name: appState.currentView.name,
|
||||
context: action.formToSelect,
|
||||
},
|
||||
}
|
||||
|
||||
case actions.SHOW_INFO_PAGE:
|
||||
return {
|
||||
...appState,
|
||||
currentView: {
|
||||
name: 'info',
|
||||
context: appState.currentView.context,
|
||||
},
|
||||
transForward: true,
|
||||
}
|
||||
|
||||
case actions.SHOW_SEND_PAGE:
|
||||
return {
|
||||
...appState,
|
||||
currentView: {
|
||||
name: 'sendTransaction',
|
||||
context: appState.currentView.context,
|
||||
},
|
||||
transForward: true,
|
||||
warning: null,
|
||||
}
|
||||
|
||||
case actions.SHOW_SEND_TOKEN_PAGE:
|
||||
return {
|
||||
...appState,
|
||||
|
@ -1,20 +0,0 @@
|
||||
import { connect } from 'react-redux'
|
||||
import * as actions from '../../store/actions'
|
||||
import { getCurrentViewContext } from '../../selectors/selectors'
|
||||
import CreateAccountPage from './create-account.component'
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
displayedForm: getCurrentViewContext(state),
|
||||
})
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
displayForm: form => dispatch(actions.setNewAccountForm(form)),
|
||||
showQrView: (selected, identity) => dispatch(actions.showQrView(selected, identity)),
|
||||
showExportPrivateKeyModal: () => {
|
||||
dispatch(actions.showModal({ name: 'EXPORT_PRIVATE_KEY' }))
|
||||
},
|
||||
hideModal: () => dispatch(actions.hideModal()),
|
||||
setAccountLabel: (address, label) => dispatch(actions.setAccountLabel(address, label)),
|
||||
})
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(CreateAccountPage)
|
@ -1 +1 @@
|
||||
export { default } from './create-account.container'
|
||||
export { default } from './create-account.component'
|
||||
|
@ -205,13 +205,12 @@ class Routes extends Component {
|
||||
network,
|
||||
provider,
|
||||
frequentRpcListDetail,
|
||||
currentView,
|
||||
setMouseUserState,
|
||||
sidebar,
|
||||
submittedPendingTransactions,
|
||||
isMouseUser,
|
||||
} = this.props
|
||||
const isLoadingNetwork = network === 'loading' && currentView.name !== 'config'
|
||||
const isLoadingNetwork = network === 'loading'
|
||||
const loadMessage = loadingMessage || isLoadingNetwork ?
|
||||
this.getConnectingLabel(loadingMessage) : null
|
||||
log.debug('Main ui render function')
|
||||
@ -366,7 +365,6 @@ Routes.propTypes = {
|
||||
provider: PropTypes.object,
|
||||
selectedAddress: PropTypes.string,
|
||||
frequentRpcListDetail: PropTypes.array,
|
||||
currentView: PropTypes.object,
|
||||
sidebar: PropTypes.object,
|
||||
alertOpen: PropTypes.bool,
|
||||
hideSidebar: PropTypes.func,
|
||||
@ -410,7 +408,6 @@ function mapStateToProps (state) {
|
||||
isLoading,
|
||||
loadingMessage,
|
||||
isUnlocked: state.metamask.isUnlocked,
|
||||
currentView: state.appState.currentView,
|
||||
submittedPendingTransactions: submittedPendingTransactionsSelector(state),
|
||||
network: state.metamask.network,
|
||||
provider: state.metamask.provider,
|
||||
|
@ -50,11 +50,6 @@ export function getCurrentNetwork (state) {
|
||||
return state.metamask.network
|
||||
}
|
||||
|
||||
export function getCurrentViewContext (state) {
|
||||
const { currentView = {} } = state.appState
|
||||
return currentView.context
|
||||
}
|
||||
|
||||
export function getForceGasMin (state) {
|
||||
return state.metamask.send.forceGasMin
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ import {
|
||||
getCurrentAccountWithSendEtherInfo,
|
||||
getCurrentCurrency,
|
||||
getCurrentNetwork,
|
||||
getCurrentViewContext,
|
||||
getNativeCurrency,
|
||||
getForceGasMin,
|
||||
getGasLimit,
|
||||
@ -180,15 +179,6 @@ describe('send selectors', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('getCurrentViewContext()', () => {
|
||||
it('should return the context of the current view', () => {
|
||||
assert.equal(
|
||||
getCurrentViewContext(mockState),
|
||||
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('getForceGasMin()', () => {
|
||||
it('should get the send.forceGasMin property', () => {
|
||||
assert.equal(
|
||||
|
@ -302,11 +302,6 @@ export function getSelectedTokenContract (state) {
|
||||
: null
|
||||
}
|
||||
|
||||
export function getCurrentViewContext (state) {
|
||||
const { currentView = {} } = state.appState
|
||||
return currentView.context
|
||||
}
|
||||
|
||||
export function getTotalUnapprovedCount ({ metamask }) {
|
||||
const {
|
||||
unapprovedTxs = {},
|
||||
|
@ -36,8 +36,6 @@ export const actionConstants = {
|
||||
// remote state
|
||||
UPDATE_METAMASK_STATE: 'UPDATE_METAMASK_STATE',
|
||||
FORGOT_PASSWORD: 'FORGOT_PASSWORD',
|
||||
SHOW_INFO_PAGE: 'SHOW_INFO_PAGE',
|
||||
SET_NEW_ACCOUNT_FORM: 'SET_NEW_ACCOUNT_FORM',
|
||||
CLOSE_WELCOME_SCREEN: 'CLOSE_WELCOME_SCREEN',
|
||||
// unlock screen
|
||||
UNLOCK_IN_PROGRESS: 'UNLOCK_IN_PROGRESS',
|
||||
@ -55,7 +53,6 @@ export const actionConstants = {
|
||||
SHOW_CONF_TX_PAGE: 'SHOW_CONF_TX_PAGE',
|
||||
SET_CURRENT_FIAT: 'SET_CURRENT_FIAT',
|
||||
// account detail screen
|
||||
SHOW_SEND_PAGE: 'SHOW_SEND_PAGE',
|
||||
SHOW_SEND_TOKEN_PAGE: 'SHOW_SEND_TOKEN_PAGE',
|
||||
SHOW_PRIVATE_KEY: 'SHOW_PRIVATE_KEY',
|
||||
SET_ACCOUNT_LABEL: 'SET_ACCOUNT_LABEL',
|
||||
@ -82,11 +79,9 @@ export const actionConstants = {
|
||||
UPDATE_SEND_ENS_RESOLUTION: 'UPDATE_SEND_ENS_RESOLUTION',
|
||||
UPDATE_SEND_ENS_RESOLUTION_ERROR: 'UPDATE_SEND_ENS_RESOLUTION_ERROR',
|
||||
// config screen
|
||||
SHOW_CONFIG_PAGE: 'SHOW_CONFIG_PAGE',
|
||||
SET_RPC_TARGET: 'SET_RPC_TARGET',
|
||||
SET_PROVIDER_TYPE: 'SET_PROVIDER_TYPE',
|
||||
SET_PREVIOUS_PROVIDER: 'SET_PREVIOUS_PROVIDER',
|
||||
SHOW_ADD_TOKEN_PAGE: 'SHOW_ADD_TOKEN_PAGE',
|
||||
UPDATE_TOKENS: 'UPDATE_TOKENS',
|
||||
SET_HARDWARE_WALLET_DEFAULT_HD_PATH: 'SET_HARDWARE_WALLET_DEFAULT_HD_PATH',
|
||||
// loading overlay
|
||||
@ -548,12 +543,6 @@ export function unlockHardwareWalletAccount (index, deviceName, hdPath) {
|
||||
}
|
||||
}
|
||||
|
||||
export function showInfoPage () {
|
||||
return {
|
||||
type: actionConstants.SHOW_INFO_PAGE,
|
||||
}
|
||||
}
|
||||
|
||||
export function showQrScanner (ROUTE) {
|
||||
return (dispatch) => {
|
||||
return WebcamUtils.checkStatus()
|
||||
@ -1127,14 +1116,6 @@ export function forgotPassword (forgotPasswordState = true) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function setNewAccountForm (formToSelect) {
|
||||
return {
|
||||
type: actionConstants.SET_NEW_ACCOUNT_FORM,
|
||||
formToSelect,
|
||||
}
|
||||
}
|
||||
|
||||
export function closeWelcomeScreen () {
|
||||
return {
|
||||
type: actionConstants.CLOSE_WELCOME_SCREEN,
|
||||
@ -1272,20 +1253,6 @@ export function showConfTxPage ({ transForward = true, id }) {
|
||||
}
|
||||
}
|
||||
|
||||
export function showConfigPage (transitionForward = true) {
|
||||
return {
|
||||
type: actionConstants.SHOW_CONFIG_PAGE,
|
||||
value: transitionForward,
|
||||
}
|
||||
}
|
||||
|
||||
export function showAddTokenPage (transitionForward = true) {
|
||||
return {
|
||||
type: actionConstants.SHOW_ADD_TOKEN_PAGE,
|
||||
value: transitionForward,
|
||||
}
|
||||
}
|
||||
|
||||
export function addToken (address, symbol, decimals, image) {
|
||||
return (dispatch) => {
|
||||
dispatch(showLoadingIndication())
|
||||
@ -1809,12 +1776,6 @@ export function setAccountLabel (account, label) {
|
||||
}
|
||||
}
|
||||
|
||||
export function showSendPage () {
|
||||
return {
|
||||
type: actionConstants.SHOW_SEND_PAGE,
|
||||
}
|
||||
}
|
||||
|
||||
export function showSendTokenPage () {
|
||||
return {
|
||||
type: actionConstants.SHOW_SEND_TOKEN_PAGE,
|
||||
|
Loading…
Reference in New Issue
Block a user