-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
upcoming: [M3-8020] β Add "Disk Encryption" section to Linode Rebuild modal #10549
Changes from 5 commits
217633c
01f4dbd
bd6b8f4
3b5d978
bb92b76
afdf95b
ebb524a
dee52d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Upcoming Features | ||
--- | ||
|
||
Add Disk Encryption section to Linode Rebuild modal ([#10549](https://github.com/linode/manager/pull/10549)) |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Diff generated by linter |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2,17 +2,21 @@ import { styled, useTheme } from '@mui/material/styles'; | |||||
import * as React from 'react'; | ||||||
|
||||||
import { Dialog } from 'src/components/Dialog/Dialog'; | ||||||
import EnhancedSelect, { Item } from 'src/components/EnhancedSelect/Select'; | ||||||
import EnhancedSelect from 'src/components/EnhancedSelect/Select'; | ||||||
import { Notice } from 'src/components/Notice/Notice'; | ||||||
import { getIsDistributedRegion } from 'src/components/RegionSelect/RegionSelect.utils'; | ||||||
import { Typography } from 'src/components/Typography'; | ||||||
import { useLinodeQuery } from 'src/queries/linodes/linodes'; | ||||||
import { useGrants, useProfile } from 'src/queries/profile/profile'; | ||||||
import { useRegionsQuery } from 'src/queries/regions/regions'; | ||||||
|
||||||
import { HostMaintenanceError } from '../HostMaintenanceError'; | ||||||
import { LinodePermissionsError } from '../LinodePermissionsError'; | ||||||
import { RebuildFromImage } from './RebuildFromImage'; | ||||||
import { RebuildFromStackScript } from './RebuildFromStackScript'; | ||||||
|
||||||
import type { Item } from 'src/components/EnhancedSelect/Select'; | ||||||
|
||||||
interface Props { | ||||||
linodeId: number | undefined; | ||||||
onClose: () => void; | ||||||
|
@@ -42,6 +46,8 @@ export const LinodeRebuildDialog = (props: Props) => { | |||||
linodeId !== undefined && open | ||||||
); | ||||||
|
||||||
const { data: regionsData } = useRegionsQuery(); | ||||||
|
||||||
const isReadOnly = | ||||||
Boolean(profile?.restricted) && | ||||||
grants?.linode.find((grant) => grant.id === linodeId)?.permissions === | ||||||
|
@@ -51,11 +57,24 @@ export const LinodeRebuildDialog = (props: Props) => { | |||||
const unauthorized = isReadOnly; | ||||||
const disabled = hostMaintenance || unauthorized; | ||||||
|
||||||
// LDE-related checks | ||||||
const isEncrypted = linode?.disk_encryption === 'enabled' ? true : false; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for bringing this to my attention, upon second look we should be fine with just the equality check |
||||||
const isLKELinode = Boolean(linode?.lke_cluster_id); | ||||||
const linodeIsInDistributedRegion = getIsDistributedRegion( | ||||||
regionsData ?? [], | ||||||
linode?.region ?? '' | ||||||
); | ||||||
|
||||||
const theme = useTheme(); | ||||||
|
||||||
const [mode, setMode] = React.useState<MODES>('fromImage'); | ||||||
const [rebuildError, setRebuildError] = React.useState<string>(''); | ||||||
|
||||||
const [ | ||||||
diskEncryptionEnabled, | ||||||
setDiskEncryptionEnabled, | ||||||
] = React.useState<boolean>(isEncrypted); | ||||||
|
||||||
const onExitDrawer = () => { | ||||||
setRebuildError(''); | ||||||
setMode('fromImage'); | ||||||
|
@@ -65,6 +84,10 @@ export const LinodeRebuildDialog = (props: Props) => { | |||||
setRebuildError(status); | ||||||
}; | ||||||
|
||||||
const toggleDiskEncryptionEnabled = () => { | ||||||
setDiskEncryptionEnabled(!diskEncryptionEnabled); | ||||||
}; | ||||||
|
||||||
return ( | ||||||
<Dialog | ||||||
TransitionProps={{ onExited: onExitDrawer }} | ||||||
|
@@ -108,33 +131,47 @@ export const LinodeRebuildDialog = (props: Props) => { | |||||
{mode === 'fromImage' && ( | ||||||
<RebuildFromImage | ||||||
disabled={disabled} | ||||||
diskEncryptionEnabled={diskEncryptionEnabled} | ||||||
handleRebuildError={handleRebuildError} | ||||||
isLKELinode={isLKELinode} | ||||||
linodeId={linodeId ?? -1} | ||||||
linodeIsInDistributedRegion={linodeIsInDistributedRegion} | ||||||
linodeLabel={linode?.label} | ||||||
linodeRegion={linode?.region} | ||||||
onClose={onClose} | ||||||
passwordHelperText={passwordHelperText} | ||||||
toggleDiskEncryptionEnabled={toggleDiskEncryptionEnabled} | ||||||
/> | ||||||
)} | ||||||
{mode === 'fromCommunityStackScript' && ( | ||||||
<RebuildFromStackScript | ||||||
disabled={disabled} | ||||||
diskEncryptionEnabled={diskEncryptionEnabled} | ||||||
handleRebuildError={handleRebuildError} | ||||||
isLKELinode={isLKELinode} | ||||||
linodeId={linodeId ?? -1} | ||||||
linodeIsInDistributedRegion={linodeIsInDistributedRegion} | ||||||
linodeLabel={linode?.label} | ||||||
linodeRegion={linode?.region} | ||||||
onClose={onClose} | ||||||
passwordHelperText={passwordHelperText} | ||||||
toggleDiskEncryptionEnabled={toggleDiskEncryptionEnabled} | ||||||
type="community" | ||||||
/> | ||||||
)} | ||||||
{mode === 'fromAccountStackScript' && ( | ||||||
<RebuildFromStackScript | ||||||
disabled={disabled} | ||||||
diskEncryptionEnabled={diskEncryptionEnabled} | ||||||
handleRebuildError={handleRebuildError} | ||||||
isLKELinode={isLKELinode} | ||||||
linodeId={linodeId ?? -1} | ||||||
linodeIsInDistributedRegion={linodeIsInDistributedRegion} | ||||||
linodeLabel={linode?.label} | ||||||
linodeRegion={linode?.region} | ||||||
onClose={onClose} | ||||||
passwordHelperText={passwordHelperText} | ||||||
toggleDiskEncryptionEnabled={toggleDiskEncryptionEnabled} | ||||||
type="account" | ||||||
/> | ||||||
)} | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I preferred this over the initial commit's nested ternaries
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
much nicer indeed :D - switch statement is also a good option for readability