mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 20:39:08 +01:00
Added reject transactions modal to be present in the footer of the approve screen (#16832)
* Added reject transactions modal in the footer * Use Button component for multiple unapproved tx
This commit is contained in:
parent
9dbc8b8ec0
commit
219e3129dc
@ -30,10 +30,14 @@ import {
|
|||||||
getKnownMethodData,
|
getKnownMethodData,
|
||||||
getRpcPrefsForCurrentProvider,
|
getRpcPrefsForCurrentProvider,
|
||||||
getCustomTokenAmount,
|
getCustomTokenAmount,
|
||||||
|
getUnapprovedTxCount,
|
||||||
|
getUnapprovedTransactions,
|
||||||
} from '../../selectors';
|
} from '../../selectors';
|
||||||
import { NETWORK_TO_NAME_MAP } from '../../../shared/constants/network';
|
import { NETWORK_TO_NAME_MAP } from '../../../shared/constants/network';
|
||||||
import {
|
import {
|
||||||
cancelTx,
|
cancelTx,
|
||||||
|
cancelTxs,
|
||||||
|
showModal,
|
||||||
updateAndApproveTx,
|
updateAndApproveTx,
|
||||||
updateCustomNonce,
|
updateCustomNonce,
|
||||||
} from '../../store/actions';
|
} from '../../store/actions';
|
||||||
@ -45,6 +49,7 @@ import Dialog from '../../components/ui/dialog';
|
|||||||
import { useGasFeeContext } from '../../contexts/gasFee';
|
import { useGasFeeContext } from '../../contexts/gasFee';
|
||||||
import { getCustomTxParamsData } from '../confirm-approve/confirm-approve.util';
|
import { getCustomTxParamsData } from '../confirm-approve/confirm-approve.util';
|
||||||
import { setCustomTokenAmount } from '../../ducks/app/app';
|
import { setCustomTokenAmount } from '../../ducks/app/app';
|
||||||
|
import { valuesFor } from '../../helpers/utils/util';
|
||||||
|
|
||||||
export default function TokenAllowance({
|
export default function TokenAllowance({
|
||||||
origin,
|
origin,
|
||||||
@ -86,6 +91,8 @@ export default function TokenAllowance({
|
|||||||
const networkIdentifier = useSelector(getNetworkIdentifier);
|
const networkIdentifier = useSelector(getNetworkIdentifier);
|
||||||
const rpcPrefs = useSelector(getRpcPrefsForCurrentProvider);
|
const rpcPrefs = useSelector(getRpcPrefsForCurrentProvider);
|
||||||
const customTokenAmount = useSelector(getCustomTokenAmount);
|
const customTokenAmount = useSelector(getCustomTokenAmount);
|
||||||
|
const unapprovedTxCount = useSelector(getUnapprovedTxCount);
|
||||||
|
const unapprovedTxs = useSelector(getUnapprovedTransactions);
|
||||||
|
|
||||||
const customPermissionAmount = customTokenAmount.toString();
|
const customPermissionAmount = customTokenAmount.toString();
|
||||||
|
|
||||||
@ -185,6 +192,20 @@ export default function TokenAllowance({
|
|||||||
setIsFirstPage(true);
|
setIsFirstPage(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCancelAll = () => {
|
||||||
|
dispatch(
|
||||||
|
showModal({
|
||||||
|
name: 'REJECT_TRANSACTIONS',
|
||||||
|
unapprovedTxCount,
|
||||||
|
onSubmit: async () => {
|
||||||
|
await dispatch(cancelTxs(valuesFor(unapprovedTxs)));
|
||||||
|
dispatch(clearConfirmTransaction());
|
||||||
|
history.push(mostRecentOverviewPage);
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const isEmpty = customTokenAmount === '';
|
const isEmpty = customTokenAmount === '';
|
||||||
|
|
||||||
const renderContractTokenValues = (
|
const renderContractTokenValues = (
|
||||||
@ -413,7 +434,19 @@ export default function TokenAllowance({
|
|||||||
onCancel={() => handleReject()}
|
onCancel={() => handleReject()}
|
||||||
onSubmit={() => (isFirstPage ? handleNextClick() : handleApprove())}
|
onSubmit={() => (isFirstPage ? handleNextClick() : handleApprove())}
|
||||||
disabled={disableNextButton || disableApproveButton}
|
disabled={disableNextButton || disableApproveButton}
|
||||||
/>
|
>
|
||||||
|
{unapprovedTxCount > 1 && (
|
||||||
|
<Button
|
||||||
|
type="link"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
handleCancelAll();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t('rejectTxsN', [unapprovedTxCount])}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</PageContainerFooter>
|
||||||
{showContractDetails && (
|
{showContractDetails && (
|
||||||
<ContractDetailsModal
|
<ContractDetailsModal
|
||||||
tokenName={tokenSymbol}
|
tokenName={tokenSymbol}
|
||||||
|
@ -533,7 +533,7 @@ export function getTotalUnapprovedMessagesCount(state) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUnapprovedTxCount(state) {
|
export function getUnapprovedTxCount(state) {
|
||||||
const { unapprovedTxs = {} } = state.metamask;
|
const { unapprovedTxs = {} } = state.metamask;
|
||||||
return Object.keys(unapprovedTxs).length;
|
return Object.keys(unapprovedTxs).length;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user