Skip to content
Merged
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 @@ -247,7 +247,7 @@ async function navigateToEvaluationsView(openInNewTab: boolean) {
} else if (route.name !== routeToNavigateTo.name) {
dirtyState.value = uiStore.stateIsDirty;
workflowToReturnTo.value = workflowId.value;
activeHeaderTab.value = MAIN_HEADER_TABS.EXECUTIONS;
activeHeaderTab.value = MAIN_HEADER_TABS.EVALUATION;
await router.push(routeToNavigateTo);
}
}
Expand Down
46 changes: 46 additions & 0 deletions packages/frontend/editor-ui/src/app/utils/nodeViewUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
generateOffsets,
getGenericHints,
getNewNodePosition,
getNodeViewTab,
updateViewportToContainNodes,
DEFAULT_NODE_SIZE,
snapPositionToGrid,
Expand All @@ -27,6 +28,8 @@ import type { GraphNode } from '@vue-flow/core';
import { v4 as uuid } from 'uuid';
import { createTestingPinia } from '@pinia/testing';
import { setActivePinia } from 'pinia';
import { MAIN_HEADER_TABS, VIEWS } from '@/app/constants';
import type { RouteLocation } from 'vue-router';

describe('getGenericHints', () => {
let mockWorkflowNode: MockProxy<INode>;
Expand Down Expand Up @@ -635,3 +638,46 @@ describe('canUsePosition', () => {
expect(canUsePosition(pos1, pos2)).toBe(true);
});
});

describe('getNodeViewTab', () => {
function createRouteLocation(overrides: Partial<RouteLocation>): RouteLocation {
return {
matched: [],
fullPath: '/',
query: {},
hash: '',
redirectedFrom: undefined,
path: '/',
params: {},
name: undefined,
meta: {},
...overrides,
} as RouteLocation;
}

it('should return WORKFLOW for routes with nodeView meta', () => {
const route = createRouteLocation({ meta: { nodeView: true } });
expect(getNodeViewTab(route)).toBe(MAIN_HEADER_TABS.WORKFLOW);
});

it.each([VIEWS.WORKFLOW_EXECUTIONS, VIEWS.EXECUTION_PREVIEW, VIEWS.EXECUTION_HOME])(
'should return EXECUTIONS for %s route',
(viewName) => {
const route = createRouteLocation({ name: viewName });
expect(getNodeViewTab(route)).toBe(MAIN_HEADER_TABS.EXECUTIONS);
},
);

it.each([VIEWS.EVALUATION_EDIT, VIEWS.EVALUATION_RUNS_DETAIL])(
'should return EVALUATION for %s route',
(viewName) => {
const route = createRouteLocation({ name: viewName });
expect(getNodeViewTab(route)).toBe(MAIN_HEADER_TABS.EVALUATION);
},
);

it('should return null for unrecognized routes', () => {
const route = createRouteLocation({ name: 'SomeOtherView' });
expect(getNodeViewTab(route)).toBeNull();
});
});
4 changes: 4 additions & 0 deletions packages/frontend/editor-ui/src/app/utils/nodeViewUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,10 @@ export const getNodeViewTab = (route: RouteLocation): string | null => {
.includes(String(route.name))
) {
return MAIN_HEADER_TABS.EXECUTIONS;
} else if (
[VIEWS.EVALUATION_EDIT, VIEWS.EVALUATION_RUNS_DETAIL].map(String).includes(String(route.name))
) {
return MAIN_HEADER_TABS.EVALUATION;
}
return null;
};
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/editor-ui/src/app/views/NodeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1674,6 +1674,7 @@ onBeforeRouteLeave(async (to, from, next) => {

const shouldSkipPrompt =
toNodeViewTab === MAIN_HEADER_TABS.EXECUTIONS ||
toNodeViewTab === MAIN_HEADER_TABS.EVALUATION ||
from.name === VIEWS.TEMPLATE_IMPORT ||
(toNodeViewTab === MAIN_HEADER_TABS.WORKFLOW && from.name === VIEWS.EXECUTION_DEBUG);

Expand Down
Loading