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

feat(ocm): Add a frontend indicator for cluster upgrades #73

Merged
merged 1 commit into from
Jan 18, 2023
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
40 changes: 39 additions & 1 deletion plugins/ocm/src/components/ClusterInfoCard/ClusterInfoCard.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,53 @@
import React from 'react';

import { Button, Grid, makeStyles, Tooltip } from '@material-ui/core';
import ArrowUpwardRoundedIcon from '@material-ui/icons/ArrowUpwardRounded';
import { useCluster } from '../ClusterContext';
import { TableCardFromData } from '../TableCardFromData';

const useStyles = makeStyles({
button: {
textTransform: 'none',
borderRadius: 16,
margin: '0px',
paddingLeft: '4px',
paddingRight: '4px',
},
});

export const ClusterInfoCard = () => {
const { data } = useCluster();
const classes = useStyles();

if (!data) {
return null;
}

data.openshiftVersion = (
<>
{data.update?.available ? (
<Grid container direction="column" spacing={0}>
<Grid item>{data.openshiftVersion}</Grid>
<Grid item>
<Tooltip title={`Version ${data.update?.version!} available`}>
<Button
variant="text"
color="primary"
startIcon={<ArrowUpwardRoundedIcon style={{ fontSize: 22 }} />}
className={classes.button}
href={data.update?.url}
size="small"
>
Upgrade available
</Button>
</Tooltip>
</Grid>
</Grid>
) : (
data.openshiftVersion
)}
</>
) as any;

const nameMap = new Map<string, string>([
['name', 'Name'],
['kubernetesVersion', 'Kubernetes version'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const valueFormatter = (value: any): any => {
return <Link to={value}>{value}</Link>;
}
}
return value.toString();
return value;
};

export const TableCardFromData = ({
Expand All @@ -30,12 +30,12 @@ export const TableCardFromData = ({
title: string;
nameMap: Map<string, string>;
}) => {
const parsedData: { name: string; value: string }[] = [];
const parsedData: { name: string; value: any }[] = [];
const entries = Object.entries(data);

nameMap.forEach((_, key) => {
const entry = entries.find(e => e[0] === key)!;
// If key of the map doesnt have an prop in the cluster object, continue
// If key of the map doesn't have an prop in the cluster object, continue
if (entry === undefined) {
return;
}
Expand Down