mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat(editor): Include NodeDetailsView in URL (#14349)
This commit is contained in:
@@ -234,6 +234,7 @@ const workflowId = computed(() => {
|
||||
? undefined
|
||||
: workflowIdParam;
|
||||
});
|
||||
const routeNodeId = computed(() => route.params.nodeId as string | undefined);
|
||||
|
||||
const isNewWorkflowRoute = computed(() => route.name === VIEWS.NEW_WORKFLOW || !workflowId.value);
|
||||
const isWorkflowRoute = computed(() => !!route?.meta?.nodeView || isDemoRoute.value);
|
||||
@@ -1606,6 +1607,23 @@ function showAddFirstStepIfEnabled() {
|
||||
* Routing
|
||||
*/
|
||||
|
||||
function updateNodeRoute(nodeId: string) {
|
||||
const nodeUi = workflowsStore.findNodeByPartialId(nodeId);
|
||||
if (nodeUi) {
|
||||
setNodeActive(nodeUi.id);
|
||||
} else {
|
||||
toast.showToast({
|
||||
title: i18n.baseText('nodeView.showMessage.ndvUrl.missingNodes.title'),
|
||||
message: i18n.baseText('nodeView.showMessage.ndvUrl.missingNodes.content'),
|
||||
type: 'warning',
|
||||
});
|
||||
void router.replace({
|
||||
name: route.name,
|
||||
params: { name: workflowId.value },
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => route.name,
|
||||
async (newRouteName, oldRouteName) => {
|
||||
@@ -1617,6 +1635,35 @@ watch(
|
||||
},
|
||||
);
|
||||
|
||||
// This keeps the selected node in sync if the URL is updated
|
||||
watch(
|
||||
() => route.params.nodeId,
|
||||
async (newId) => {
|
||||
if (typeof newId !== 'string' || newId === '') ndvStore.activeNodeName = null;
|
||||
else {
|
||||
updateNodeRoute(newId);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// This keeps URL in sync if the activeNode is changed
|
||||
watch(
|
||||
() => ndvStore.activeNode,
|
||||
async (val) => {
|
||||
// This is just out of caution
|
||||
if (!([VIEWS.WORKFLOW] as string[]).includes(String(route.name))) return;
|
||||
|
||||
// Route params default to '' instead of undefined if not present
|
||||
const nodeId = val?.id ? workflowsStore.getPartialIdForNode(val?.id) : '';
|
||||
|
||||
if (nodeId !== route.params.nodeId) {
|
||||
await router.push({
|
||||
name: route.name,
|
||||
params: { name: workflowId.value, nodeId },
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
onBeforeRouteLeave(async (to, from, next) => {
|
||||
const toNodeViewTab = getNodeViewTab(to);
|
||||
|
||||
@@ -1689,6 +1736,13 @@ onMounted(() => {
|
||||
|
||||
void externalHooks.run('nodeView.mount').catch(() => {});
|
||||
|
||||
// A delay here makes opening the NDV a bit less jarring
|
||||
setTimeout(() => {
|
||||
if (routeNodeId.value) {
|
||||
updateNodeRoute(routeNodeId.value);
|
||||
}
|
||||
}, 500);
|
||||
|
||||
emitPostMessageReady();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user