Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { createRouter, createWebHistory } from "vue-router";
import { setupHints } from "@knime/components";
import { CURRENT_STATE_VERSION } from "@knime/hub-features/versions";

import { WorkflowInfo } from "@/api/gateway-api/generated-api";
import { isBrowser, isDesktop, runInEnvironment } from "@/environment";
import { APP_ROUTES } from "@/router/appRoutes";
import { router, routes } from "@/router/router";
Expand Down Expand Up @@ -324,6 +325,54 @@ describe("application::lifecycle", () => {
expect(mockedAPI.event.subscribeEvent).not.toHaveBeenCalled();
});

it("handles afterSetActivateWorkflow when a workflow is loaded", async () => {
const { lifecycleStore, componentInteractionsStore } = loadStore();
const loadedWF = createWorkflow({
info: { containerId: "root" },
nodes: Object.create({}),
});

mockedAPI.workflow.getWorkflow.mockResolvedValue({
workflow: loadedWF,
snapshotId: "snap",
});
await lifecycleStore.loadWorkflow({
projectId: "wf1",
workflowId: "root:0:12",
});

expect(
componentInteractionsStore.checkForLinkedComponentUpdates,
).toHaveBeenCalledWith({ auto: true });
});

it("closes version panel when entering a linked component", async () => {
const { lifecycleStore, workflowVersionsStore } = loadStore();

// @ts-expect-error - mock getter
workflowVersionsStore.activeProjectVersionsModeStatus = "active";

const loadedWF = createWorkflow({
info: {
containerId: "root",
linked: true,
containerType: WorkflowInfo.ContainerTypeEnum.Component,
},
nodes: Object.create({}),
});

mockedAPI.workflow.getWorkflow.mockResolvedValue({
workflow: loadedWF,
snapshotId: "snap",
});
await lifecycleStore.loadWorkflow({
projectId: "wf1",
workflowId: "root:0:12",
});

expect(workflowVersionsStore.deactivateVersionsMode).toHaveBeenCalled();
});

it("unloads workflow when another one is loaded", async () => {
const { lifecycleStore, workflowStore, selectionStore } = loadStore();
const loadedWF = createWorkflow({
Expand Down
15 changes: 15 additions & 0 deletions org.knime.ui.js/src/store/application/lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { sleep } from "@knime/utils";
import {
AppState,
type Workflow,
WorkflowInfo,
type WorkflowSnapshot,
} from "@/api/gateway-api/generated-api";
import { fetchUiStrings as kaiFetchUiStrings } from "@/components/kai/useKaiServer";
Expand All @@ -23,6 +24,7 @@ import { ratioToZoomLevel, useSettingsStore } from "@/store/settings";
import { useAnnotationInteractionsStore } from "@/store/workflow/annotationInteractions";
import { useComponentInteractionsStore } from "@/store/workflow/componentInteractions";
import { useWorkflowStore } from "@/store/workflow/workflow";
import { useWorkflowVersionsStore } from "@/store/workflow/workflowVersions";
import { encodeString } from "@/util/encodeString";
import { geometry } from "@/util/geometry";
import { setProjectActiveOrThrow } from "@/util/projectUtil";
Expand Down Expand Up @@ -588,6 +590,19 @@ export const useLifecycleStore = defineStore("lifecycle", {
},

afterSetActivateWorkflow() {
const activeWorkflow = useWorkflowStore().activeWorkflow;
if (
activeWorkflow?.info.linked &&
activeWorkflow.info.containerType ===
WorkflowInfo.ContainerTypeEnum.Component
) {
const versionsStore = useWorkflowVersionsStore();

if (versionsStore.activeProjectVersionsModeStatus !== "inactive") {
versionsStore.deactivateVersionsMode();
}
}

useComponentInteractionsStore().checkForLinkedComponentUpdates({
auto: true,
});
Expand Down
Loading