in frontend/src/old-pages/Configure/Components.tsx [535:614]
function RootVolume({basePath, errorsPath}: any) {
const {t} = useTranslation()
const rootVolumeSizePath = [...basePath, 'LocalStorage', 'RootVolume', 'Size']
const rootVolumeSize = useState(rootVolumeSizePath)
const rootVolumeEncryptedPath = [
...basePath,
'LocalStorage',
'RootVolume',
'Encrypted',
]
const rootVolumeEncrypted = useState(rootVolumeEncryptedPath)
const rootVolumeTypePath = useMemo(
() => [...basePath, 'LocalStorage', 'RootVolume', 'VolumeType'],
[basePath],
)
const rootVolumeType = useState(rootVolumeTypePath)
const defaultRootVolumeType = 'gp3'
const volumeTypes = ['gp3', 'gp2', 'io1', 'io2', 'sc1', 'st1', 'standard']
const rootVolumeErrors = useState([...errorsPath, 'rootVolume'])
const editing = useState(['app', 'wizard', 'editing'])
const setRootVolume = (size: any) => {
if (size === '') clearState(rootVolumeSizePath)
else setState(rootVolumeSizePath, parseInt(size))
clearEmptyNest(rootVolumeSizePath, 3)
}
const toggleEncrypted = () => {
const setEncrypted = !rootVolumeEncrypted
if (setEncrypted) setState(rootVolumeEncryptedPath, setEncrypted)
else clearState(rootVolumeEncryptedPath)
clearEmptyNest(rootVolumeSizePath, 3)
}
React.useEffect(() => {
if (rootVolumeType === null)
setState(rootVolumeTypePath, defaultRootVolumeType)
}, [rootVolumeType, rootVolumeTypePath])
return (
<SpaceBetween direction="vertical" size="s">
<FormField
label={t('wizard.components.rootVolume.size.label')}
errorText={rootVolumeErrors}
>
<Input
disabled={editing}
placeholder={t('wizard.components.rootVolume.size.placeholder')}
value={rootVolumeSize || ''}
inputMode="decimal"
type="number"
onChange={({detail}) => setRootVolume(detail.value)}
/>
</FormField>
<FormField label={t('wizard.components.rootVolume.type.label')}>
<Select
disabled={editing}
placeholder={t('wizard.components.rootVolume.type.placeholder', {
defaultRootVolumeType: defaultRootVolumeType,
})}
selectedOption={rootVolumeType && strToOption(rootVolumeType)}
onChange={({detail}) => {
setState(rootVolumeTypePath, detail.selectedOption.value)
}}
options={volumeTypes.map(strToOption)}
/>
</FormField>
<Checkbox
disabled={editing}
checked={rootVolumeEncrypted || false}
onChange={toggleEncrypted}
>
{t('wizard.components.rootVolume.encrypted')}
</Checkbox>
</SpaceBetween>
)
}