mirror of
https://github.com/n8n-io/n8n.git
synced 2026-09-24 23:22:38 +08:00
chore(editor): Refactor wf checksum setting (no-changelog) (#23039)
This commit is contained in:
@@ -301,20 +301,12 @@ export async function createActiveWorkflow(
|
||||
const workflow = await createWorkflowWithTriggerAndHistory(
|
||||
{ active: true, ...attributes },
|
||||
userOrProject,
|
||||
{},
|
||||
);
|
||||
|
||||
await setActiveVersion(workflow.id, workflow.versionId);
|
||||
|
||||
workflow.activeVersionId = workflow.versionId;
|
||||
|
||||
if (userOrProject instanceof User) {
|
||||
await Container.get(WorkflowPublishHistoryRepository).save({
|
||||
workflowId: workflow.id,
|
||||
versionId: workflow.versionId,
|
||||
event: 'activated',
|
||||
userId: userOrProject.id,
|
||||
});
|
||||
}
|
||||
|
||||
return workflow;
|
||||
}
|
||||
|
||||
@@ -211,6 +211,7 @@ export function createTestWorkflow({
|
||||
activeVersionId: active ? 'v1' : null,
|
||||
meta: {},
|
||||
pinData,
|
||||
checksum: 'checksum',
|
||||
...rest,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -481,11 +481,7 @@ const saveSettings = async () => {
|
||||
data.expectedChecksum = workflowsStore.workflowChecksum;
|
||||
|
||||
try {
|
||||
const workflowData = await workflowsStore.updateWorkflow(String(route.params.name), data);
|
||||
workflowsStore.setWorkflowVersionId(workflowData.versionId);
|
||||
if (workflowData.checksum) {
|
||||
workflowsStore.setWorkflowChecksum(workflowData.checksum);
|
||||
}
|
||||
await workflowsStore.updateWorkflow(String(route.params.name), data);
|
||||
} catch (error) {
|
||||
toast.showError(error, i18n.baseText('workflowSettings.showError.saveSettings3.title'));
|
||||
isLoading.value = false;
|
||||
|
||||
+6
-13
@@ -2,13 +2,10 @@ import type { WorkflowActivated } from '@n8n/api-types/push/workflow';
|
||||
import { useWorkflowsStore } from '@/app/stores/workflows.store';
|
||||
import { useBannersStore } from '@/features/shared/banners/banners.store';
|
||||
import { useUIStore } from '@/app/stores/ui.store';
|
||||
import { getWorkflowVersion } from '@n8n/rest-api-client';
|
||||
import { useRootStore } from '@n8n/stores/useRootStore';
|
||||
|
||||
export async function workflowActivated({ data }: WorkflowActivated) {
|
||||
const workflowsStore = useWorkflowsStore();
|
||||
const bannersStore = useBannersStore();
|
||||
const rootStore = useRootStore();
|
||||
const uiStore = useUIStore();
|
||||
|
||||
const { workflowId, activeVersionId } = data;
|
||||
@@ -16,17 +13,13 @@ export async function workflowActivated({ data }: WorkflowActivated) {
|
||||
const workflowIsBeingViewed = workflowsStore.workflowId === workflowId;
|
||||
const activeVersionIsSet = workflowsStore.workflow.activeVersionId !== activeVersionId;
|
||||
if (workflowIsBeingViewed && activeVersionIsSet) {
|
||||
const activeVersion = await getWorkflowVersion(
|
||||
rootStore.restApiContext,
|
||||
workflowId,
|
||||
activeVersionId,
|
||||
);
|
||||
|
||||
workflowsStore.setWorkflowActive(workflowId, activeVersion, false);
|
||||
|
||||
// Only update checksum if there are no unsaved changes
|
||||
// Only update workflow if there are no unsaved changes
|
||||
if (!uiStore.stateIsDirty) {
|
||||
await workflowsStore.updateWorkflowChecksum();
|
||||
const updatedWorkflow = await workflowsStore.fetchWorkflow(workflowId);
|
||||
if (!updatedWorkflow.checksum) {
|
||||
throw new Error('Failed to fetch workflow');
|
||||
}
|
||||
workflowsStore.setWorkflow(updatedWorkflow);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-2
@@ -11,9 +11,13 @@ export async function workflowAutoDeactivated({ data }: WorkflowAutoDeactivated)
|
||||
workflowsStore.setWorkflowInactive(data.workflowId);
|
||||
|
||||
if (workflowsStore.workflowId === data.workflowId) {
|
||||
// Only update checksum if there are no unsaved changes
|
||||
// Only update workflow if there are no unsaved changes
|
||||
if (!uiStore.stateIsDirty) {
|
||||
await workflowsStore.updateWorkflowChecksum();
|
||||
const updatedWorkflow = await workflowsStore.fetchWorkflow(data.workflowId);
|
||||
if (!updatedWorkflow.checksum) {
|
||||
throw new Error('Failed to fetch workflow');
|
||||
}
|
||||
workflowsStore.setWorkflow(updatedWorkflow);
|
||||
}
|
||||
|
||||
bannersStore.pushBannerToStack('WORKFLOW_AUTO_DEACTIVATED');
|
||||
|
||||
+6
-4
@@ -6,12 +6,14 @@ export async function workflowDeactivated({ data }: WorkflowDeactivated) {
|
||||
const workflowsStore = useWorkflowsStore();
|
||||
const uiStore = useUIStore();
|
||||
|
||||
workflowsStore.setWorkflowInactive(data.workflowId);
|
||||
|
||||
if (workflowsStore.workflowId === data.workflowId) {
|
||||
// Only update checksum if there are no unsaved changes
|
||||
// Only update workflow if there are no unsaved changes
|
||||
if (!uiStore.stateIsDirty) {
|
||||
await workflowsStore.updateWorkflowChecksum();
|
||||
const updatedWorkflow = await workflowsStore.fetchWorkflow(data.workflowId);
|
||||
if (!updatedWorkflow.checksum) {
|
||||
throw new Error('Failed to fetch workflow');
|
||||
}
|
||||
workflowsStore.setWorkflow(updatedWorkflow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,15 +108,15 @@ export function useWorkflowActivate() {
|
||||
workflow = await workflowsApi.deactivateWorkflow(rootStore.restApiContext, currWorkflowId);
|
||||
}
|
||||
|
||||
// Update local state
|
||||
if (workflow.activeVersion) {
|
||||
workflowsStore.setWorkflowActive(currWorkflowId, workflow.activeVersion);
|
||||
} else {
|
||||
workflowsStore.setWorkflowInactive(currWorkflowId);
|
||||
if (!workflow.checksum) {
|
||||
throw new Error('Failed to activate or deactivate workflow');
|
||||
}
|
||||
|
||||
if (isCurrentWorkflow && workflow.checksum) {
|
||||
workflowsStore.setWorkflowChecksum(workflow.checksum);
|
||||
// Update local state
|
||||
if (workflow.activeVersion) {
|
||||
workflowsStore.setWorkflowActive(currWorkflowId, workflow.activeVersion, true);
|
||||
} else {
|
||||
workflowsStore.setWorkflowInactive(currWorkflowId);
|
||||
}
|
||||
} catch (error) {
|
||||
const newStateName = newActiveState ? 'activated' : 'deactivated';
|
||||
@@ -186,17 +186,14 @@ export function useWorkflowActivate() {
|
||||
expectedChecksum,
|
||||
});
|
||||
|
||||
if (!updatedWorkflow.activeVersion) {
|
||||
if (!updatedWorkflow.activeVersion || !updatedWorkflow.checksum) {
|
||||
throw new Error('Failed to publish workflow');
|
||||
}
|
||||
|
||||
workflowsStore.setWorkflowActive(workflowId, updatedWorkflow.activeVersion);
|
||||
workflowsStore.setWorkflowActive(workflowId, updatedWorkflow.activeVersion, true);
|
||||
|
||||
if (workflowId === workflowsStore.workflowId) {
|
||||
workflowsStore.setWorkflowVersionId(updatedWorkflow.versionId);
|
||||
if (updatedWorkflow.checksum) {
|
||||
workflowsStore.setWorkflowChecksum(updatedWorkflow.checksum);
|
||||
}
|
||||
workflowsStore.setWorkflowVersionId(updatedWorkflow.versionId, updatedWorkflow.checksum);
|
||||
}
|
||||
|
||||
void useExternalHooks().run('workflow.published', {
|
||||
@@ -242,11 +239,7 @@ export function useWorkflowActivate() {
|
||||
void useExternalHooks().run('workflowActivate.updateWorkflowActivation', telemetryPayload);
|
||||
|
||||
try {
|
||||
const updatedWorkflow = await workflowsStore.deactivateWorkflow(workflowId);
|
||||
|
||||
if (workflowId === workflowsStore.workflowId && updatedWorkflow.checksum) {
|
||||
workflowsStore.setWorkflowChecksum(updatedWorkflow.checksum);
|
||||
}
|
||||
await workflowsStore.deactivateWorkflow(workflowId);
|
||||
|
||||
void useExternalHooks().run('workflow.unpublished', {
|
||||
workflowId,
|
||||
|
||||
@@ -263,7 +263,7 @@ describe('useWorkflowHelpers', () => {
|
||||
timezone: 'DEFAULT',
|
||||
});
|
||||
expect(setWorkflowPinDataSpy).toHaveBeenCalledWith({});
|
||||
expect(setWorkflowVersionIdSpy).toHaveBeenCalledWith('v1');
|
||||
expect(setWorkflowVersionIdSpy).toHaveBeenCalledWith('v1', 'checksum');
|
||||
expect(setWorkflowMetadataSpy).toHaveBeenCalledWith({});
|
||||
expect(setWorkflowScopesSpy).toHaveBeenCalledWith(['workflow:create']);
|
||||
expect(setUsedCredentialsSpy).toHaveBeenCalledWith([]);
|
||||
|
||||
@@ -847,9 +847,8 @@ export function useWorkflowHelpers() {
|
||||
}
|
||||
|
||||
const workflow = await workflowsStore.updateWorkflow(workflowId, data);
|
||||
workflowsStore.setWorkflowVersionId(workflow.versionId);
|
||||
if (workflow.checksum) {
|
||||
workflowsStore.setWorkflowChecksum(workflow.checksum);
|
||||
if (!workflow.checksum) {
|
||||
throw new Error('Failed to update workflow');
|
||||
}
|
||||
|
||||
if (isCurrentWorkflow) {
|
||||
@@ -953,10 +952,7 @@ export function useWorkflowHelpers() {
|
||||
});
|
||||
workflowState.setWorkflowSettings(workflowData.settings ?? {});
|
||||
workflowsStore.setWorkflowPinData(workflowData.pinData ?? {});
|
||||
workflowsStore.setWorkflowVersionId(workflowData.versionId);
|
||||
if (workflowData.checksum) {
|
||||
workflowsStore.setWorkflowChecksum(workflowData.checksum);
|
||||
}
|
||||
workflowsStore.setWorkflowVersionId(workflowData.versionId, workflowData.checksum);
|
||||
workflowsStore.setWorkflowMetadata(workflowData.meta);
|
||||
workflowsStore.setWorkflowScopes(workflowData.scopes);
|
||||
|
||||
|
||||
@@ -7,20 +7,17 @@ import {
|
||||
MODAL_CANCEL,
|
||||
MODAL_CLOSE,
|
||||
MODAL_CONFIRM,
|
||||
NON_ACTIVATABLE_TRIGGER_NODE_TYPES,
|
||||
PLACEHOLDER_EMPTY_WORKFLOW_ID,
|
||||
VIEWS,
|
||||
IS_DRAFT_PUBLISH_ENABLED,
|
||||
} from '@/app/constants';
|
||||
import { useWorkflowHelpers } from '@/app/composables/useWorkflowHelpers';
|
||||
import { useWorkflowsStore } from '@/app/stores/workflows.store';
|
||||
import { useSourceControlStore } from '@/features/integrations/sourceControl.ee/sourceControl.store';
|
||||
import { useCanvasStore } from '@/app/stores/canvas.store';
|
||||
import type { IUpdateInformation, IWorkflowDb, NotificationOptions } from '@/Interface';
|
||||
import type { IUpdateInformation, IWorkflowDb } from '@/Interface';
|
||||
import type { ITag } from '@n8n/rest-api-client/api/tags';
|
||||
import type { WorkflowDataCreate, WorkflowDataUpdate } from '@n8n/rest-api-client/api/workflows';
|
||||
import type { IDataObject, INode, IWorkflowSettings } from 'n8n-workflow';
|
||||
import { useNodeTypesStore } from '@/app/stores/nodeTypes.store';
|
||||
import type { IDataObject, IWorkflowSettings } from 'n8n-workflow';
|
||||
import { useToast } from './useToast';
|
||||
import { useExternalHooks } from './useExternalHooks';
|
||||
import { useTelemetry } from './useTelemetry';
|
||||
@@ -43,7 +40,6 @@ export function useWorkflowSaving({
|
||||
const workflowsStore = useWorkflowsStore();
|
||||
const workflowState = providedWorkflowState ?? injectWorkflowState();
|
||||
const focusPanelStore = useFocusPanelStore();
|
||||
const nodeTypesStore = useNodeTypesStore();
|
||||
const toast = useToast();
|
||||
const telemetry = useTelemetry();
|
||||
const nodeHelpers = useNodeHelpers();
|
||||
@@ -124,54 +120,6 @@ export function useWorkflowSaving({
|
||||
);
|
||||
}
|
||||
|
||||
function isNodeActivatable(node: INode): boolean {
|
||||
if (node.disabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const nodeType = nodeTypesStore.getNodeType(node.type, node.typeVersion);
|
||||
|
||||
return (
|
||||
nodeType !== null &&
|
||||
nodeType.group.includes('trigger') &&
|
||||
!NON_ACTIVATABLE_TRIGGER_NODE_TYPES.includes(node.type)
|
||||
);
|
||||
}
|
||||
|
||||
async function getWorkflowDeactivationInfo(
|
||||
workflowId: string,
|
||||
request: WorkflowDataUpdate,
|
||||
): Promise<Partial<NotificationOptions> | undefined> {
|
||||
if (IS_DRAFT_PUBLISH_ENABLED) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const missingActivatableTriggerNode =
|
||||
request.nodes !== undefined && !request.nodes.some(isNodeActivatable);
|
||||
|
||||
if (missingActivatableTriggerNode) {
|
||||
// Automatically deactivate if all activatable triggers are removed
|
||||
return {
|
||||
title: i18n.baseText('workflows.autodeactivated'),
|
||||
message: i18n.baseText('workflowActivator.thisWorkflowHasNoTriggerNodes'),
|
||||
type: 'info',
|
||||
};
|
||||
}
|
||||
|
||||
const conflictData = await checkConflictingWebhooks(workflowId);
|
||||
|
||||
if (conflictData) {
|
||||
// Workflow should not be active if there is live webhook with the same path
|
||||
return {
|
||||
title: 'Conflicting Webhook Path',
|
||||
message: `Workflow set to inactive: Workflow set to inactive: Live webhook in another workflow uses same path as node '${conflictData.trigger.name}'.`,
|
||||
type: 'error',
|
||||
};
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function getQueryParam(query: LocationQuery, key: string): string | undefined {
|
||||
const value = query[key];
|
||||
if (Array.isArray(value)) return value[0] ?? undefined;
|
||||
@@ -225,29 +173,15 @@ export function useWorkflowSaving({
|
||||
workflowDataRequest.aiBuilderAssisted = builderStore.getAiBuilderMadeEdits();
|
||||
workflowDataRequest.expectedChecksum = workflowsStore.workflowChecksum;
|
||||
|
||||
const deactivateReason = await getWorkflowDeactivationInfo(
|
||||
currentWorkflow,
|
||||
workflowDataRequest,
|
||||
);
|
||||
|
||||
if (deactivateReason !== undefined) {
|
||||
workflowDataRequest.active = false;
|
||||
|
||||
if (workflowsStore.isWorkflowActive) {
|
||||
toast.showMessage(deactivateReason);
|
||||
|
||||
workflowsStore.setWorkflowInactive(currentWorkflow);
|
||||
}
|
||||
}
|
||||
const workflowData = await workflowsStore.updateWorkflow(
|
||||
currentWorkflow,
|
||||
workflowDataRequest,
|
||||
forceSave,
|
||||
);
|
||||
workflowsStore.setWorkflowVersionId(workflowData.versionId);
|
||||
if (workflowData.checksum) {
|
||||
workflowsStore.setWorkflowChecksum(workflowData.checksum);
|
||||
if (!workflowData.checksum) {
|
||||
throw new Error('Failed to update workflow');
|
||||
}
|
||||
workflowsStore.setWorkflowVersionId(workflowData.versionId, workflowData.checksum);
|
||||
|
||||
if (name) {
|
||||
workflowState.setWorkflowName({ newName: workflowData.name, setStateDirty: false });
|
||||
|
||||
@@ -908,7 +908,7 @@ describe('useWorkflowsStore', () => {
|
||||
workflowPublishHistory: [],
|
||||
};
|
||||
|
||||
workflowsStore.setWorkflowActive('1', mockActiveVersion);
|
||||
workflowsStore.setWorkflowActive('1', mockActiveVersion, true);
|
||||
|
||||
expect(workflowsStore.activeWorkflows).toContain('1');
|
||||
expect(workflowsStore.workflowsById['1'].active).toBe(true);
|
||||
@@ -931,7 +931,7 @@ describe('useWorkflowsStore', () => {
|
||||
workflowPublishHistory: [],
|
||||
};
|
||||
|
||||
workflowsStore.setWorkflowActive('1', mockActiveVersion);
|
||||
workflowsStore.setWorkflowActive('1', mockActiveVersion, true);
|
||||
|
||||
expect(workflowsStore.activeWorkflows).toEqual(['1']);
|
||||
expect(workflowsStore.workflowsById['1'].active).toBe(true);
|
||||
@@ -953,7 +953,7 @@ describe('useWorkflowsStore', () => {
|
||||
workflowPublishHistory: [],
|
||||
};
|
||||
|
||||
workflowsStore.setWorkflowActive('2', mockActiveVersion);
|
||||
workflowsStore.setWorkflowActive('2', mockActiveVersion, true);
|
||||
expect(workflowsStore.workflowsById['1'].active).toBe(false);
|
||||
expect(uiStore.stateIsDirty).toBe(true);
|
||||
});
|
||||
@@ -1490,6 +1490,7 @@ describe('useWorkflowsStore', () => {
|
||||
.spyOn(apiUtils, 'makeRestApiRequest')
|
||||
.mockImplementation(async () => ({
|
||||
versionId: updatedVersionId,
|
||||
checksum: 'checksum',
|
||||
}));
|
||||
|
||||
await workflowsStore.archiveWorkflow(workflowId);
|
||||
@@ -1529,6 +1530,7 @@ describe('useWorkflowsStore', () => {
|
||||
.spyOn(apiUtils, 'makeRestApiRequest')
|
||||
.mockImplementation(async () => ({
|
||||
versionId: updatedVersionId,
|
||||
checksum: 'checksum',
|
||||
}));
|
||||
|
||||
await workflowsStore.unarchiveWorkflow(workflowId);
|
||||
@@ -1566,7 +1568,7 @@ describe('useWorkflowsStore', () => {
|
||||
const makeRestApiRequestSpy = vi.spyOn(apiUtils, 'makeRestApiRequest').mockResolvedValue(
|
||||
createTestWorkflow({
|
||||
id: 'w1',
|
||||
versionId: 'v2',
|
||||
versionId: 'v1',
|
||||
settings: {
|
||||
executionOrder: 'v1',
|
||||
timezone: 'UTC',
|
||||
@@ -1592,8 +1594,8 @@ describe('useWorkflowsStore', () => {
|
||||
);
|
||||
|
||||
// Assert returned value and store updates
|
||||
expect(result.versionId).toBe('v2');
|
||||
expect(workflowsStore.workflow.versionId).toBe('v2');
|
||||
expect(result.versionId).toBe('v1');
|
||||
expect(workflowsStore.workflow.versionId).toBe('v1');
|
||||
expect(workflowsStore.workflow.settings).toEqual({
|
||||
executionOrder: 'v1',
|
||||
timezone: 'UTC',
|
||||
|
||||
@@ -744,18 +744,10 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
||||
}, {});
|
||||
}
|
||||
|
||||
function setWorkflowVersionId(versionId: string) {
|
||||
function setWorkflowVersionId(versionId: string, newChecksum?: string) {
|
||||
workflow.value.versionId = versionId;
|
||||
}
|
||||
|
||||
function setWorkflowChecksum(checksum: string) {
|
||||
workflowChecksum.value = checksum;
|
||||
}
|
||||
|
||||
async function updateWorkflowChecksum() {
|
||||
const updatedWorkflow = await fetchWorkflow(workflow.value.id);
|
||||
if (updatedWorkflow.checksum) {
|
||||
setWorkflowChecksum(updatedWorkflow.checksum);
|
||||
if (newChecksum) {
|
||||
workflowChecksum.value = newChecksum;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -860,20 +852,19 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
||||
'POST',
|
||||
`/workflows/${id}/archive`,
|
||||
);
|
||||
if (!updatedWorkflow.checksum) {
|
||||
throw new Error('Failed to archive workflow');
|
||||
}
|
||||
if (workflowsById.value[id]) {
|
||||
workflowsById.value[id].isArchived = true;
|
||||
workflowsById.value[id].versionId = updatedWorkflow.versionId;
|
||||
}
|
||||
|
||||
if (id === workflow.value.id && updatedWorkflow.checksum) {
|
||||
setWorkflowChecksum(updatedWorkflow.checksum);
|
||||
}
|
||||
|
||||
setWorkflowInactive(id);
|
||||
|
||||
if (id === workflow.value.id) {
|
||||
setIsArchived(true);
|
||||
setWorkflowVersionId(updatedWorkflow.versionId);
|
||||
setWorkflowVersionId(updatedWorkflow.versionId, updatedWorkflow.checksum);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -883,19 +874,16 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
||||
'POST',
|
||||
`/workflows/${id}/unarchive`,
|
||||
);
|
||||
if (!updatedWorkflow.checksum) {
|
||||
throw new Error('Failed to unarchive workflow');
|
||||
}
|
||||
if (workflowsById.value[id]) {
|
||||
workflowsById.value[id].isArchived = false;
|
||||
workflowsById.value[id].versionId = updatedWorkflow.versionId;
|
||||
}
|
||||
|
||||
// Update checksum if unarchiving the currently open workflow
|
||||
if (id === workflow.value.id && updatedWorkflow.checksum) {
|
||||
setWorkflowChecksum(updatedWorkflow.checksum);
|
||||
}
|
||||
|
||||
if (id === workflow.value.id) {
|
||||
setIsArchived(false);
|
||||
setWorkflowVersionId(updatedWorkflow.versionId);
|
||||
setWorkflowVersionId(updatedWorkflow.versionId, updatedWorkflow.checksum);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -912,7 +900,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
||||
function setWorkflowActive(
|
||||
targetWorkflowId: string,
|
||||
activeVersion: WorkflowHistory,
|
||||
clearDirtyState: boolean = true,
|
||||
clearDirtyState: boolean,
|
||||
) {
|
||||
if (activeWorkflows.value.indexOf(targetWorkflowId) === -1) {
|
||||
activeWorkflows.value.push(targetWorkflowId);
|
||||
@@ -1637,6 +1625,14 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
||||
data as unknown as IDataObject,
|
||||
);
|
||||
|
||||
if (!updatedWorkflow.checksum) {
|
||||
throw new Error('Failed to update workflow');
|
||||
}
|
||||
|
||||
if (id === workflow.value.id) {
|
||||
setWorkflowVersionId(updatedWorkflow.versionId, updatedWorkflow.checksum);
|
||||
}
|
||||
|
||||
if (
|
||||
workflowHelpers.containsNodeFromPackage(updatedWorkflow, AI_NODES_PACKAGE_NAME) &&
|
||||
!usersStore.isEasyAIWorkflowOnboardingDone
|
||||
@@ -1670,9 +1666,16 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
||||
'POST',
|
||||
`/workflows/${id}/deactivate`,
|
||||
);
|
||||
if (!updatedWorkflow.checksum) {
|
||||
throw new Error('Failed to deactivate workflow');
|
||||
}
|
||||
|
||||
setWorkflowInactive(id);
|
||||
|
||||
if (id === workflow.value.id) {
|
||||
setWorkflowVersionId(updatedWorkflow.versionId, updatedWorkflow.checksum);
|
||||
}
|
||||
|
||||
return updatedWorkflow;
|
||||
}
|
||||
|
||||
@@ -1717,10 +1720,6 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
||||
|
||||
// Update local store state to reflect the change
|
||||
if (isCurrentWorkflow) {
|
||||
setWorkflowVersionId(updated.versionId);
|
||||
if (updated.checksum) {
|
||||
setWorkflowChecksum(updated.checksum);
|
||||
}
|
||||
setWorkflowSettings(updated.settings ?? {});
|
||||
} else if (workflowsById.value[id]) {
|
||||
workflowsById.value[id] = {
|
||||
@@ -1771,12 +1770,6 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
||||
// Update local store state
|
||||
if (isCurrentWorkflow) {
|
||||
setDescription(updated.description ?? '');
|
||||
if (updated.versionId !== currentVersionId) {
|
||||
setWorkflowVersionId(updated.versionId);
|
||||
}
|
||||
if (updated.checksum) {
|
||||
setWorkflowChecksum(updated.checksum);
|
||||
}
|
||||
}
|
||||
|
||||
return updated;
|
||||
@@ -2040,8 +2033,6 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, () => {
|
||||
addNodeExecutionStartedData,
|
||||
setUsedCredentials,
|
||||
setWorkflowVersionId,
|
||||
setWorkflowChecksum,
|
||||
updateWorkflowChecksum,
|
||||
setWorkflowActiveVersion,
|
||||
replaceInvalidWorkflowCredentials,
|
||||
assignCredentialToMatchingNodes,
|
||||
|
||||
-4
@@ -266,10 +266,6 @@ const restoreWorkflowVersion = async (
|
||||
deactivateAndRestore,
|
||||
);
|
||||
|
||||
if (workflowId.value === workflowsStore.workflowId && activeWorkflow.value.checksum) {
|
||||
workflowsStore.setWorkflowChecksum(activeWorkflow.value.checksum);
|
||||
}
|
||||
|
||||
const history = await workflowHistoryStore.getWorkflowHistory(workflowId.value, {
|
||||
take: 1,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user