Skip to content

Commit dbac795

Browse files
fix(editor): fix for executions view auto-refresh and new workflow saving (#4462)
* 🐛 Fixing auto-refresh and save workflow bugs. Added executions filtering based on current workflow settings * ✔️ Fixing a lint error
1 parent c66929f commit dbac795

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

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

+19-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
@filterUpdated="onFilterUpdated"
1010
@loadMore="loadMore"
1111
@retryExecution="onRetryExecution"
12+
@refresh="loadAutoRefresh"
1213
/>
1314
<div :class="$style.content" v-if="!hidePreview">
1415
<router-view name="executionPreview" @deleteCurrentExecution="onDeleteCurrentExecution" @retryExecution="onRetryExecution"/>
@@ -25,7 +26,7 @@
2526
import ExecutionsSidebar from '@/components/ExecutionsView/ExecutionsSidebar.vue';
2627
import { MODAL_CANCEL, MODAL_CLOSE, MODAL_CONFIRMED, PLACEHOLDER_EMPTY_WORKFLOW_ID, VIEWS, WEBHOOK_NODE_TYPE } from '@/constants';
2728
import { IExecutionsListResponse, IExecutionsSummary, INodeUi, ITag, IWorkflowDb } from '@/Interface';
28-
import { IConnection, IConnections, IDataObject, INodeTypeDescription, INodeTypeNameVersion, NodeHelpers } from 'n8n-workflow';
29+
import { IConnection, IConnections, IDataObject, INodeTypeDescription, INodeTypeNameVersion, IWorkflowSettings, NodeHelpers } from 'n8n-workflow';
2930
import mixins from 'vue-typed-mixins';
3031
import { restApi } from '../mixins/restApi';
3132
import { showMessage } from '../mixins/showMessage';
@@ -73,6 +74,11 @@ export default mixins(restApi, showMessage, executionHelpers, debounceHelper, wo
7374
totalFinishedExecutionsCount(): number {
7475
return this.$store.getters['workflows/getTotalFinishedExecutionsCount'];
7576
},
77+
isWorkflowSavingManualExecutions(): boolean {
78+
const workflowSettings: IWorkflowSettings = this.$store.getters.workflowSettings;
79+
const saveManualExecutionsDefault = this.$store.getters.saveManualExecutions;
80+
return workflowSettings.saveManualExecutions === undefined ? saveManualExecutionsDefault: workflowSettings.saveManualExecutions as boolean;
81+
},
7682
},
7783
watch:{
7884
$route (to: Route, from: Route) {
@@ -242,6 +248,7 @@ export default mixins(restApi, showMessage, executionHelpers, debounceHelper, wo
242248
const alreadyPresentExecutionIds = existingExecutions.map(exec => parseInt(exec.id, 10));
243249
let lastId = 0;
244250
const gaps = [] as number[];
251+
let updatedActiveExecution = null;
245252
246253
for(let i = fetchedExecutions.length - 1; i >= 0; i--) {
247254
const currentItem = fetchedExecutions[i];
@@ -262,6 +269,9 @@ export default mixins(restApi, showMessage, executionHelpers, debounceHelper, wo
262269
263270
if (existingStillRunning && currentFinished) {
264271
existingExecutions[executionIndex] = currentItem;
272+
if (currentItem.id === this.activeExecution.id) {
273+
updatedActiveExecution = currentItem;
274+
}
265275
}
266276
continue;
267277
}
@@ -280,6 +290,9 @@ export default mixins(restApi, showMessage, executionHelpers, debounceHelper, wo
280290
281291
existingExecutions = existingExecutions.filter(execution => !gaps.includes(parseInt(execution.id, 10)) && lastId >= parseInt(execution.id, 10));
282292
this.$store.commit('workflows/setCurrentWorkflowExecutions', existingExecutions);
293+
if (updatedActiveExecution !== null) {
294+
this.$store.commit('workflows/setActiveWorkflowExecution', updatedActiveExecution);
295+
}
283296
},
284297
async loadExecutions(): Promise<IExecutionsSummary[]> {
285298
if (!this.currentWorkflow) {
@@ -288,6 +301,11 @@ export default mixins(restApi, showMessage, executionHelpers, debounceHelper, wo
288301
try {
289302
const executions: IExecutionsSummary[] =
290303
await this.$store.dispatch('workflows/loadCurrentWorkflowExecutions', this.filter);
304+
305+
// Don't show running manual executions if workflow is set up not to save them
306+
if (!this.isWorkflowSavingManualExecutions) {
307+
return executions.filter(ex => ex.finished === true || ex.mode !== 'manual');
308+
}
291309
return executions;
292310
} catch (error) {
293311
this.$showError(

packages/editor-ui/src/components/mixins/workflowHelpers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ export const workflowHelpers = mixins(
683683
async saveCurrentWorkflow({id, name, tags}: {id?: string, name?: string, tags?: string[]} = {}, redirect = true): Promise<boolean> {
684684
const currentWorkflow = id || this.$route.params.name;
685685

686-
if (!currentWorkflow) {
686+
if (!currentWorkflow || ['new', PLACEHOLDER_EMPTY_WORKFLOW_ID].includes(currentWorkflow)) {
687687
return this.saveAsNewWorkflow({name, tags}, redirect);
688688
}
689689

packages/editor-ui/src/modules/workflows.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { makeRestApiRequest } from '@/api/helpers';
21
import { getCurrentExecutions, getFinishedExecutions, getNewWorkflow } from '@/api/workflows';
32
import { DUPLICATE_POSTFFIX, MAX_WORKFLOW_NAME_LENGTH, DEFAULT_NEW_WORKFLOW_NAME } from '@/constants';
43
import { IDataObject } from 'n8n-workflow';

0 commit comments

Comments
 (0)