|
| 1 | +import React, { useContext } from 'react' |
| 2 | +import { useTranslation } from 'react-i18next' |
| 3 | +import { ResponsiveLayer } from '../ResponsiveLayer' |
| 4 | +import { Box, Button, Heading, Paragraph, RadioButtonGroup, ResponsiveContext } from 'grommet' |
| 5 | +import { useDispatch, useSelector } from 'react-redux' |
| 6 | +import { selectDangerousModeSetting } from './slice/selectors' |
| 7 | +import { Threats } from 'grommet-icons' |
| 8 | +import { settingsActions } from './slice' |
| 9 | + |
| 10 | +interface SettingsDialogProps { |
| 11 | + closeHandler: () => void |
| 12 | +} |
| 13 | + |
| 14 | +export const SettingsDialog = (props: SettingsDialogProps) => { |
| 15 | + const { t } = useTranslation() |
| 16 | + const size = useContext(ResponsiveContext) |
| 17 | + |
| 18 | + const dispatch = useDispatch() |
| 19 | + const dangerousMode = useSelector(selectDangerousModeSetting) |
| 20 | + |
| 21 | + return ( |
| 22 | + <ResponsiveLayer |
| 23 | + onClickOutside={props.closeHandler} |
| 24 | + onEsc={props.closeHandler} |
| 25 | + animation="slide" |
| 26 | + background="background-front" |
| 27 | + modal |
| 28 | + > |
| 29 | + <Box pad={{ vertical: 'small' }} margin="medium" width={size === 'small' ? 'auto' : '700px'}> |
| 30 | + <Heading size="1" margin={{ vertical: 'small' }}> |
| 31 | + {t('settings.dialog.title', 'Wallet settings')} |
| 32 | + </Heading> |
| 33 | + <Paragraph fill> |
| 34 | + {t( |
| 35 | + 'settings.dialog.description', |
| 36 | + 'This is where you can configure the behavior of the Oasis Wallet.', |
| 37 | + )} |
| 38 | + </Paragraph> |
| 39 | + <Box |
| 40 | + gap="small" |
| 41 | + pad={{ vertical: 'medium', right: 'small' }} |
| 42 | + overflow={{ vertical: 'auto' }} |
| 43 | + height={{ max: '400px' }} |
| 44 | + > |
| 45 | + <Paragraph fill> |
| 46 | + <b>{t('dangerMode.title', 'Dangerous mode')}:</b>{' '} |
| 47 | + {t('dangerMode.description', 'should the wallet let the user shoot himself in the foot?')} |
| 48 | + </Paragraph> |
| 49 | + <RadioButtonGroup |
| 50 | + name="doc" |
| 51 | + options={[ |
| 52 | + { |
| 53 | + value: false, |
| 54 | + label: t('dangerMode.off', 'Off - Refuse to execute nonsensical actions'), |
| 55 | + }, |
| 56 | + { |
| 57 | + value: true, |
| 58 | + label: ( |
| 59 | + <span> |
| 60 | + {t('dangerMode.on', "On - Allow executing nonsensical actions. Don't blame Oasis!")}{' '} |
| 61 | + <Threats size={'large'} /> |
| 62 | + </span> |
| 63 | + ), |
| 64 | + }, |
| 65 | + ]} |
| 66 | + value={dangerousMode} |
| 67 | + onChange={event => dispatch(settingsActions.setDangerousMode(event.target.value === 'true'))} |
| 68 | + /> |
| 69 | + </Box> |
| 70 | + <Box align="end" pad={{ top: 'medium' }}> |
| 71 | + <Button primary label={t('settings.dialog.close', 'Close')} onClick={props.closeHandler} /> |
| 72 | + </Box> |
| 73 | + </Box> |
| 74 | + </ResponsiveLayer> |
| 75 | + ) |
| 76 | +} |
0 commit comments