Skip to content

Commit

Permalink
[RHOAIENG-8583] Remove the disabled 'Create schedule' button when in …
Browse files Browse the repository at this point in the history
…an archived experiment
  • Loading branch information
jpuzz0 committed Jun 26, 2024
1 parent a9bbb1b commit 143c3d7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,10 @@ describe('Runs page for archived experiment', () => {
pipelineRunsGlobal.findRestoreRunButton().should('have.class', 'pf-m-aria-disabled');
});

it('has create schedule button disabled on schedules tab', () => {
it('has no create schedule button on schedules tab', () => {
pipelineRunsGlobal.findSchedulesTab().click();
pipelineRunJobTable.getRowByName('Test job').findCheckbox().click();
pipelineRunsGlobal.findScheduleRunButton().should('have.class', 'pf-m-aria-disabled');
pipelineRunsGlobal.findScheduleRunButton().should('not.exist');
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { FilterOptions } from '~/concepts/pipelines/content/tables/usePipelineFi
import PipelineVersionSelect from '~/concepts/pipelines/content/pipelineSelector/CustomPipelineVersionSelect';
import { PipelineRunVersionsContext } from '~/pages/pipelines/global/runs/PipelineRunVersionsContext';
import CreateScheduleButton from '~/pages/pipelines/global/runs/CreateScheduleButton';
import { useContextExperimentArchived as useIsExperimentArchived } from '~/pages/pipelines/global/experiments/ExperimentRunsContext';

export type FilterProps = Pick<
React.ComponentProps<typeof PipelineFilterBar>,
Expand All @@ -21,6 +22,7 @@ const PipelineRunJobTableToolbar: React.FC<PipelineRunJobTableToolbarProps> = ({
...toolbarProps
}) => {
const { versions } = React.useContext(PipelineRunVersionsContext);
const isExperimentArchived = useIsExperimentArchived();
const { pipelineVersionId } = useParams();

const options = {
Expand Down Expand Up @@ -53,9 +55,12 @@ const PipelineRunJobTableToolbar: React.FC<PipelineRunJobTableToolbarProps> = ({
),
}}
>
<ToolbarItem>
<CreateScheduleButton />
</ToolbarItem>
{!isExperimentArchived && (
<ToolbarItem>
<CreateScheduleButton />
</ToolbarItem>
)}

<ToolbarItem data-testid="job-table-toolbar-item">{dropdownActions}</ToolbarItem>
</PipelineFilterBar>
);
Expand Down
19 changes: 11 additions & 8 deletions frontend/src/pages/pipelines/global/runs/ScheduledRuns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ import { ExclamationCircleIcon, PlusCircleIcon } from '@patternfly/react-icons';
import PipelineRunJobTable from '~/concepts/pipelines/content/tables/pipelineRunJob/PipelineRunJobTable';
import { usePipelineScheduledRunsTable } from '~/concepts/pipelines/content/tables/pipelineRunJob/usePipelineRunJobTable';
import CreateScheduleButton from '~/pages/pipelines/global/runs/CreateScheduleButton';
import { useContextExperimentArchived as useIsExperimentArchived } from '~/pages/pipelines/global/experiments/ExperimentRunsContext';

const ScheduledRuns: React.FC = () => {
const { experimentId, pipelineVersionId } = useParams();

const [[{ items: jobs, totalSize }, loaded, error], { initialLoaded, ...tableProps }] =
usePipelineScheduledRunsTable({ experimentId, pipelineVersionId });
const isExperimentArchived = useIsExperimentArchived();

if (error) {
return (
Expand Down Expand Up @@ -56,15 +57,17 @@ const ScheduledRuns: React.FC = () => {
/>

<EmptyStateBody>
Schedules dictate when and how many times a run is executed. To get started, create a
schedule.
Schedules dictate when and how many times a run is executed.{' '}
{!isExperimentArchived && 'To get started, create a schedule.'}
</EmptyStateBody>

<EmptyStateFooter>
<EmptyStateActions>
<CreateScheduleButton />
</EmptyStateActions>
</EmptyStateFooter>
{!isExperimentArchived && (
<EmptyStateFooter>
<EmptyStateActions>
<CreateScheduleButton />
</EmptyStateActions>
</EmptyStateFooter>
)}
</EmptyState>
);
}
Expand Down

0 comments on commit 143c3d7

Please sign in to comment.