-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1752 from oasisprotocol/mz/accRemove
Remove Account
- Loading branch information
Showing
12 changed files
with
251 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add remove account feature |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { ReactNode } from 'react' | ||
import { Box } from 'grommet/es6/components/Box' | ||
import { Button } from 'grommet/es6/components/Button' | ||
import { useTranslation } from 'react-i18next' | ||
import { TextInput } from 'grommet/es6/components/TextInput' | ||
import { Form } from 'grommet/es6/components/Form' | ||
import { FormField } from 'grommet/es6/components/FormField' | ||
|
||
interface DeleteInputFormProps { | ||
children: ReactNode | ||
onCancel: () => void | ||
onConfirm: () => void | ||
} | ||
|
||
export function DeleteInputForm({ children, onCancel, onConfirm }: DeleteInputFormProps) { | ||
const { t } = useTranslation() | ||
|
||
return ( | ||
<Form onSubmit={onConfirm}> | ||
{children} | ||
<FormField | ||
name="type_delete" | ||
validate={(value: string | undefined) => | ||
!value || value.toLowerCase() !== t('deleteForm.confirmationKeyword', 'delete').toLowerCase() | ||
? t('deleteForm.hint', `Type '{{confirmationKeyword}}'`, { | ||
confirmationKeyword: t('deleteForm.confirmationKeyword', 'delete'), | ||
}) | ||
: undefined | ||
} | ||
> | ||
<TextInput id="type_delete" name="type_delete" /> | ||
</FormField> | ||
|
||
<Box direction="row" justify="between" pad={{ top: 'large' }}> | ||
<Button secondary label={t('common.cancel', 'Cancel')} onClick={onCancel} /> | ||
<Button type="submit" label={t('deleteForm.confirm', 'Yes, delete')} primary color="status-error" /> | ||
</Box> | ||
</Form> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
src/app/components/Toolbar/Features/Account/DeleteAccount.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { useContext } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import { Box } from 'grommet/es6/components/Box' | ||
import { Paragraph } from 'grommet/es6/components/Paragraph' | ||
import { ResponsiveContext } from 'grommet/es6/contexts/ResponsiveContext' | ||
import { Text } from 'grommet/es6/components/Text' | ||
import { ResponsiveLayer } from '../../../ResponsiveLayer' | ||
import { DeleteInputForm } from '../../../../components/DeleteInputForm' | ||
import { Account } from '../Account/Account' | ||
import { Wallet } from '../../../../state/wallet/types' | ||
|
||
interface DeleteAccountProps { | ||
onDelete: () => void | ||
onCancel: () => void | ||
wallet: Wallet | ||
} | ||
|
||
export const DeleteAccount = ({ onCancel, onDelete, wallet }: DeleteAccountProps) => { | ||
const { t } = useTranslation() | ||
const isMobile = useContext(ResponsiveContext) === 'small' | ||
|
||
return ( | ||
<ResponsiveLayer | ||
onClickOutside={onCancel} | ||
onEsc={onCancel} | ||
animation="none" | ||
background="background-front" | ||
modal | ||
margin={isMobile ? 'none' : 'xlarge'} | ||
> | ||
<Box margin="medium"> | ||
<Box flex="grow" justify="center"> | ||
<Text weight="bold" size="medium" textAlign="center" margin={{ bottom: 'large' }}> | ||
{t('toolbar.settings.delete.title', 'Delete Account')} | ||
</Text> | ||
<Text size="medium" textAlign="center" margin={{ bottom: 'medium' }}> | ||
{t( | ||
'toolbar.settings.delete.description', | ||
'Are you sure you want to delete the following account?', | ||
)} | ||
</Text> | ||
<Account address={wallet.address} balance={undefined} displayBalance={false} isActive /> | ||
|
||
<DeleteInputForm onCancel={onCancel} onConfirm={onDelete}> | ||
<label htmlFor="type_delete"> | ||
<Paragraph fill textAlign="center"> | ||
{t( | ||
'toolbar.settings.delete.inputHelp', | ||
`This action cannot be undone. To continue please enter '{{confirmationKeyword}}' below.`, | ||
{ | ||
confirmationKeyword: t('deleteForm.confirmationKeyword', 'delete'), | ||
}, | ||
)} | ||
</Paragraph> | ||
</label> | ||
</DeleteInputForm> | ||
</Box> | ||
</Box> | ||
</ResponsiveLayer> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.