mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
use local storage to redirect to next waiting form
This commit is contained in:
parent
73d383d53d
commit
9883a7a53f
|
@ -735,6 +735,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
}).then(() => {
|
||||||
|
window.addEventListener('storage', function(event) {
|
||||||
|
if (event.key === 'n8n_redirect_to_next_form_test_page' && event.newValue) {
|
||||||
|
const newUrl = event.newValue;
|
||||||
|
localStorage.removeItem('n8n_redirect_to_next_form_test_page');
|
||||||
|
window.location.replace(newUrl);
|
||||||
|
}
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
console.error('Error:', error);
|
console.error('Error:', error);
|
||||||
|
|
|
@ -20,7 +20,12 @@ import { NodeConnectionType } from 'n8n-workflow';
|
||||||
import { useToast } from '@/composables/useToast';
|
import { useToast } from '@/composables/useToast';
|
||||||
import { useNodeHelpers } from '@/composables/useNodeHelpers';
|
import { useNodeHelpers } from '@/composables/useNodeHelpers';
|
||||||
|
|
||||||
import { CHAT_TRIGGER_NODE_TYPE, WAIT_NODE_TYPE, WORKFLOW_LM_CHAT_MODAL_KEY } from '@/constants';
|
import {
|
||||||
|
CHAT_TRIGGER_NODE_TYPE,
|
||||||
|
FORM_TRIGGER_NODE_TYPE,
|
||||||
|
WAIT_NODE_TYPE,
|
||||||
|
WORKFLOW_LM_CHAT_MODAL_KEY,
|
||||||
|
} from '@/constants';
|
||||||
import { useTitleChange } from '@/composables/useTitleChange';
|
import { useTitleChange } from '@/composables/useTitleChange';
|
||||||
import { useRootStore } from '@/stores/root.store';
|
import { useRootStore } from '@/stores/root.store';
|
||||||
import { useUIStore } from '@/stores/ui.store';
|
import { useUIStore } from '@/stores/ui.store';
|
||||||
|
@ -296,10 +301,10 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
|
||||||
shouldShowForm,
|
shouldShowForm,
|
||||||
});
|
});
|
||||||
|
|
||||||
// await useExternalHooks().run('workflowRun.runWorkflow', {
|
await useExternalHooks().run('workflowRun.runWorkflow', {
|
||||||
// nodeName: options.destinationNode,
|
nodeName: options.destinationNode,
|
||||||
// source: options.source,
|
source: options.source,
|
||||||
// });
|
});
|
||||||
|
|
||||||
return runWorkflowApiResponse;
|
return runWorkflowApiResponse;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -309,11 +314,11 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function openWaitNodeFormResumeUrl(node: INode, executionId: string) {
|
function gerWaitNodeFormResumeUrl(node: INode, executionId: string) {
|
||||||
const { webhookSuffix } = (node.parameters.options ?? {}) as IDataObject;
|
const { webhookSuffix } = (node.parameters.options ?? {}) as IDataObject;
|
||||||
const suffix = webhookSuffix && typeof webhookSuffix !== 'object' ? `/${webhookSuffix}` : '';
|
const suffix = webhookSuffix && typeof webhookSuffix !== 'object' ? `/${webhookSuffix}` : '';
|
||||||
const testUrl = `${rootStore.formWaitingUrl}/${executionId}${suffix}`;
|
const testUrl = `${rootStore.formWaitingUrl}/${executionId}${suffix}`;
|
||||||
openPopUpWindow(testUrl);
|
return testUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function runWorkflowAndResolveWaitingNodesData(options: {
|
async function runWorkflowAndResolveWaitingNodesData(options: {
|
||||||
|
@ -346,6 +351,7 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
|
||||||
if (!executionId) executionId = await waitForWebhook();
|
if (!executionId) executionId = await waitForWebhook();
|
||||||
|
|
||||||
const shownForms: string[] = [];
|
const shownForms: string[] = [];
|
||||||
|
let isFormShown = workflowsStore.allNodes.some((node) => node.type === FORM_TRIGGER_NODE_TYPE);
|
||||||
|
|
||||||
const resolveWaitingNodesData = async (): Promise<void> => {
|
const resolveWaitingNodesData = async (): Promise<void> => {
|
||||||
return await new Promise<void>((resolve) => {
|
return await new Promise<void>((resolve) => {
|
||||||
|
@ -358,7 +364,7 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (execution.finished) {
|
if (execution.finished || ['error', 'canceled', 'crashed'].includes(execution.status)) {
|
||||||
workflowsStore.setWorkflowExecutionData(execution);
|
workflowsStore.setWorkflowExecutionData(execution);
|
||||||
nodeHelpers.updateNodesExecutionIssues();
|
nodeHelpers.updateNodesExecutionIssues();
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
|
@ -379,7 +385,14 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
|
||||||
waitingNode.parameters.resume === 'form' &&
|
waitingNode.parameters.resume === 'form' &&
|
||||||
!shownForms.includes(waitingNode.name)
|
!shownForms.includes(waitingNode.name)
|
||||||
) {
|
) {
|
||||||
openWaitNodeFormResumeUrl(waitingNode, executionId as string);
|
const testUrl = gerWaitNodeFormResumeUrl(waitingNode, executionId as string);
|
||||||
|
if (isFormShown) {
|
||||||
|
localStorage.setItem('n8n_redirect_to_next_form_test_page', testUrl);
|
||||||
|
} else {
|
||||||
|
isFormShown = true;
|
||||||
|
openPopUpWindow(testUrl);
|
||||||
|
}
|
||||||
|
|
||||||
shownForms.push(waitingNode.name);
|
shownForms.push(waitingNode.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue