Skip to content

Commit 92f6cbf

Browse files
authored
fix(editor): Fix displaying logic of execution retry button (#9061)
1 parent 610ead9 commit 92f6cbf

File tree

5 files changed

+94
-12
lines changed

5 files changed

+94
-12
lines changed

packages/editor-ui/src/components/ExecutionsList.vue

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -894,15 +894,6 @@ export default defineComponent({
894894
this.showError(error, this.i18n.baseText('executionsList.showError.stopExecution.title'));
895895
}
896896
},
897-
isExecutionRetriable(execution: ExecutionSummary): boolean {
898-
return (
899-
execution.stoppedAt !== undefined &&
900-
!execution.finished &&
901-
execution.retryOf === undefined &&
902-
execution.retrySuccessId === undefined &&
903-
!execution.waitTill
904-
);
905-
},
906897
async deleteExecution(execution: ExecutionSummary) {
907898
this.isDataLoading = true;
908899
try {
@@ -1160,6 +1151,7 @@ export default defineComponent({
11601151
background: var(--execution-card-border-waiting);
11611152
}
11621153
1154+
&.canceled td:first-child::before,
11631155
&.unknown td:first-child::before {
11641156
background: var(--execution-card-border-unknown);
11651157
}

packages/editor-ui/src/components/ExecutionsView/ExecutionCard.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
</div>
6060
<div :class="$style.icons">
6161
<n8n-action-dropdown
62-
v-if="executionUIDetails.name === 'error'"
62+
v-if="isRetriable"
6363
:class="[$style.icon, $style.retry]"
6464
:items="retryExecutionActions"
6565
activator-icon="redo"
@@ -83,7 +83,7 @@
8383

8484
<script lang="ts">
8585
import { defineComponent } from 'vue';
86-
import type { ExecutionSummary } from '@/Interface';
86+
import type { ExecutionSummary } from 'n8n-workflow';
8787
import type { IExecutionUIData } from '@/mixins/executionsHelpers';
8888
import { executionHelpers } from '@/mixins/executionsHelpers';
8989
import { VIEWS } from '@/constants';
@@ -133,6 +133,9 @@ export default defineComponent({
133133
isActive(): boolean {
134134
return this.execution.id === this.$route.params.executionId;
135135
},
136+
isRetriable(): boolean {
137+
return this.isExecutionRetriable(this.execution);
138+
},
136139
},
137140
methods: {
138141
onRetryMenuItemSelect(action: string): void {

packages/editor-ui/src/components/ExecutionsView/ExecutionPreview.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
</n8n-button>
9797

9898
<ElDropdown
99-
v-if="executionUIDetails?.name === 'error'"
99+
v-if="isRetriable"
100100
ref="retryDropdown"
101101
trigger="click"
102102
class="mr-xs"
@@ -190,6 +190,9 @@ export default defineComponent({
190190
type: 'primary',
191191
};
192192
},
193+
isRetriable(): boolean {
194+
return !!this.activeExecution && this.isExecutionRetriable(this.activeExecution);
195+
},
193196
},
194197
methods: {
195198
async onDeleteExecution(): Promise<void> {
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import { createComponentRenderer } from '@/__tests__/render';
2+
import ExecutionCard from '@/components/ExecutionsView/ExecutionCard.vue';
3+
import { createPinia, setActivePinia } from 'pinia';
4+
5+
const renderComponent = createComponentRenderer(ExecutionCard, {
6+
global: {
7+
stubs: {
8+
'router-link': {
9+
template: '<div><slot /></div>',
10+
},
11+
},
12+
mocks: {
13+
$route: {
14+
params: {},
15+
},
16+
},
17+
},
18+
});
19+
20+
describe('ExecutionCard', () => {
21+
beforeEach(() => {
22+
setActivePinia(createPinia());
23+
});
24+
25+
test.each([
26+
[
27+
{
28+
id: '1',
29+
mode: 'manual',
30+
status: 'success',
31+
retryOf: null,
32+
retrySuccessId: null,
33+
},
34+
false,
35+
],
36+
[
37+
{
38+
id: '2',
39+
mode: 'manual',
40+
status: 'error',
41+
retryOf: null,
42+
retrySuccessId: null,
43+
},
44+
true,
45+
],
46+
[
47+
{
48+
id: '3',
49+
mode: 'manual',
50+
status: 'error',
51+
retryOf: '2',
52+
retrySuccessId: null,
53+
},
54+
false,
55+
],
56+
[
57+
{
58+
id: '4',
59+
mode: 'manual',
60+
status: 'error',
61+
retryOf: null,
62+
retrySuccessId: '3',
63+
},
64+
false,
65+
],
66+
])('with execution %j retry button visibility is %s', (execution, shouldRenderRetryBtn) => {
67+
const { queryByTestId } = renderComponent({
68+
props: {
69+
execution,
70+
},
71+
});
72+
73+
expect(!!queryByTestId('retry-execution-button') && shouldRenderRetryBtn).toBe(
74+
shouldRenderRetryBtn,
75+
);
76+
});
77+
});

packages/editor-ui/src/mixins/executionsHelpers.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,12 @@ export const executionHelpers = defineComponent({
7474
const { date, time } = convertToDisplayDate(fullDate);
7575
return locale.baseText('executionsList.started', { interpolate: { time, date } });
7676
},
77+
isExecutionRetriable(execution: ExecutionSummary): boolean {
78+
return (
79+
['crashed', 'error'].includes(execution.status ?? '') &&
80+
!execution.retryOf &&
81+
!execution.retrySuccessId
82+
);
83+
},
7784
},
7885
});

0 commit comments

Comments
 (0)