Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable create run/schedule dropdown action when pipeline has no vers… #2985

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,19 @@ describe('Pipelines', () => {
runCreateRunPageNavTest(visitPipelineProjects);
});

it('run and schedule dropdown action should be disabeld when pipeline has no versions', () => {
initIntercepts({ hasNoPipelineVersions: true });
pipelinesGlobal.visit(projectName);
pipelinesTable
.getRowById(initialMockPipeline.pipeline_id)
.findKebabAction('Create schedule')
.should('have.attr', 'aria-disabled');
pipelinesTable
.getRowById(initialMockPipeline.pipeline_id)
.findKebabAction('Create run')
.should('have.attr', 'aria-disabled');
});

it('navigates to "Schedule run" page from pipeline row', () => {
const visitPipelineProjects = () => pipelinesGlobal.visit(projectName);
runScheduleRunPageNavTest(visitPipelineProjects);
Expand Down Expand Up @@ -1114,13 +1127,15 @@ describe('Pipelines', () => {
type HandlersProps = {
isEmpty?: boolean;
mockPipelines?: PipelineKFv2[];
hasNoPipelineVersions?: boolean;
totalSize?: number;
nextPageToken?: string | undefined;
};

export const initIntercepts = ({
isEmpty = false,
mockPipelines = [initialMockPipeline],
hasNoPipelineVersions = false,
totalSize = mockPipelines.length,
nextPageToken,
}: HandlersProps): void => {
Expand Down Expand Up @@ -1169,7 +1184,7 @@ export const initIntercepts = ({
pipelineId: initialMockPipeline.pipeline_id,
},
},
buildMockPipelineVersionsV2([initialMockPipelineVersion]),
hasNoPipelineVersions ? {} : buildMockPipelineVersionsV2([initialMockPipelineVersion]),
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const PipelinesTableRow: React.FC<PipelinesTableRowProps> = ({

// disable the checkbox if the pipeline has pipeline versions
const disableDelete = totalSize > 0;
const hasNoPipelineVersions = totalSize === 0;
React.useEffect(() => {
disableCheck(pipelineRef.current, disableDelete || loading);
}, [disableDelete, loading, disableCheck]);
Expand Down Expand Up @@ -125,6 +126,7 @@ const PipelinesTableRow: React.FC<PipelinesTableRowProps> = ({
},
{
title: 'Create run',
isAriaDisabled: hasNoPipelineVersions,
onClick: () => {
navigate(routePipelineRunCreateNamespacePipelinesPage(namespace), {
state: { lastPipeline: pipeline },
Expand All @@ -133,6 +135,7 @@ const PipelinesTableRow: React.FC<PipelinesTableRowProps> = ({
},
{
title: 'Create schedule',
isAriaDisabled: hasNoPipelineVersions,
onClick: () => {
navigate(
{
Expand Down
Loading