Skip to content

Commit c9e4348

Browse files
committed
Fix styles and label for cancelled steps
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)
1 parent 261a585 commit c9e4348

File tree

5 files changed

+33
-10
lines changed

5 files changed

+33
-10
lines changed

packages/components/src/components/DetailsHeader/DetailsHeader.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ class DetailsHeader extends Component {
5252
const { intl, reason, status, taskRun } = this.props;
5353
const { reason: taskReason, status: taskStatus } = getStatus(taskRun);
5454

55-
if (status === 'cancelled') {
55+
if (
56+
status === 'cancelled' ||
57+
(status === 'terminated' && reason === 'TaskRunCancelled')
58+
) {
5659
return intl.formatMessage({
5760
id: 'dashboard.taskRun.status.cancelled',
5861
defaultMessage: 'Cancelled'

packages/components/src/components/DetailsHeader/DetailsHeader.test.js

+7
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ it('DetailsHeader renders the cancelled state', () => {
4545
expect(queryByText(/Cancelled/i)).toBeTruthy();
4646
});
4747

48+
it('DetailsHeader renders the cancelled state with status terminated', () => {
49+
const { queryByText } = renderWithIntl(
50+
<DetailsHeader {...props} status="terminated" reason="TaskRunCancelled" />
51+
);
52+
expect(queryByText(/Cancelled/i)).toBeTruthy();
53+
});
54+
4855
it('DetailsHeader renders the failed state', () => {
4956
const { queryByText } = renderWithIntl(
5057
<DetailsHeader {...props} status="terminated" />

packages/components/src/components/Step/Step.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ class Step extends Component {
5757
statusLabel() {
5858
const { intl, reason, status } = this.props;
5959

60-
if (status === 'cancelled') {
60+
if (
61+
status === 'cancelled' ||
62+
(status === 'terminated' && reason === 'TaskRunCancelled')
63+
) {
6164
return intl.formatMessage({
6265
id: 'dashboard.taskRun.status.cancelled',
6366
defaultMessage: 'Cancelled'

packages/components/src/components/Step/Step.scss

+11-8
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,17 @@ limitations under the License.
112112
font-weight: bold;
113113
}
114114
}
115-
&[data-status='cancelled'] > a.tkn--step-link {
116-
opacity: 1;
117-
.tkn--step-icon {
118-
fill: $failed;
119-
}
120-
.tkn--status-label {
121-
color: $failed;
122-
font-weight: bold;
115+
&[data-status='cancelled'],
116+
&[data-status='terminated'][data-reason='TaskRunCancelled'] {
117+
> a.tkn--step-link {
118+
opacity: 1;
119+
.tkn--step-icon {
120+
fill: $failed;
121+
}
122+
.tkn--status-label {
123+
color: $failed;
124+
font-weight: bold;
125+
}
123126
}
124127
}
125128
}

packages/components/src/components/Step/Step.test.js

+7
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ it('Step renders cancelled state', () => {
4747
expect(queryByText(/Cancelled/i)).toBeTruthy();
4848
});
4949

50+
it('Step renders cancelled state with status terminated', () => {
51+
const { queryByText } = renderWithIntl(
52+
<Step status="terminated" reason="TaskRunCancelled" />
53+
);
54+
expect(queryByText(/Cancelled/i)).toBeTruthy();
55+
});
56+
5057
it('Step renders completed state', () => {
5158
const { queryByText } = renderWithIntl(
5259
<Step status="terminated" reason="Completed" />

0 commit comments

Comments
 (0)