Skip to content
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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-10320-fixed-1711553963315.md
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
Expand Up @@ -2,16 +2,16 @@ import {
AutoscaleSettings,
PoolNodeResponse,
} from '@linode/api-v4/lib/kubernetes';
import Grid from '@mui/material/Unstable_Grid2';
import { Theme } from '@mui/material/styles';
import { makeStyles } from 'tss-react/mui';
import Grid from '@mui/material/Unstable_Grid2';
import * as React from 'react';
import { makeStyles } from 'tss-react/mui';

import { Button } from 'src/components/Button/Button';
import { Tooltip } from 'src/components/Tooltip';
import { Typography } from 'src/components/Typography';

import NodeTable from './NodeTable';
import { NodeTable } from './NodeTable';

interface Props {
autoscaler: AutoscaleSettings;
Expand Down
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';
Copy link
Contributor Author

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


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
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we simplify the determination of iconStatus by directly incorporating the conditions?

  const iconStatus =
    nodeStatus === 'not_ready'
      ? 'other'
      : nodeStatus === 'ready' && instanceStatus === 'running'
      ? 'active'
      : 'inactive';


const displayLabel = label ?? typeLabel;

const displayStatus =
nodeStatus === 'not_ready'
? 'Provisioning'
: transitionText(instanceStatus ?? '', instanceId ?? -1, recentEvent);

const displayIP = ip ?? '';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need direct usage of ip instead of displayIP? Since we are conditionally rendering the consumers of displayIP, which will handle undefined cases, can we directly use ip?


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,
}));
Loading
Loading