From dbac7955f94007a8b305400ae28ccf1e5c040261 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milorad=20FIlipovi=C4=87?= Date: Fri, 28 Oct 2022 09:54:01 +0200 Subject: [PATCH] fix(editor): fix for executions view auto-refresh and new workflow saving (#4462) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🐛 Fixing auto-refresh and save workflow bugs. Added executions filtering based on current workflow settings * ✔️ Fixing a lint error --- .../ExecutionsView/ExecutionsView.vue | 20 ++++++++++++++++++- .../src/components/mixins/workflowHelpers.ts | 2 +- packages/editor-ui/src/modules/workflows.ts | 1 - 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/editor-ui/src/components/ExecutionsView/ExecutionsView.vue b/packages/editor-ui/src/components/ExecutionsView/ExecutionsView.vue index ed70cb007..bf19c41bb 100644 --- a/packages/editor-ui/src/components/ExecutionsView/ExecutionsView.vue +++ b/packages/editor-ui/src/components/ExecutionsView/ExecutionsView.vue @@ -9,6 +9,7 @@ @filterUpdated="onFilterUpdated" @loadMore="loadMore" @retryExecution="onRetryExecution" + @refresh="loadAutoRefresh" />
@@ -25,7 +26,7 @@ import ExecutionsSidebar from '@/components/ExecutionsView/ExecutionsSidebar.vue'; import { MODAL_CANCEL, MODAL_CLOSE, MODAL_CONFIRMED, PLACEHOLDER_EMPTY_WORKFLOW_ID, VIEWS, WEBHOOK_NODE_TYPE } from '@/constants'; import { IExecutionsListResponse, IExecutionsSummary, INodeUi, ITag, IWorkflowDb } from '@/Interface'; -import { IConnection, IConnections, IDataObject, INodeTypeDescription, INodeTypeNameVersion, NodeHelpers } from 'n8n-workflow'; +import { IConnection, IConnections, IDataObject, INodeTypeDescription, INodeTypeNameVersion, IWorkflowSettings, NodeHelpers } from 'n8n-workflow'; import mixins from 'vue-typed-mixins'; import { restApi } from '../mixins/restApi'; import { showMessage } from '../mixins/showMessage'; @@ -73,6 +74,11 @@ export default mixins(restApi, showMessage, executionHelpers, debounceHelper, wo totalFinishedExecutionsCount(): number { return this.$store.getters['workflows/getTotalFinishedExecutionsCount']; }, + isWorkflowSavingManualExecutions(): boolean { + const workflowSettings: IWorkflowSettings = this.$store.getters.workflowSettings; + const saveManualExecutionsDefault = this.$store.getters.saveManualExecutions; + return workflowSettings.saveManualExecutions === undefined ? saveManualExecutionsDefault: workflowSettings.saveManualExecutions as boolean; + }, }, watch:{ $route (to: Route, from: Route) { @@ -242,6 +248,7 @@ export default mixins(restApi, showMessage, executionHelpers, debounceHelper, wo const alreadyPresentExecutionIds = existingExecutions.map(exec => parseInt(exec.id, 10)); let lastId = 0; const gaps = [] as number[]; + let updatedActiveExecution = null; for(let i = fetchedExecutions.length - 1; i >= 0; i--) { const currentItem = fetchedExecutions[i]; @@ -262,6 +269,9 @@ export default mixins(restApi, showMessage, executionHelpers, debounceHelper, wo if (existingStillRunning && currentFinished) { existingExecutions[executionIndex] = currentItem; + if (currentItem.id === this.activeExecution.id) { + updatedActiveExecution = currentItem; + } } continue; } @@ -280,6 +290,9 @@ export default mixins(restApi, showMessage, executionHelpers, debounceHelper, wo existingExecutions = existingExecutions.filter(execution => !gaps.includes(parseInt(execution.id, 10)) && lastId >= parseInt(execution.id, 10)); this.$store.commit('workflows/setCurrentWorkflowExecutions', existingExecutions); + if (updatedActiveExecution !== null) { + this.$store.commit('workflows/setActiveWorkflowExecution', updatedActiveExecution); + } }, async loadExecutions(): Promise { if (!this.currentWorkflow) { @@ -288,6 +301,11 @@ export default mixins(restApi, showMessage, executionHelpers, debounceHelper, wo try { const executions: IExecutionsSummary[] = await this.$store.dispatch('workflows/loadCurrentWorkflowExecutions', this.filter); + + // Don't show running manual executions if workflow is set up not to save them + if (!this.isWorkflowSavingManualExecutions) { + return executions.filter(ex => ex.finished === true || ex.mode !== 'manual'); + } return executions; } catch (error) { this.$showError( diff --git a/packages/editor-ui/src/components/mixins/workflowHelpers.ts b/packages/editor-ui/src/components/mixins/workflowHelpers.ts index 79be40db5..fa72b6511 100644 --- a/packages/editor-ui/src/components/mixins/workflowHelpers.ts +++ b/packages/editor-ui/src/components/mixins/workflowHelpers.ts @@ -683,7 +683,7 @@ export const workflowHelpers = mixins( async saveCurrentWorkflow({id, name, tags}: {id?: string, name?: string, tags?: string[]} = {}, redirect = true): Promise { const currentWorkflow = id || this.$route.params.name; - if (!currentWorkflow) { + if (!currentWorkflow || ['new', PLACEHOLDER_EMPTY_WORKFLOW_ID].includes(currentWorkflow)) { return this.saveAsNewWorkflow({name, tags}, redirect); } diff --git a/packages/editor-ui/src/modules/workflows.ts b/packages/editor-ui/src/modules/workflows.ts index 2f7fcd23c..5fdd05ece 100644 --- a/packages/editor-ui/src/modules/workflows.ts +++ b/packages/editor-ui/src/modules/workflows.ts @@ -1,4 +1,3 @@ -import { makeRestApiRequest } from '@/api/helpers'; import { getCurrentExecutions, getFinishedExecutions, getNewWorkflow } from '@/api/workflows'; import { DUPLICATE_POSTFFIX, MAX_WORKFLOW_NAME_LENGTH, DEFAULT_NEW_WORKFLOW_NAME } from '@/constants'; import { IDataObject } from 'n8n-workflow';