From c213d5464d8b346e9e1b92740e6d1a571ac990c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Fri, 7 Jun 2024 15:20:31 +0200 Subject: [PATCH] refactor(editor): Stop expecting `null` execution status (no-changelog) --- packages/cli/src/Interfaces.ts | 2 +- packages/editor-ui/src/Interface.ts | 2 +- .../global/GlobalExecutionsListItem.vue | 2 +- .../src/composables/useExecutionHelpers.ts | 2 +- .../editor-ui/src/stores/executions.store.ts | 23 +------------------ packages/editor-ui/src/utils/apiUtils.ts | 6 ++--- packages/workflow/src/Interfaces.ts | 2 +- 7 files changed, 8 insertions(+), 31 deletions(-) diff --git a/packages/cli/src/Interfaces.ts b/packages/cli/src/Interfaces.ts index 9a6cffd782a22..11d0ea6cd5528 100644 --- a/packages/cli/src/Interfaces.ts +++ b/packages/cli/src/Interfaces.ts @@ -185,7 +185,7 @@ export interface IExecutionsCurrentSummary { startedAt: Date; mode: WorkflowExecuteMode; workflowId: string; - status?: ExecutionStatus; + status: ExecutionStatus; } export interface IExecutingWorkflowData { diff --git a/packages/editor-ui/src/Interface.ts b/packages/editor-ui/src/Interface.ts index ab2afde49d497..6687919ea25d4 100644 --- a/packages/editor-ui/src/Interface.ts +++ b/packages/editor-ui/src/Interface.ts @@ -381,6 +381,7 @@ export interface IExecutionBase { id?: string; finished: boolean; mode: WorkflowExecuteMode; + status: ExecutionStatus; retryOf?: string; retrySuccessId?: string; startedAt: Date; @@ -404,7 +405,6 @@ export interface IExecutionPushResponse { export interface IExecutionResponse extends IExecutionBase { id: string; - status: string; data?: IRunExecutionData; workflowData: IWorkflowDb; executedNode?: string; diff --git a/packages/editor-ui/src/components/executions/global/GlobalExecutionsListItem.vue b/packages/editor-ui/src/components/executions/global/GlobalExecutionsListItem.vue index 82c690ed4677d..c2049050a7500 100644 --- a/packages/editor-ui/src/components/executions/global/GlobalExecutionsListItem.vue +++ b/packages/editor-ui/src/components/executions/global/GlobalExecutionsListItem.vue @@ -51,7 +51,7 @@ const isRetriable = computed(() => executionHelpers.isExecutionRetriable(props.e const classes = computed(() => { return { [style.executionListItem]: true, - [style[props.execution.status ?? '']]: !!props.execution.status, + [style[props.execution.status]]: true, }; }); diff --git a/packages/editor-ui/src/composables/useExecutionHelpers.ts b/packages/editor-ui/src/composables/useExecutionHelpers.ts index 47f74ecf6c56c..b39e03c5c1df0 100644 --- a/packages/editor-ui/src/composables/useExecutionHelpers.ts +++ b/packages/editor-ui/src/composables/useExecutionHelpers.ts @@ -56,7 +56,7 @@ export function useExecutionHelpers() { function isExecutionRetriable(execution: ExecutionSummary): boolean { return ( - ['crashed', 'error'].includes(execution.status ?? '') && + ['crashed', 'error'].includes(execution.status) && !execution.retryOf && !execution.retrySuccessId ); diff --git a/packages/editor-ui/src/stores/executions.store.ts b/packages/editor-ui/src/stores/executions.store.ts index 95b4247f53dcf..bdbe4b32ceb9f 100644 --- a/packages/editor-ui/src/stores/executions.store.ts +++ b/packages/editor-ui/src/stores/executions.store.ts @@ -1,6 +1,6 @@ import { defineStore } from 'pinia'; import { computed, ref } from 'vue'; -import type { ExecutionStatus, IDataObject, ExecutionSummary } from 'n8n-workflow'; +import type { IDataObject, ExecutionSummary } from 'n8n-workflow'; import type { ExecutionFilterType, ExecutionsQueryFilter, @@ -83,7 +83,6 @@ export const useExecutionsStore = defineStore('executions', () => { function addExecution(execution: ExecutionSummary) { executionsById.value[execution.id] = { ...execution, - status: execution.status ?? getExecutionStatus(execution), mode: execution.mode, }; } @@ -91,7 +90,6 @@ export const useExecutionsStore = defineStore('executions', () => { function addCurrentExecution(execution: ExecutionSummary) { currentExecutionsById.value[execution.id] = { ...execution, - status: execution.status ?? getExecutionStatus(execution), mode: execution.mode, }; } @@ -113,24 +111,6 @@ export const useExecutionsStore = defineStore('executions', () => { await startAutoRefreshInterval(workflowId); } - function getExecutionStatus(execution: ExecutionSummary): ExecutionStatus { - if (execution.status) { - return execution.status; - } else { - if (execution.waitTill) { - return 'waiting'; - } else if (execution.stoppedAt === undefined) { - return 'running'; - } else if (execution.finished) { - return 'success'; - } else if (execution.stoppedAt !== null) { - return 'error'; - } else { - return 'unknown'; - } - } - } - async function fetchExecutions( filter = executionsFilters.value, lastId?: string, @@ -274,7 +254,6 @@ export const useExecutionsStore = defineStore('executions', () => { activeExecution, fetchExecutions, fetchExecution, - getExecutionStatus, autoRefresh, autoRefreshTimeout, startAutoRefreshInterval, diff --git a/packages/editor-ui/src/utils/apiUtils.ts b/packages/editor-ui/src/utils/apiUtils.ts index 5c66c87daefae..686d4a27dbe1f 100644 --- a/packages/editor-ui/src/utils/apiUtils.ts +++ b/packages/editor-ui/src/utils/apiUtils.ts @@ -175,11 +175,9 @@ export async function patch( * * @param {IExecutionFlattedResponse} fullExecutionData The data to unflatten */ -export function unflattenExecutionData( - fullExecutionData: IExecutionFlattedResponse, -): Omit { +export function unflattenExecutionData(fullExecutionData: IExecutionFlattedResponse) { // Unflatten the data - const returnData: Omit = { + const returnData: IExecutionResponse = { ...fullExecutionData, workflowData: fullExecutionData.workflowData, data: parse(fullExecutionData.data), diff --git a/packages/workflow/src/Interfaces.ts b/packages/workflow/src/Interfaces.ts index 1e356d0d136c5..e78179e2698da 100644 --- a/packages/workflow/src/Interfaces.ts +++ b/packages/workflow/src/Interfaces.ts @@ -2371,7 +2371,7 @@ export interface ExecutionSummary { stoppedAt?: Date; workflowId: string; workflowName?: string; - status?: ExecutionStatus; + status: ExecutionStatus; lastNodeExecuted?: string; executionError?: ExecutionError; nodeExecutionStatus?: {