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

Update components to support displaying new Cancelled status #2316

Merged
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
@@ -1,5 +1,5 @@
/*
Copyright 2019-2021 The Tekton Authors
Copyright 2019-2022 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down Expand Up @@ -88,7 +88,6 @@ header.tkn--step-details-header {
&[data-status='terminated'][data-reason='Error'],
&[data-status='False'],
&[data-status='cancelled'],
&[data-reason='PipelineRunCancelled'],
&[data-reason='TaskRunCancelled'],
&[data-reason='TaskRunTimeout'] {
.tkn--status-label {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2019-2021 The Tekton Authors
Copyright 2019-2022 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down Expand Up @@ -48,11 +48,12 @@ export default {
title: 'Components/DetailsHeader'
};

export const Running = args => (
export const Cancelled = args => (
<DetailsHeader
status="running"
reason="TaskRunCancelled"
status="terminated"
displayName="build"
taskRun={getTaskRun({ reason: 'Running', status: 'Unknown' })}
taskRun={getTaskRun({ reason: 'TaskRunCancelled', status: 'False' })}
{...args}
/>
);
Expand Down Expand Up @@ -96,3 +97,12 @@ export const Pending = args => (
{...args}
/>
);

export const Running = args => (
<DetailsHeader
status="running"
displayName="build"
taskRun={getTaskRun({ reason: 'Running', status: 'Unknown' })}
{...args}
/>
);
4 changes: 3 additions & 1 deletion packages/components/src/components/StatusIcon/StatusIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ export default function StatusIcon({
statusClass = hasWarning ? 'warning' : 'success';
} else if (
status === 'False' &&
(reason === 'PipelineRunCancelled' || reason === 'TaskRunCancelled')
(reason === 'PipelineRunCancelled' ||
reason === 'Cancelled' ||
reason === 'TaskRunCancelled')
) {
statusClass = 'cancelled';
} else if (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2020-2021 The Tekton Authors
Copyright 2020-2022 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down Expand Up @@ -34,12 +34,30 @@ export default {
title: 'Components/StatusIcon'
};

export const Queued = args => <StatusIcon {...args} />;
export const CancelledGraceful = args => (
<StatusIcon reason="Cancelled" status="False" {...args} />
);
CancelledGraceful.storyName =
'Cancelled - PipelineRun TEP-0058 graceful termination';

export const CancelledPipelineRun = args => (
<StatusIcon reason="PipelineRunCancelled" status="False" {...args} />
);
CancelledPipelineRun.storyName = 'Cancelled - PipelineRun legacy';

export const CancelledTaskRun = args => (
<StatusIcon reason="TaskRunCancelled" status="False" {...args} />
AlanGreene marked this conversation as resolved.
Show resolved Hide resolved
);
CancelledTaskRun.storyName = 'Cancelled - TaskRun';

export const Failed = args => <StatusIcon status="False" {...args} />;

export const Pending = args => (
<StatusIcon reason="Pending" status="Unknown" {...args} />
);

export const Queued = args => <StatusIcon {...args} />;

export const Running = args => (
<StatusIcon reason="Running" status="Unknown" {...args} />
);
Expand All @@ -50,5 +68,3 @@ export const SucceededWithWarning = args => (
<StatusIcon hasWarning status="True" {...args} />
);
SucceededWithWarning.storyName = 'Succeeded with warning';

export const Failed = args => <StatusIcon status="False" {...args} />;
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021 The Tekton Authors
Copyright 2021-2022 The Tekton Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Expand Down Expand Up @@ -28,6 +28,10 @@ describe('StatusIcon', () => {
render(<StatusIcon reason="PipelineRunCancelled" status="False" />);
});

it('renders Cancelled state', () => {
render(<StatusIcon reason="Cancelled" status="False" />);
});

it('renders TaskRunCancelled state', () => {
render(<StatusIcon reason="TaskRunCancelled" status="False" />);
});
Expand Down
5 changes: 4 additions & 1 deletion packages/utils/src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,16 @@ export function runMatchesStatusFilter({ run, statusFilter }) {
return (
(status === 'False' &&
reason !== 'PipelineRunCancelled' &&
reason !== 'Cancelled' &&
reason !== 'TaskRunCancelled') ||
(status === 'Unknown' && reason === 'PipelineRunCouldntCancel')
);
case 'cancelled':
return (
status === 'False' &&
(reason === 'PipelineRunCancelled' || reason === 'TaskRunCancelled')
(reason === 'PipelineRunCancelled' ||
reason === 'Cancelled' ||
reason === 'TaskRunCancelled')
);
case 'completed':
return status === 'True';
Expand Down