-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
359 additions
and
74 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
src/components/settings/Recovery/ConfirmRemoveRecoveryModal.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,74 @@ | ||
import { | ||
Button, | ||
Dialog, | ||
DialogActions, | ||
DialogContent, | ||
DialogContentText, | ||
DialogTitle, | ||
IconButton, | ||
SvgIcon, | ||
} from '@mui/material' | ||
import CloseIcon from '@mui/icons-material/Close' | ||
import { useContext } from 'react' | ||
import type { ReactElement } from 'react' | ||
|
||
import AlertIcon from '@/public/images/notifications/alert.svg' | ||
import { TxModalContext } from '@/components/tx-flow' | ||
import { RemoveRecoveryFlow } from '@/components/tx-flow/flows/RemoveRecovery' | ||
import type { RecoveryState } from '@/store/recoverySlice' | ||
|
||
export function ConfirmRemoveRecoveryModal({ | ||
open, | ||
onClose, | ||
delayModifier, | ||
}: { | ||
open: boolean | ||
onClose: () => void | ||
delayModifier: RecoveryState[number] | ||
}): ReactElement { | ||
const { setTxFlow } = useContext(TxModalContext) | ||
|
||
const onConfirm = () => { | ||
setTxFlow(<RemoveRecoveryFlow delayModifier={delayModifier} />) | ||
onClose() | ||
} | ||
|
||
return ( | ||
<Dialog open={open} onClose={onClose}> | ||
<DialogTitle display="flex" alignItems="center" sx={{ pt: 3 }}> | ||
<SvgIcon | ||
component={AlertIcon} | ||
inheritViewBox | ||
sx={{ | ||
color: (theme) => theme.palette.error.main, | ||
mr: '10px', | ||
}} | ||
/> | ||
Remove the recovery module? | ||
<IconButton | ||
onClick={onClose} | ||
sx={{ | ||
color: (theme) => theme.palette.text.secondary, | ||
ml: 'auto', | ||
}} | ||
> | ||
<CloseIcon /> | ||
</IconButton> | ||
</DialogTitle> | ||
|
||
<DialogContent dividers sx={{ py: 2, px: 3 }}> | ||
<DialogContentText color="text.primary"> | ||
Are you sure you wish to remove the recovery module? The assigned guardian won't be able to recover this | ||
Safe account for you. | ||
</DialogContentText> | ||
</DialogContent> | ||
|
||
<DialogActions sx={{ display: 'flex', justifyContent: 'space-between', p: 3, pb: 2 }}> | ||
<Button onClick={onClose}>Cancel</Button> | ||
<Button onClick={onConfirm} autoFocus variant="danger"> | ||
Remove | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
) | ||
} |
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,62 @@ | ||
import { IconButton, SvgIcon, Tooltip } from '@mui/material' | ||
import { useContext, useState } from 'react' | ||
import type { ReactElement } from 'react' | ||
|
||
import { TxModalContext } from '@/components/tx-flow' | ||
import useIsSafeOwner from '@/hooks/useIsSafeOwner' | ||
import DeleteIcon from '@/public/images/common/delete.svg' | ||
import EditIcon from '@/public/images/common/edit.svg' | ||
import CheckWallet from '@/components/common/CheckWallet' | ||
import { ConfirmRemoveRecoveryModal } from './ConfirmRemoveRecoveryModal' | ||
import type { RecoveryState } from '@/store/recoverySlice' | ||
|
||
export function DelayModifierRow({ delayModifier }: { delayModifier: RecoveryState[number] }): ReactElement | null { | ||
const { setTxFlow } = useContext(TxModalContext) | ||
const isOwner = useIsSafeOwner() | ||
const [confirm, setConfirm] = useState(false) | ||
|
||
if (!isOwner) { | ||
return null | ||
} | ||
|
||
const onEdit = () => { | ||
// TODO: Display flow | ||
setTxFlow(undefined) | ||
} | ||
|
||
const onDelete = () => { | ||
setConfirm(true) | ||
} | ||
|
||
const onCloseConfirm = () => { | ||
setConfirm(false) | ||
} | ||
|
||
return ( | ||
<> | ||
<CheckWallet> | ||
{(isOk) => ( | ||
<> | ||
<Tooltip title={isOk ? 'Edit recovery setup' : undefined}> | ||
<span> | ||
<IconButton onClick={onEdit} size="small" disabled={!isOk}> | ||
<SvgIcon component={EditIcon} inheritViewBox color="border" fontSize="small" /> | ||
</IconButton> | ||
</span> | ||
</Tooltip> | ||
|
||
<Tooltip title={isOk ? 'Disable recovery' : undefined}> | ||
<span> | ||
<IconButton onClick={onDelete} size="small" disabled={!isOk}> | ||
<SvgIcon component={DeleteIcon} inheritViewBox color="error" fontSize="small" /> | ||
</IconButton> | ||
</span> | ||
</Tooltip> | ||
</> | ||
)} | ||
</CheckWallet> | ||
|
||
<ConfirmRemoveRecoveryModal open={confirm} onClose={onCloseConfirm} delayModifier={delayModifier} /> | ||
</> | ||
) | ||
} |
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
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
File renamed without changes.
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.