Skip to content

Commit

Permalink
fix(ui): handle non-existent labels in isWorkflowInCluster (#12898)
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Gilgur <[email protected]>
  • Loading branch information
agilgur5 committed Apr 21, 2024
1 parent 49e21ac commit 08772fb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export function WorkflowDetails({history, location, match}: RouteComponentProps<
if (e.type === 'DELETED') {
setUid(e.object.metadata.uid);
setError(new Error('Workflow gone'));
if (e.object.metadata.labels[archivalStatus]) {
if (e.object.metadata.labels?.[archivalStatus]) {
e.object.metadata.labels[archivalStatus] = 'Persisted';
}
setWorkflow(e.object);
Expand Down
4 changes: 3 additions & 1 deletion ui/src/models/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,9 @@ export function isWorkflowInCluster(wf: Workflow): boolean {
if (!wf) {
return false;
}
return !wf.metadata.labels[archivalStatus] || wf.metadata.labels[archivalStatus] === 'Pending' || wf.metadata.labels[archivalStatus] === 'Archived';

const labelValue = wf.metadata?.labels?.[archivalStatus];
return !labelValue || labelValue === 'Pending' || labelValue === 'Archived';
}

export function isArchivedWorkflow(wf?: Workflow): boolean {
Expand Down

0 comments on commit 08772fb

Please sign in to comment.