From ead6fef9074c50539cd68072808da785e7538be9 Mon Sep 17 00:00:00 2001 From: Jenny <32821331+jenny-s51@users.noreply.github.com> Date: Wed, 29 May 2024 15:55:26 -0400 Subject: [PATCH] update ExperimentTableRow logic to render dropdown items correctly, use StorageStateKF instead of location' --- .../pipelineRun/PipelineRunDetailsActions.tsx | 62 +++++++++++-------- .../tables/experiment/ExperimentTableRow.tsx | 7 +-- 2 files changed, 40 insertions(+), 29 deletions(-) diff --git a/frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunDetailsActions.tsx b/frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunDetailsActions.tsx index 2f8149be78..f1877c3a17 100644 --- a/frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunDetailsActions.tsx +++ b/frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunDetailsActions.tsx @@ -30,6 +30,21 @@ const PipelineRunDetailsActions: React.FC = ({ o const [experiment] = useExperimentById(experimentId); const isExperimentActive = experiment?.storage_state === StorageStateKF.AVAILABLE; + const RestoreDropdownItem = ( + + run && + api + .unarchivePipelineRun({}, run.run_id) + .catch((e) => notification.error('Unable to restore pipeline run', e.message)) + } + > + Restore + + ); + return ( = ({ o ) : ( ), - !isExperimentActive ? ( - - Archived runs cannot be restored until its associated experiment is restored. - - } - > - - api - .unarchivePipelineRun({}, run.run_id) - .catch((e) => - notification.error('Unable to restore pipeline run', e.message), - ) + !isRunActive ? ( + !isExperimentActive ? ( + + Archived runs cannot be restored until its associated experiment is + restored. + } > - Restore - - + {RestoreDropdownItem} + + ) : ( + RestoreDropdownItem + ) ) : ( ), - , - onDelete()}> - Delete - , + !isRunActive ? ( + + + onDelete()}>Delete + + ) : ( + + ), ] } /> diff --git a/frontend/src/concepts/pipelines/content/tables/experiment/ExperimentTableRow.tsx b/frontend/src/concepts/pipelines/content/tables/experiment/ExperimentTableRow.tsx index d6e3659b75..af730b7c56 100644 --- a/frontend/src/concepts/pipelines/content/tables/experiment/ExperimentTableRow.tsx +++ b/frontend/src/concepts/pipelines/content/tables/experiment/ExperimentTableRow.tsx @@ -1,9 +1,9 @@ import React from 'react'; -import { Link, useLocation } from 'react-router-dom'; +import { Link } from 'react-router-dom'; import { ActionsColumn, IAction, Td, Tr } from '@patternfly/react-table'; -import { ExperimentKFv2 } from '~/concepts/pipelines/kfTypes'; +import { ExperimentKFv2, StorageStateKF } from '~/concepts/pipelines/kfTypes'; import { CheckboxTd } from '~/components/table'; import { experimentRunsRoute } from '~/routes'; import { usePipelinesAPI } from '~/concepts/pipelines/context'; @@ -23,9 +23,8 @@ const ExperimentTableRow: React.FC = ({ actionColumnItems, }) => { const { namespace } = usePipelinesAPI(); - const location = useLocation(); - const isArchived = location.pathname.includes('/archived'); + const isArchived = experiment.storage_state === StorageStateKF.ARCHIVED; return (