Skip to content

Commit

Permalink
update ExperimentTableRow logic to render dropdown items correctly, u…
Browse files Browse the repository at this point in the history
…se StorageStateKF instead of location'
  • Loading branch information
jenny-s51 committed May 29, 2024
1 parent a4d4e74 commit 8cd319f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ const PipelineRunDetailsActions: React.FC<PipelineRunDetailsActionsProps> = ({ o
const [experiment] = useExperimentById(experimentId);
const isExperimentActive = experiment?.storage_state === StorageStateKF.AVAILABLE;

const RestoreDropdownItem = (
<DropdownItem
isDisabled={!isExperimentActive}
key="restore-run"
onClick={() =>
run &&
api
.unarchivePipelineRun({}, run.run_id)
.catch((e) => notification.error('Unable to restore pipeline run', e.message))
}
>
Restore
</DropdownItem>
);

return (
<Dropdown
data-testid="pipeline-run-details-actions"
Expand Down Expand Up @@ -93,36 +108,33 @@ const PipelineRunDetailsActions: React.FC<PipelineRunDetailsActionsProps> = ({ o
) : (
<React.Fragment key="compare-runs" />
),
!isExperimentActive ? (
<Tooltip
position="left"
content={
<div>
Archived runs cannot be restored until its associated experiment is restored.
</div>
}
>
<DropdownItem
isDisabled={!isExperimentActive}
key="restore-run"
onClick={() =>
api
.unarchivePipelineRun({}, run.run_id)
.catch((e) =>
notification.error('Unable to restore pipeline run', e.message),
)
!isRunActive ? (
!isExperimentActive ? (
<Tooltip
position="left"
content={
<div>
Archived runs cannot be restored until its associated experiment is
restored.
</div>
}
>
Restore
</DropdownItem>
</Tooltip>
{RestoreDropdownItem}
</Tooltip>
) : (
RestoreDropdownItem
)
) : (
<React.Fragment key="restore-run" />
),
<DropdownSeparator key="separator" />,
<DropdownItem key="delete-run" onClick={() => onDelete()}>
Delete
</DropdownItem>,
!isRunActive ? (
<React.Fragment key="delete-run">
<DropdownSeparator key="separator" />
<DropdownItem onClick={() => onDelete()}>Delete</DropdownItem>
</React.Fragment>
) : (
<React.Fragment key="delete-run" />
),
]
}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -23,9 +23,8 @@ const ExperimentTableRow: React.FC<ExperimentTableRowProps> = ({
actionColumnItems,
}) => {
const { namespace } = usePipelinesAPI();
const location = useLocation();

const isArchived = location.pathname.includes('/archived');
const isArchived = experiment.storage_state === StorageStateKF.ARCHIVED;

return (
<Tr>
Expand Down

0 comments on commit 8cd319f

Please sign in to comment.