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

fix(editor): Fix displaying logic of execution retry button #9061

Merged
Show file tree
Hide file tree
Changes from 5 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
10 changes: 1 addition & 9 deletions packages/editor-ui/src/components/ExecutionsList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -894,15 +894,6 @@ export default defineComponent({
this.showError(error, this.i18n.baseText('executionsList.showError.stopExecution.title'));
}
},
isExecutionRetriable(execution: ExecutionSummary): boolean {
return (
execution.stoppedAt !== undefined &&
!execution.finished &&
execution.retryOf === undefined &&
execution.retrySuccessId === undefined &&
!execution.waitTill
);
},
async deleteExecution(execution: ExecutionSummary) {
this.isDataLoading = true;
try {
Expand Down Expand Up @@ -1160,6 +1151,7 @@ export default defineComponent({
background: var(--execution-card-border-waiting);
}

&.canceled td:first-child::before,
&.unknown td:first-child::before {
background: var(--execution-card-border-unknown);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
</div>
<div :class="$style.icons">
<n8n-action-dropdown
v-if="executionUIDetails.name === 'error'"
v-if="isExecutionRetriable(execution)"
:class="[$style.icon, $style.retry]"
:items="retryExecutionActions"
activator-icon="redo"
Expand All @@ -83,7 +83,7 @@

<script lang="ts">
import { defineComponent } from 'vue';
import type { ExecutionSummary } from '@/Interface';
import type { ExecutionSummary } from 'n8n-workflow';
import type { IExecutionUIData } from '@/mixins/executionsHelpers';
import { executionHelpers } from '@/mixins/executionsHelpers';
import { VIEWS } from '@/constants';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { createComponentRenderer } from '@/__tests__/render';
import ExecutionCard from '@/components/ExecutionsView/ExecutionCard.vue';
import { createPinia, setActivePinia } from 'pinia';

const renderComponent = createComponentRenderer(ExecutionCard, {
global: {
stubs: {
'router-link': {
template: '<div><slot /></div>',
},
},
mocks: {
$route: {
params: {},
},
},
},
});

describe('ExecutionCard', () => {
beforeEach(() => {
setActivePinia(createPinia());
});

test.each([
[
{
id: '1',
mode: 'manual',
status: 'success',
retryOf: null,
retrySuccessId: null,
},
false,
],
[
{
id: '2',
mode: 'manual',
status: 'error',
retryOf: null,
retrySuccessId: null,
},
true,
],
[
{
id: '3',
mode: 'manual',
status: 'error',
retryOf: '2',
retrySuccessId: null,
},
false,
],
[
{
id: '4',
mode: 'manual',
status: 'error',
retryOf: null,
retrySuccessId: '3',
},
false,
],
])('with execution %j retry button visibility is %s', (execution, shouldRenderRetryBtn) => {
const { queryByTestId } = renderComponent({
props: {
execution,
},
});

expect(!!queryByTestId('retry-execution-button') && shouldRenderRetryBtn).toBe(
shouldRenderRetryBtn,
);
});
});
7 changes: 7 additions & 0 deletions packages/editor-ui/src/mixins/executionsHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,12 @@ export const executionHelpers = defineComponent({
const { date, time } = convertToDisplayDate(fullDate);
return locale.baseText('executionsList.started', { interpolate: { time, date } });
},
isExecutionRetriable(execution: ExecutionSummary): boolean {
return (
['crashed', 'error'].includes(execution.status ?? '') &&
!execution.retryOf &&
!execution.retrySuccessId
);
},
},
});
Loading