-
Notifications
You must be signed in to change notification settings - Fork 367
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
fix: [M3-7605] - Wrong status indicator when provisioning a LKE #10320
Changes from all commits
dfaf0b0
f17fad2
576d807
5806994
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": Fixed | ||
--- | ||
|
||
Wrong status indicator when provisioning a LKE ([#10320](https://github.com/linode/manager/pull/10320)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
import { APIError } from '@linode/api-v4/lib/types'; | ||
import Grid from '@mui/material/Unstable_Grid2'; | ||
import * as React from 'react'; | ||
import { Link } from 'react-router-dom'; | ||
|
||
import { CopyTooltip } from 'src/components/CopyTooltip/CopyTooltip'; | ||
import { StatusIcon } from 'src/components/StatusIcon/StatusIcon'; | ||
import { TableCell } from 'src/components/TableCell'; | ||
import { Typography } from 'src/components/Typography'; | ||
import { transitionText } from 'src/features/Linodes/transitions'; | ||
import { useInProgressEvents } from 'src/queries/events/events'; | ||
|
||
import NodeActionMenu from './NodeActionMenu'; | ||
import { StyledCopyTooltip, StyledTableRow } from './NodeTable.styles'; | ||
|
||
export interface NodeRow { | ||
instanceId?: number; | ||
instanceStatus?: string; | ||
ip?: string; | ||
label?: string; | ||
nodeId: string; | ||
nodeStatus: string; | ||
} | ||
|
||
interface NodeRowProps extends NodeRow { | ||
linodeError?: APIError[]; | ||
openRecycleNodeDialog: (nodeID: string, linodeLabel: string) => void; | ||
typeLabel: string; | ||
} | ||
|
||
export const NodeRow = React.memo((props: NodeRowProps) => { | ||
const { | ||
instanceId, | ||
instanceStatus, | ||
ip, | ||
label, | ||
linodeError, | ||
nodeId, | ||
nodeStatus, | ||
openRecycleNodeDialog, | ||
typeLabel, | ||
} = props; | ||
|
||
const { data: events } = useInProgressEvents(); | ||
|
||
const recentEvent = events?.find( | ||
(event) => | ||
event.entity?.id === instanceId && event.entity?.type === 'linode' | ||
); | ||
|
||
const linodeLink = instanceId ? `/linodes/${instanceId}` : undefined; | ||
|
||
const nodeReadyAndInstanceRunning = | ||
nodeStatus === 'ready' && instanceStatus === 'running'; | ||
|
||
const iconStatus = | ||
nodeStatus === 'not_ready' | ||
? 'other' | ||
Comment on lines
+57
to
+58
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. This was the actual fix |
||
: nodeReadyAndInstanceRunning | ||
? 'active' | ||
: 'inactive'; | ||
Comment on lines
+53
to
+61
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. Can we simplify the determination of
|
||
|
||
const displayLabel = label ?? typeLabel; | ||
|
||
const displayStatus = | ||
nodeStatus === 'not_ready' | ||
? 'Provisioning' | ||
: transitionText(instanceStatus ?? '', instanceId ?? -1, recentEvent); | ||
|
||
const displayIP = ip ?? ''; | ||
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. Do we need direct usage of ip instead of |
||
|
||
return ( | ||
<StyledTableRow ariaLabel={label} data-qa-node-row={nodeId}> | ||
<TableCell> | ||
<Grid alignItems="center" container wrap="nowrap"> | ||
<Grid> | ||
<Typography> | ||
{linodeLink ? ( | ||
<Link to={linodeLink}>{displayLabel}</Link> | ||
) : ( | ||
displayLabel | ||
)} | ||
</Typography> | ||
</Grid> | ||
</Grid> | ||
</TableCell> | ||
<TableCell statusCell={!linodeError}> | ||
{linodeError ? ( | ||
<Typography | ||
sx={(theme) => ({ | ||
color: theme.color.red, | ||
})} | ||
> | ||
Error retrieving status | ||
</Typography> | ||
) : ( | ||
<> | ||
<StatusIcon status={iconStatus} /> | ||
{displayStatus} | ||
</> | ||
)} | ||
</TableCell> | ||
<TableCell> | ||
{linodeError ? ( | ||
<Typography | ||
sx={(theme) => ({ | ||
color: theme.color.red, | ||
})} | ||
> | ||
Error retrieving IP | ||
</Typography> | ||
) : displayIP.length > 0 ? ( | ||
<> | ||
<CopyTooltip copyableText text={displayIP} /> | ||
<StyledCopyTooltip text={displayIP} /> | ||
</> | ||
) : null} | ||
</TableCell> | ||
<TableCell> | ||
<NodeActionMenu | ||
instanceLabel={label} | ||
nodeId={nodeId} | ||
openRecycleNodeDialog={openRecycleNodeDialog} | ||
/> | ||
</TableCell> | ||
</StyledTableRow> | ||
); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { styled } from '@mui/material/styles'; | ||
|
||
import { CopyTooltip } from 'src/components/CopyTooltip/CopyTooltip'; | ||
import { Table } from 'src/components/Table'; | ||
import { TableRow } from 'src/components/TableRow'; | ||
|
||
export const StyledTableRow = styled(TableRow, { | ||
label: 'TableRow', | ||
})(({ theme }) => ({ | ||
'& svg': { | ||
height: `12px`, | ||
opacity: 0, | ||
width: `12px`, | ||
}, | ||
'&:hover': { | ||
backgroundColor: theme.bg.lightBlue1, | ||
}, | ||
[`&:hover .copy-tooltip > svg, & .copy-tooltip:focus > svg`]: { | ||
opacity: 1, | ||
}, | ||
marginLeft: 4, | ||
top: 1, | ||
})); | ||
|
||
export const StyledTable = styled(Table, { | ||
label: 'Table', | ||
})(({ theme }) => ({ | ||
borderLeft: `1px solid ${theme.borderColors.borderTable}`, | ||
borderRight: `1px solid ${theme.borderColors.borderTable}`, | ||
})); | ||
|
||
export const StyledCopyTooltip = styled(CopyTooltip, { | ||
label: 'CopyTooltip', | ||
})(() => ({ | ||
'& svg': { | ||
height: `12px`, | ||
opacity: 0, | ||
width: `12px`, | ||
}, | ||
marginLeft: 4, | ||
top: 1, | ||
})); |
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.
This file was basically migrated from NodeTable along with some styling migration