Skip to content

Commit

Permalink
fix(ocm): fix unaligned status icon and message
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Jerolimov <[email protected]>
  • Loading branch information
christoph-jerolimov committed Oct 18, 2024
1 parent f1fcddb commit 253219f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 41 deletions.
40 changes: 17 additions & 23 deletions plugins/ocm/src/components/ClusterStatusPage/ClusterStatusPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactElement } from 'react';
import React from 'react';
import useAsyncFn from 'react-use/lib/useAsyncFn';
import useDebounce from 'react-use/lib/useDebounce';

Expand Down Expand Up @@ -50,27 +50,21 @@ const useStyles = makeStyles(theme => ({

const NodeChip = ({
count,
indicator,
indicatorComponent: IndicatorComponent,
}: {
count: number;
indicator: ReactElement;
}) => (
<>
{count > 0 ? (
<Chip
label={
<>
{indicator}
{count}
</>
}
variant="outlined"
/>
) : (
<></>
)}
</>
);
indicatorComponent: React.FC<React.PropsWithChildren<{}>>;
}) => {
if (!count) {
return null;
}
return (
<Chip
label={<IndicatorComponent>{count}</IndicatorComponent>}
variant="outlined"
/>
);
};

const NodeChips = ({ nodes }: { nodes: ClusterNodesStatus[] }) => {
const readyChipsNodes = nodes.filter(node => node.status === 'True').length;
Expand All @@ -85,11 +79,11 @@ const NodeChips = ({ nodes }: { nodes: ClusterNodesStatus[] }) => {

return (
<>
<NodeChip count={readyChipsNodes} indicator={<StatusOK />} />
<NodeChip count={notReadyNodesCount} indicator={<StatusError />} />
<NodeChip count={readyChipsNodes} indicatorComponent={StatusOK} />
<NodeChip count={notReadyNodesCount} indicatorComponent={StatusError} />
<NodeChip
count={nodes.length - readyChipsNodes - notReadyNodesCount}
indicator={<StatusAborted />}
indicatorComponent={StatusAborted}
/>
</>
);
Expand Down
21 changes: 3 additions & 18 deletions plugins/ocm/src/components/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,11 @@ const useStyles = makeStyles({

export const Status = ({ status }: { status: ClusterStatus }) => {
if (!status) {
return (
<>
<StatusAborted />
Unknown
</>
);
return <StatusAborted>Unknown</StatusAborted>;
} else if (status.available) {
return (
<>
<StatusOK />
Ready
</>
);
return <StatusOK>Ready</StatusOK>;
}
return (
<>
<StatusError />
Not Ready
</>
);
return <StatusError>Not Ready</StatusError>;
};

export const Update = ({ data }: { data: versionDetails }) => {
Expand Down

0 comments on commit 253219f

Please sign in to comment.