Skip to content

Commit

Permalink
add archived labels and additional dropdown items
Browse files Browse the repository at this point in the history
  • Loading branch information
jenny-s51 committed May 21, 2024
1 parent cb8e308 commit 0c33597
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Label, Split, SplitItem } from '@patternfly/react-core';
import { PipelineRunKFv2 } from '~/concepts/pipelines/kfTypes';
import { computeRunStatus } from '~/concepts/pipelines/content/utils';
import { computeRunStatus, getStorageState } from '~/concepts/pipelines/content/utils';
import PipelineRunTypeLabel from '~/concepts/pipelines/content/PipelineRunTypeLabel';

type RunJobTitleProps = {
Expand All @@ -17,6 +17,8 @@ const PipelineDetailsTitle: React.FC<RunJobTitleProps> = ({
}) => {
const { icon, label } = computeRunStatus(run);

const isArchived = getStorageState(run) === 'ARCHIVED';

return (
<>
<Split hasGutter>
Expand All @@ -31,6 +33,11 @@ const PipelineDetailsTitle: React.FC<RunJobTitleProps> = ({
<Label icon={icon}>{label}</Label>
</SplitItem>
)}
{isArchived && (
<SplitItem>
<Label>Archived</Label>
</SplitItem>
)}
</Split>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ const PipelineRunDetailsActions: React.FC<PipelineRunDetailsActionsProps> = ({ o
? []
: [
<DropdownItem
key="stop-run"
isDisabled={run.state !== RuntimeStateKF.RUNNING}
key="retry-run"
isDisabled={run.state !== RuntimeStateKF.FAILED || !!run.error}
onClick={() =>
api
.stopPipelineRun({}, run.run_id)
.catch((e) => notification.error('Unable to stop pipeline run', e.message))
.retryPipelineRun({}, run.run_id)
.catch((e) => notification.error('Unable to retry pipeline run', e.message))
}
>
Stop
Retry
</DropdownItem>,
<DropdownItem
key="clone-run"
Expand All @@ -64,7 +64,18 @@ const PipelineRunDetailsActions: React.FC<PipelineRunDetailsActionsProps> = ({ o
)
}
>
Duplicate
Clone
</DropdownItem>,
<DropdownItem
key="stop-run"
isDisabled={run.state !== RuntimeStateKF.RUNNING}
onClick={() =>
api
.stopPipelineRun({}, run.run_id)
.catch((e) => notification.error('Unable to stop pipeline run', e.message))
}
>
Stop
</DropdownItem>,
isExperimentsAvailable && experimentId && isRunActive ? (
<DropdownItem
Expand All @@ -78,6 +89,20 @@ const PipelineRunDetailsActions: React.FC<PipelineRunDetailsActionsProps> = ({ o
) : (
<React.Fragment key="compare-runs" />
),
!isRunActive ? (
<DropdownItem
key="restore-run"
onClick={() =>
api
.unarchivePipelineRun({}, run.run_id)
.catch((e) => notification.error('Unable to restore pipeline run', e.message))
}
>
Restore
</DropdownItem>
) : (
<React.Fragment key="restore-run" />
),
<DropdownSeparator key="separator" />,
<DropdownItem key="delete-run" onClick={() => onDelete()}>
Delete
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/concepts/pipelines/content/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
PipelineRunKFv2,
PipelineVersionKFv2,
RuntimeStateKF,
StorageStateKF,
runtimeStateLabels,
} from '~/concepts/pipelines/kfTypes';
import { relativeTime } from '~/utilities/time';
Expand All @@ -30,6 +31,8 @@ export type RunStatusDetails = {
const UNKNOWN_ICON = <QuestionCircleIcon />;
const UNKNOWN_STATUS = 'warning';

export const getStorageState = (run?: PipelineRunKFv2 | null): StorageStateKF | undefined => run?.storage_state;

export const computeRunStatus = (run?: PipelineRunKFv2 | null): RunStatusDetails => {
if (!run) {
return { icon: UNKNOWN_ICON, status: UNKNOWN_STATUS, label: '-' };
Expand Down

0 comments on commit 0c33597

Please sign in to comment.