Skip to content

Commit

Permalink
fix(editor): Fix workflow activation from the Workflows view (#4549)
Browse files Browse the repository at this point in the history
🐛 Fixing a bug when activating workflow from workflows view
  • Loading branch information
MiloradFilipovic authored Nov 8, 2022
1 parent 026fb50 commit d2bec63
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/editor-ui/src/Interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ export interface IWorkflowDb {
pinData?: IPinData;
sharedWith?: Array<Partial<IUser>>;
ownedBy?: Partial<IUser>;
hash?: string;
hash: string;
}

// Identical to cli.Interfaces.ts
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/components/WorkflowActivator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions packages/editor-ui/src/components/WorkflowCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export default mixins(
name: '',
sharedWith: [],
ownedBy: {} as IUser,
hash: '',
}),
},
readonly: {
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/components/WorkflowSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions packages/editor-ui/src/components/mixins/workflowHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -681,15 +681,15 @@ 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) {
data.active = active;
}

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);
Expand Down Expand Up @@ -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});
Expand Down Expand Up @@ -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}});
Expand Down
7 changes: 7 additions & 0 deletions packages/editor-ui/src/stores/workflows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,20 @@ 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 {
const index = this.activeWorkflows.indexOf(workflowId);
if (index !== -1) {
this.activeWorkflows.splice(index, 1);
}
if (this.workflowsById[workflowId]) {
this.workflowsById[workflowId].active = false;
}
},

async fetchActiveWorkflows(): Promise<string[]> {
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/views/NodeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d2bec63

Please sign in to comment.