Skip to content

Commit

Permalink
Fix styles and label for cancelled steps
Browse files Browse the repository at this point in the history
Pipelines now updates the status of steps for cancelled or timed out
TaskRuns, see tektoncd/pipeline#3088

Update the styles and labels to display these as cancelled rather
than failed (which was the fallback for unknown status/reason combos)
  • Loading branch information
AlanGreene authored and tekton-robot committed Oct 15, 2020
1 parent 261a585 commit ccf839d
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ class DetailsHeader extends Component {
const { intl, reason, status, taskRun } = this.props;
const { reason: taskReason, status: taskStatus } = getStatus(taskRun);

if (status === 'cancelled') {
if (
status === 'cancelled' ||
(status === 'terminated' &&
(reason === 'TaskRunCancelled' || reason === 'TaskRunTimeout'))
) {
return intl.formatMessage({
id: 'dashboard.taskRun.status.cancelled',
defaultMessage: 'Cancelled'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ limitations under the License.
}
&[data-status='cancelled'],
&[data-reason='PipelineRunCancelled'],
&[data-reason='TaskRunCancelled'] {
&[data-reason='TaskRunCancelled'],
&[data-reason='TaskRunTimeout'] {
.tkn--status-icon {
fill: $failed;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,20 @@ it('DetailsHeader renders the cancelled state', () => {
expect(queryByText(/Cancelled/i)).toBeTruthy();
});

it('DetailsHeader renders the cancelled state for TaskRunCancelled', () => {
const { queryByText } = renderWithIntl(
<DetailsHeader {...props} status="terminated" reason="TaskRunCancelled" />
);
expect(queryByText(/Cancelled/i)).toBeTruthy();
});

it('DetailsHeader renders the cancelled state for TaskRunTimeout', () => {
const { queryByText } = renderWithIntl(
<DetailsHeader {...props} status="terminated" reason="TaskRunTimeout" />
);
expect(queryByText(/Cancelled/i)).toBeTruthy();
});

it('DetailsHeader renders the failed state', () => {
const { queryByText } = renderWithIntl(
<DetailsHeader {...props} status="terminated" />
Expand Down
6 changes: 5 additions & 1 deletion packages/components/src/components/Step/Step.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ class Step extends Component {
statusLabel() {
const { intl, reason, status } = this.props;

if (status === 'cancelled') {
if (
status === 'cancelled' ||
(status === 'terminated' &&
(reason === 'TaskRunCancelled' || reason === 'TaskRunTimeout'))
) {
return intl.formatMessage({
id: 'dashboard.taskRun.status.cancelled',
defaultMessage: 'Cancelled'
Expand Down
20 changes: 12 additions & 8 deletions packages/components/src/components/Step/Step.scss
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,18 @@ limitations under the License.
font-weight: bold;
}
}
&[data-status='cancelled'] > a.tkn--step-link {
opacity: 1;
.tkn--step-icon {
fill: $failed;
}
.tkn--status-label {
color: $failed;
font-weight: bold;
&[data-status='cancelled'],
&[data-status='terminated'][data-reason='TaskRunCancelled'],
&[data-status='terminated'][data-reason='TaskRunTimeout'] {
> a.tkn--step-link {
opacity: 1;
.tkn--step-icon {
fill: $failed;
}
.tkn--status-label {
color: $failed;
font-weight: bold;
}
}
}
}
14 changes: 14 additions & 0 deletions packages/components/src/components/Step/Step.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ it('Step renders cancelled state', () => {
expect(queryByText(/Cancelled/i)).toBeTruthy();
});

it('Step renders cancelled state for TaskRunCancelled', () => {
const { queryByText } = renderWithIntl(
<Step status="terminated" reason="TaskRunCancelled" />
);
expect(queryByText(/Cancelled/i)).toBeTruthy();
});

it('Step renders cancelled state for TaskRunTimeout', () => {
const { queryByText } = renderWithIntl(
<Step status="terminated" reason="TaskRunTimeout" />
);
expect(queryByText(/Cancelled/i)).toBeTruthy();
});

it('Step renders completed state', () => {
const { queryByText } = renderWithIntl(
<Step status="terminated" reason="Completed" />
Expand Down

0 comments on commit ccf839d

Please sign in to comment.