Skip to content

Commit

Permalink
PR feedback: fix route, remove helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jenny-s51 committed May 23, 2024
1 parent 3fd1ef0 commit 3169f83
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 25 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, getStorageState } from '~/concepts/pipelines/content/utils';
import { PipelineRunKFv2, StorageStateKF } from '~/concepts/pipelines/kfTypes';
import { computeRunStatus } from '~/concepts/pipelines/content/utils';
import PipelineRunTypeLabel from '~/concepts/pipelines/content/PipelineRunTypeLabel';

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

const isArchived = getStorageState(run) === 'ARCHIVED';
const isArchived = run.storage_state === StorageStateKF.ARCHIVED;

return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import useNotification from '~/utilities/useNotification';
import { PipelineRunKFv2, RuntimeStateKF, StorageStateKF } from '~/concepts/pipelines/kfTypes';
import { cloneRunRoute, experimentsCompareRunsRoute } from '~/routes';
import { SupportedArea, useIsAreaAvailable } from '~/concepts/areas';
import useExperimentById from "~/concepts/pipelines/apiHooks/useExperimentById";

Check failure on line 15 in frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/PipelineRunDetailsActions.tsx

View workflow job for this annotation

GitHub Actions / Tests (18.x)

Replace `"~/concepts/pipelines/apiHooks/useExperimentById"` with `'~/concepts/pipelines/apiHooks/useExperimentById'`

type PipelineRunDetailsActionsProps = {
run?: PipelineRunKFv2 | null;
Expand All @@ -26,6 +27,8 @@ const PipelineRunDetailsActions: React.FC<PipelineRunDetailsActionsProps> = ({ o
const [open, setOpen] = React.useState(false);
const isExperimentsAvailable = useIsAreaAvailable(SupportedArea.PIPELINE_EXPERIMENTS).status;
const isRunActive = run?.storage_state === StorageStateKF.AVAILABLE;
const [experiment] = useExperimentById(experimentId);
const isExperimentActive = experiment?.storage_state === StorageStateKF.AVAILABLE;

return (
<Dropdown
Expand Down Expand Up @@ -90,7 +93,7 @@ const PipelineRunDetailsActions: React.FC<PipelineRunDetailsActionsProps> = ({ o
) : (
<React.Fragment key="compare-runs" />
),
!isRunActive ? (
!isExperimentActive ? (
<Tooltip
position="left"
content={
Expand All @@ -100,7 +103,7 @@ const PipelineRunDetailsActions: React.FC<PipelineRunDetailsActionsProps> = ({ o
}
>
<DropdownItem
isDisabled={!isRunActive}
isDisabled={!isExperimentActive}
key="restore-run"
onClick={() =>
api
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { Link, useLocation } from 'react-router-dom';

import { ActionsColumn, IAction, Td, Tr } from '@patternfly/react-table';

import { ExperimentKFv2 } from '~/concepts/pipelines/kfTypes';
import { CheckboxTd } from '~/components/table';
import { experimentArchivedRunsRoute, experimentRunsRoute } from '~/routes';
import { experimentRunsRoute } from '~/routes';
import { usePipelinesAPI } from '~/concepts/pipelines/context';
import { ExperimentCreated, LastExperimentRuns } from './renderUtils';

Expand All @@ -23,19 +23,18 @@ const ExperimentTableRow: React.FC<ExperimentTableRowProps> = ({
actionColumnItems,
}) => {
const { namespace } = usePipelinesAPI();
const location = useLocation();

const isArchived = window.location.href.includes('/archived');
const isArchived = location.pathname.includes('/archived');

return (
<Tr>
<CheckboxTd id={experiment.experiment_id} isChecked={isChecked} onToggle={onToggleCheck} />
<Td dataLabel="Experiment">
<Link
to={
isArchived
? experimentArchivedRunsRoute(namespace, experiment.experiment_id)
: experimentRunsRoute(namespace, experiment.experiment_id)
}
to={`${experimentRunsRoute(namespace, experiment.experiment_id)}${
isArchived ? '/?runType=archived' : ''
}`}
state={{ experiment }}
>
{experiment.display_name}
Expand Down
4 changes: 0 additions & 4 deletions frontend/src/concepts/pipelines/content/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
PipelineRunKFv2,
PipelineVersionKFv2,
RuntimeStateKF,
StorageStateKF,
runtimeStateLabels,
} from '~/concepts/pipelines/kfTypes';
import { relativeTime } from '~/utilities/time';
Expand All @@ -31,9 +30,6 @@ 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
8 changes: 0 additions & 8 deletions frontend/src/routes/pipelines/experiments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ export const experimentRunsRoute = (
? experimentsBaseRoute(namespace)
: `${experimentsBaseRoute(namespace)}/${experimentId}/runs`;

export const experimentArchivedRunsRoute = (
namespace: string | undefined,
experimentId: string | undefined,
): string =>
!experimentId
? experimentsBaseRoute(namespace)
: `${experimentsBaseRoute(namespace)}/${experimentId}/runs/?runType=archived`;

export const experimentSchedulesRoute = (
namespace: string | undefined,
experimentId: string | undefined,
Expand Down

0 comments on commit 3169f83

Please sign in to comment.