From d2bec63cecbc39f1881a883d36b6a2c3ea1568a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milorad=20FIlipovi=C4=87?= Date: Tue, 8 Nov 2022 18:05:50 +0100 Subject: [PATCH] fix(editor): Fix workflow activation from the Workflows view (#4549) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🐛 Fixing a bug when activating workflow from workflows view --- packages/editor-ui/src/Interface.ts | 2 +- packages/editor-ui/src/components/WorkflowActivator.vue | 2 +- packages/editor-ui/src/components/WorkflowCard.vue | 1 + packages/editor-ui/src/components/WorkflowSettings.vue | 2 +- .../editor-ui/src/components/mixins/workflowHelpers.ts | 8 ++++---- packages/editor-ui/src/stores/workflows.ts | 7 +++++++ packages/editor-ui/src/views/NodeView.vue | 2 +- 7 files changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/editor-ui/src/Interface.ts b/packages/editor-ui/src/Interface.ts index 03d113d93e..5b41b9b9ec 100644 --- a/packages/editor-ui/src/Interface.ts +++ b/packages/editor-ui/src/Interface.ts @@ -319,7 +319,7 @@ export interface IWorkflowDb { pinData?: IPinData; sharedWith?: Array>; ownedBy?: Partial; - hash?: string; + hash: string; } // Identical to cli.Interfaces.ts diff --git a/packages/editor-ui/src/components/WorkflowActivator.vue b/packages/editor-ui/src/components/WorkflowActivator.vue index 1e19cecf3b..28258e0f02 100644 --- a/packages/editor-ui/src/components/WorkflowActivator.vue +++ b/packages/editor-ui/src/components/WorkflowActivator.vue @@ -94,7 +94,7 @@ export default mixins( }, methods: { async activeChanged (newActiveState: boolean) { - return this.updateWorkflowActivation(this.workflowId, newActiveState); + return await this.updateWorkflowActivation(this.workflowId, newActiveState); }, async displayActivationError () { let errorMessage: string; diff --git a/packages/editor-ui/src/components/WorkflowCard.vue b/packages/editor-ui/src/components/WorkflowCard.vue index 8e0f7c8063..0917b10b40 100644 --- a/packages/editor-ui/src/components/WorkflowCard.vue +++ b/packages/editor-ui/src/components/WorkflowCard.vue @@ -100,6 +100,7 @@ export default mixins( name: '', sharedWith: [], ownedBy: {} as IUser, + hash: '', }), }, readonly: { diff --git a/packages/editor-ui/src/components/WorkflowSettings.vue b/packages/editor-ui/src/components/WorkflowSettings.vue index 7555261078..4f3371ca60 100644 --- a/packages/editor-ui/src/components/WorkflowSettings.vue +++ b/packages/editor-ui/src/components/WorkflowSettings.vue @@ -611,7 +611,7 @@ export default mixins( try { const workflow = await this.restApi().updateWorkflow(this.$route.params.name, data); - this.workflowsStore.setWorkflowHash(workflow.hash || ''); + this.workflowsStore.setWorkflowHash(workflow.hash); } catch (error) { this.$showError( error, diff --git a/packages/editor-ui/src/components/mixins/workflowHelpers.ts b/packages/editor-ui/src/components/mixins/workflowHelpers.ts index e8136f6d27..68c2c9b3d4 100644 --- a/packages/editor-ui/src/components/mixins/workflowHelpers.ts +++ b/packages/editor-ui/src/components/mixins/workflowHelpers.ts @@ -681,7 +681,7 @@ export const workflowHelpers = mixins( data = await this.getWorkflowDataToSave(); } else { const { hash } = await this.restApi().getWorkflow(workflowId); - data.hash = hash as string; + data.hash = hash; } if (active !== undefined) { @@ -689,7 +689,7 @@ export const workflowHelpers = mixins( } const workflow = await this.restApi().updateWorkflow(workflowId, data); - this.workflowsStore.setWorkflowHash(workflow.hash || ''); + this.workflowsStore.setWorkflowHash(workflow.hash); if (isCurrentWorkflow) { this.workflowsStore.setActive(!!workflow.active); @@ -727,7 +727,7 @@ export const workflowHelpers = mixins( workflowDataRequest.hash = this.workflowsStore.workflowHash; const workflowData = await this.restApi().updateWorkflow(currentWorkflow, workflowDataRequest); - this.workflowsStore.setWorkflowHash(workflowData.hash || ''); + this.workflowsStore.setWorkflowHash(workflowData.hash); if (name) { this.workflowsStore.setWorkflowName({newName: workflowData.name, setStateDirty: false}); @@ -794,7 +794,7 @@ export const workflowHelpers = mixins( const workflowData = await this.restApi().createNewWorkflow(workflowDataRequest); this.workflowsStore.addWorkflow(workflowData); - this.workflowsStore.setWorkflowHash(workflowData.hash || ''); + this.workflowsStore.setWorkflowHash(workflowData.hash); if (openInNewWindow) { const routeData = this.$router.resolve({name: VIEWS.WORKFLOW, params: {name: workflowData.id}}); diff --git a/packages/editor-ui/src/stores/workflows.ts b/packages/editor-ui/src/stores/workflows.ts index 53c7c06d4c..60e77fee9b 100644 --- a/packages/editor-ui/src/stores/workflows.ts +++ b/packages/editor-ui/src/stores/workflows.ts @@ -287,6 +287,10 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, { if (index === -1) { this.activeWorkflows.push(workflowId); } + if (this.workflowsById[workflowId]) { + this.workflowsById[workflowId].active = true; + } + }, setWorkflowInactive(workflowId: string): void { @@ -294,6 +298,9 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, { if (index !== -1) { this.activeWorkflows.splice(index, 1); } + if (this.workflowsById[workflowId]) { + this.workflowsById[workflowId].active = false; + } }, async fetchActiveWorkflows(): Promise { diff --git a/packages/editor-ui/src/views/NodeView.vue b/packages/editor-ui/src/views/NodeView.vue index 1fea690c8a..27d49ba2ee 100644 --- a/packages/editor-ui/src/views/NodeView.vue +++ b/packages/editor-ui/src/views/NodeView.vue @@ -813,7 +813,7 @@ export default mixins( this.workflowsStore.setWorkflowName({ newName: data.name, setStateDirty: false }); this.workflowsStore.setWorkflowSettings(data.settings || {}); this.workflowsStore.setWorkflowPinData(data.pinData || {}); - this.workflowsStore.setWorkflowHash(data.hash || ''); + this.workflowsStore.setWorkflowHash(data.hash); const tags = (data.tags || []) as ITag[]; const tagIds = tags.map((tag) => tag.id);