mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-30 16:18:07 +01:00
fadad601b8
* ConfirmImportToken: convert to FC * ConfirmImportToken: reorganize * ConfirmImportToken: rm component from path * replace mapStateToProps w/ useSelector ConfirmImportToken * replace mapDispatchToProps w/ useDispatch ConfirmImportToken * ConfirmAddSuggestedToken: useHistory * ConfirmImportToken: add storybook controls * ConfirmImportToken: rm 1st entry overwrite * ConfirmImportToken: add tests * ConfirmImportToken: use real Redux store in tests * ConfirmImportToken: do not use mock-state.json https://github.com/MetaMask/metamask-extension/pull/13594#discussion_r805022647 * ConfirmImportToken: tokenAddedEvent -> trackTokenAddedEvent * Update ui/pages/confirm-import-token/confirm-import-token.js Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com> * ConfirmImportToken: update useSelector logic * ConfirmImportToken: replace typeof check w/ === undefined * ConfirmImportToken: rm unnecessary /rendering from path * ConfirmImportToken: fix add token redirect * ConfirmImportToken: use useNewMetricEvent * ConfirmImportToken: rename vars using "addedToken" * ConfirmImportToken: setAddedToken to obj copy Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
48 lines
1.0 KiB
JavaScript
48 lines
1.0 KiB
JavaScript
/* eslint-disable react/prop-types */
|
|
import React, { useEffect } from 'react';
|
|
|
|
import { store, getNewState } from '../../../.storybook/preview';
|
|
import { tokens } from '../../../.storybook/initial-states/approval-screens/add-token';
|
|
import { updateMetamaskState } from '../../store/actions';
|
|
import ConfirmAddToken from '.';
|
|
|
|
export default {
|
|
title: 'Pages/ConfirmImportToken',
|
|
id: __filename,
|
|
|
|
argTypes: {
|
|
pendingTokens: {
|
|
control: 'object',
|
|
table: { category: 'Data' },
|
|
},
|
|
},
|
|
};
|
|
|
|
const PageSet = ({ children, pendingTokens }) => {
|
|
const { metamask: state } = store.getState();
|
|
|
|
useEffect(() => {
|
|
store.dispatch(
|
|
updateMetamaskState(
|
|
getNewState(state, {
|
|
pendingTokens,
|
|
}),
|
|
),
|
|
);
|
|
}, [state, pendingTokens]);
|
|
|
|
return children;
|
|
};
|
|
|
|
export const DefaultStory = ({ pendingTokens }) => {
|
|
return (
|
|
<PageSet pendingTokens={pendingTokens}>
|
|
<ConfirmAddToken />
|
|
</PageSet>
|
|
);
|
|
};
|
|
DefaultStory.args = {
|
|
pendingTokens: { ...tokens },
|
|
};
|
|
DefaultStory.storyName = 'Default';
|