1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 01:39:44 +01:00

Fix unlock-page component for new Storybook format (#12894)

* unlock-page

* Updating comments and removing broken args table

Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
This commit is contained in:
Etienne Dusseault 2021-12-07 07:08:13 +08:00 committed by GitHub
parent bab48c809a
commit 9fcfbe7609
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 72 additions and 12 deletions

View File

@ -0,0 +1,27 @@
import { Story, Canvas, ArgsTable } from '@storybook/addon-docs';
import UnlockPage from '.';
# Unlock Page
Portal page for user to auth the access of their account
<Canvas>
<Story id="ui-pages-unlock-page-unlock-page-stories-js--default-story" />
</Canvas>
## Component API
<!--
ArgsTable doesn't work with SectionShape
<ArgsTable of={MetaMaskTranslation} />
-->
| Name | Description |
| -------------------------- | -------------------------------------------------------------------------- |
| `history` | History router for redirect after action `object` |
| `isUnlocked` | If isUnlocked is true will redirect to most recent route in history `bool` |
| `onRestore` | onClick handler for "import using Secret Recovery Phrase" link `func` |
| `onSubmit` | onSumbit handler when form is submitted `func` |
| `forceUpdateMetamaskState` | Force update metamask data state `func` |
| `showOptInModal` | Event handler to show metametrics modal `func` |

View File

@ -14,11 +14,29 @@ export default class UnlockPage extends Component {
}; };
static propTypes = { static propTypes = {
/**
* History router for redirect after action
*/
history: PropTypes.object.isRequired, history: PropTypes.object.isRequired,
/**
* If isUnlocked is true will redirect to most recent route in history
*/
isUnlocked: PropTypes.bool, isUnlocked: PropTypes.bool,
/**
* onClick handler for "import using Secret Recovery Phrase" link
*/
onRestore: PropTypes.func, onRestore: PropTypes.func,
/**
* onSumbit handler when form is submitted
*/
onSubmit: PropTypes.func, onSubmit: PropTypes.func,
/**
* Force update metamask data state
*/
forceUpdateMetamaskState: PropTypes.func, forceUpdateMetamaskState: PropTypes.func,
/**
* Event handler to show metametrics modal
*/
showOptInModal: PropTypes.func, showOptInModal: PropTypes.func,
}; };

View File

@ -1,23 +1,38 @@
import { createBrowserHistory } from 'history';
import React from 'react'; import React from 'react';
import { action } from '@storybook/addon-actions'; import README from './README.mdx';
import UnlockPage from './unlock-page.component'; import UnlockPage from './unlock-page.component';
export default { export default {
title: 'Pages/UnlockPage', title: 'Pages/UnlockPage',
id: __filename, id: __filename,
component: UnlockPage,
parameters: {
docs: {
page: README,
},
},
argTypes: {
history: { control: 'object' },
isUnlocked: { control: 'boolean' },
onRestore: { action: 'onRestore' },
onSubmit: { action: 'onSubmit' },
forceUpdateMetamaskState: { action: 'forceUpdateMetamaskState' },
showOptInModal: { action: 'showOptInModal' },
},
}; };
export const DefaultStory = () => { export const DefaultStory = (args) => {
return ( const history = createBrowserHistory();
<UnlockPage return <UnlockPage {...args} history={history} />;
onSubmit={action('Login')} };
forceUpdateMetamaskState={() => ({
participateInMetaMetrics: true, DefaultStory.storyName = 'Default';
})}
showOptInModal={() => null} DefaultStory.args = {
history={{}} forceUpdateMetamaskState: () => ({
/> participateInMetaMetrics: true,
); }),
}; };
DefaultStory.storyName = 'Default'; DefaultStory.storyName = 'Default';