Skip to content

Commit

Permalink
Fix deployment status properly on deployments list,
Browse files Browse the repository at this point in the history
 details and incluster overview
  • Loading branch information
akucharska committed Nov 21, 2024
1 parent 0c4ca06 commit 69b7e50
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 deletions.
7 changes: 6 additions & 1 deletion src/resources/Deployments/DeploymentDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ export function DeploymentDetails(props) {
const statusConditions = deployment => {
return deployment?.status?.conditions?.map(condition => {
return {
header: { titleText: condition.type, status: condition.status },
header: {
titleText: condition.type,
status: condition.status,
overrideStatusType:
condition.type === 'ReplicaFailure' ? 'False' : condition.status,
},
message: condition.message,
};
});
Expand Down
2 changes: 1 addition & 1 deletion src/resources/Deployments/DeploymentStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { RunningPodsStatus } from 'shared/components/RunningPodsStatus';

export function DeploymentStatus({ deployment }) {
const running = deployment.status.readyReplicas || 0;
const expected = deployment.status.replicas || 0;
const expected = deployment.status.replicas || deployment.spec.replicas || 0;

return <RunningPodsStatus running={running} expected={expected} />;
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { calculatePodState } from 'resources/Pods/PodStatus';

export function getHealthyReplicasCount(resource) {
return resource?.filter(r => r.status.replicas === r.status.readyReplicas)
?.length;
return resource?.filter(
r =>
r.status.replicas &&
r.status.readyReplicas &&
r.status.replicas === r.status.readyReplicas,
)?.length;
}

export const PodStatusCounterKey = {
Expand Down
2 changes: 2 additions & 0 deletions src/shared/components/ConditionList/ConditionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type ConditionItem = {
type ConditionHeader = {
titleText: string | ReactNode;
status?: string;
overrideStatusType?: string;
};

export const ConditionList = ({
Expand All @@ -34,6 +35,7 @@ export const ConditionList = ({
key={index}
header={cond.header?.titleText}
status={cond.header?.status}
overrideStatusType={cond.header?.overrideStatusType}
content={cond.message}
customContent={cond.customContent}
/>
Expand Down
12 changes: 8 additions & 4 deletions src/shared/components/ExpandableListItem/ExpandableListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import './ExpandableListItem.scss';
type ExpandableListItemProps = {
header: string | ReactNode;
status?: string;
overrideStatusType?: string;
content?: string;
customContent?: CustomContent[];
};
Expand All @@ -21,12 +22,18 @@ export type CustomContent = {
export const ExpandableListItem = ({
header,
status,
overrideStatusType,
content,
customContent,
}: ExpandableListItemProps) => {
const { t } = useTranslation();
const [expanded, setExpanded] = useState(false);

let statusType = status === 'True' ? 'Success' : 'Error';
if (overrideStatusType !== undefined) {
statusType = overrideStatusType === 'True' ? 'Success' : 'Error';
}

return (
<>
<StandardListItem
Expand All @@ -49,10 +56,7 @@ export const ExpandableListItem = ({
)}
{header}
{status && (
<StatusBadge
type={status === 'True' ? 'Success' : 'Error'}
className={'header__status-badge'}
>
<StatusBadge type={statusType} className={'header__status-badge'}>
{status}
</StatusBadge>
)}
Expand Down

0 comments on commit 69b7e50

Please sign in to comment.