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

refactor: NodeBalancer Config Node - Remove one-off-styled Chip #9883

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tech Stories
---

NodeBalancer Config Node - Remove one-off-styled Chip ([#9883](https://github.com/linode/manager/pull/9883))
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ const modeOptions: {
{ label: 'Drain', value: 'drain' },
];

const statusToChipColor = {
DOWN: 'error',
UP: 'success',
unknown: 'default',
} as const;

export const NodeBalancerConfigNode = React.memo(
(props: NodeBalancerConfigNodeProps) => {
const {
Expand Down Expand Up @@ -114,10 +120,12 @@ export const NodeBalancerConfigNode = React.memo(
<Grid lg={2} sm={4} xs={6}>
<StyledStatusHeader data-qa-active-checks-header variant="h3">
Status
<div>
<StyledStatusChip component="div" label={node.status} />
</div>
</StyledStatusHeader>
<Chip
color={statusToChipColor[node.status]}
label={node.status}
sx={{ marginTop: 1 }}
/>
</Grid>
)}
</Grid>
Expand Down Expand Up @@ -205,16 +213,3 @@ const StyledStatusHeader = styled(Typography, {
fontSize: '.9rem',
marginTop: `calc(${theme.spacing(2)} - 4)`,
}));

const StyledStatusChip = styled(Chip, {
label: 'StyledStatusChip',
})<Partial<NodeBalancerConfigNodeProps>>(({ theme, ...props }) => ({
backgroundColor:
props.label === 'UP'
? theme.color.green
: props.label === 'DOWN'
? theme.color.red
: theme.color.grey2,
color: props?.node?.status ? theme.palette.text.primary : 'white',
marginTop: theme.spacing(1),
}));
14 changes: 8 additions & 6 deletions packages/manager/src/mocks/serverHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -779,11 +779,11 @@ export const handlers = [
});
return res(ctx.json(newFirewall));
}),
rest.get('*/nodebalancers', (req, res, ctx) => {
const nodeBalancers = nodeBalancerFactory.buildList(0);
rest.get('*/v4/nodebalancers', (req, res, ctx) => {
const nodeBalancers = nodeBalancerFactory.buildList(1);
return res(ctx.json(makeResourcePage(nodeBalancers)));
}),
rest.get('*/nodebalancers/:nodeBalancerID', (req, res, ctx) => {
rest.get('*/v4/nodebalancers/:nodeBalancerID', (req, res, ctx) => {
const nodeBalancer = nodeBalancerFactory.build({
id: Number(req.params.nodeBalancerID),
});
Expand All @@ -798,9 +798,11 @@ export const handlers = [
rest.get(
'*/nodebalancers/:nodeBalancerID/configs/:configID/nodes',
(req, res, ctx) => {
const configs = nodeBalancerConfigNodeFactory.buildList(2, {
nodebalancer_id: Number(req.params.nodeBalancerID),
});
const configs = [
nodeBalancerConfigNodeFactory.build({ status: 'UP' }),
nodeBalancerConfigNodeFactory.build({ status: 'DOWN' }),
nodeBalancerConfigNodeFactory.build({ status: 'unknown' }),
];
return res(ctx.json(makeResourcePage(configs)));
}
),
Expand Down