mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-12 16:10:30 +02:00
This commit is contained in:
parent
413730d737
commit
bb90476acc
|
|
@ -1,35 +0,0 @@
|
||||||
import { ERROR_TRIGGER_NODE_TYPE } from '@/app/constants';
|
|
||||||
import type { NodeTypesStore } from '@/app/stores/nodeTypes.store';
|
|
||||||
import type { INodeType, INodeTypes } from 'n8n-workflow';
|
|
||||||
|
|
||||||
export function createFrontendNodeTypes(
|
|
||||||
nodeTypesStore: Pick<NodeTypesStore, 'getNodeType' | 'communityNodeType'>,
|
|
||||||
): INodeTypes {
|
|
||||||
const nodeTypes: INodeTypes = {
|
|
||||||
nodeTypes: {},
|
|
||||||
init: async (): Promise<void> => {},
|
|
||||||
getByNameAndVersion: (nodeType: string, version?: number): INodeType | undefined => {
|
|
||||||
const nodeTypeDescription =
|
|
||||||
nodeTypesStore.getNodeType(nodeType, version) ??
|
|
||||||
nodeTypesStore.communityNodeType(nodeType)?.nodeDescription ??
|
|
||||||
null;
|
|
||||||
if (nodeTypeDescription === null) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
description: nodeTypeDescription,
|
|
||||||
// As we do not have the trigger/poll functions available in the frontend
|
|
||||||
// we use the information available to figure out what are trigger nodes
|
|
||||||
// @ts-ignore
|
|
||||||
trigger:
|
|
||||||
(![ERROR_TRIGGER_NODE_TYPE].includes(nodeType) &&
|
|
||||||
nodeTypeDescription.inputs.length === 0 &&
|
|
||||||
!nodeTypeDescription.webhooks) ||
|
|
||||||
undefined,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
} as unknown as INodeTypes;
|
|
||||||
|
|
||||||
return nodeTypes;
|
|
||||||
}
|
|
||||||
|
|
@ -6,7 +6,6 @@ import NodeCredentials from '@/features/credentials/components/NodeCredentials.v
|
||||||
import ParameterInputList from '@/features/ndv/parameters/components/ParameterInputList.vue';
|
import ParameterInputList from '@/features/ndv/parameters/components/ParameterInputList.vue';
|
||||||
import { useCredentialsStore } from '@/features/credentials/credentials.store';
|
import { useCredentialsStore } from '@/features/credentials/credentials.store';
|
||||||
import { useNodeTypesStore } from '@/app/stores/nodeTypes.store';
|
import { useNodeTypesStore } from '@/app/stores/nodeTypes.store';
|
||||||
import { createFrontendNodeTypes } from '@/app/utils/nodeTypes/createFrontendNodeTypes';
|
|
||||||
import useEnvironmentsStore from '@/features/settings/environments.ee/environments.store';
|
import useEnvironmentsStore from '@/features/settings/environments.ee/environments.store';
|
||||||
import { ExpressionLocalResolveContextSymbol } from '@/app/constants';
|
import { ExpressionLocalResolveContextSymbol } from '@/app/constants';
|
||||||
import { Workflow, type IConnections, type INodeProperties } from 'n8n-workflow';
|
import { Workflow, type IConnections, type INodeProperties } from 'n8n-workflow';
|
||||||
|
|
@ -24,7 +23,6 @@ const i18n = useI18n();
|
||||||
const credentialsStore = useCredentialsStore();
|
const credentialsStore = useCredentialsStore();
|
||||||
const nodeTypesStore = useNodeTypesStore();
|
const nodeTypesStore = useNodeTypesStore();
|
||||||
const environmentsStore = useEnvironmentsStore();
|
const environmentsStore = useEnvironmentsStore();
|
||||||
const frontendNodeTypes = createFrontendNodeTypes(nodeTypesStore);
|
|
||||||
|
|
||||||
const credentialType = computed(() => props.section.credentialType);
|
const credentialType = computed(() => props.section.credentialType);
|
||||||
|
|
||||||
|
|
@ -99,7 +97,7 @@ const expressionContext = computed<ExpressionLocalResolveContext | undefined>(()
|
||||||
nodes: [node],
|
nodes: [node],
|
||||||
connections,
|
connections,
|
||||||
active: false,
|
active: false,
|
||||||
nodeTypes: frontendNodeTypes,
|
nodeTypes: nodeTypesStore.getAllNodeTypes(),
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -87,19 +87,10 @@ describe('useWorkflowSetupApply', () => {
|
||||||
|
|
||||||
await h.applyMachine.apply({ nodeCredentials });
|
await h.applyMachine.apply({ nodeCredentials });
|
||||||
|
|
||||||
expect(h.store.confirmAction).toHaveBeenCalledWith(
|
expect(h.store.confirmAction).toHaveBeenCalledWith('req-1', {
|
||||||
'req-1',
|
kind: 'setupWorkflowApply',
|
||||||
true,
|
nodeCredentials,
|
||||||
undefined,
|
});
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
{
|
|
||||||
action: 'apply',
|
|
||||||
nodeCredentials,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('posts apply confirmation with node parameters', async () => {
|
it('posts apply confirmation with node parameters', async () => {
|
||||||
|
|
@ -108,19 +99,10 @@ describe('useWorkflowSetupApply', () => {
|
||||||
|
|
||||||
await h.applyMachine.apply({ nodeParameters });
|
await h.applyMachine.apply({ nodeParameters });
|
||||||
|
|
||||||
expect(h.store.confirmAction).toHaveBeenCalledWith(
|
expect(h.store.confirmAction).toHaveBeenCalledWith('req-1', {
|
||||||
'req-1',
|
kind: 'setupWorkflowApply',
|
||||||
true,
|
nodeParameters,
|
||||||
undefined,
|
});
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
{
|
|
||||||
action: 'apply',
|
|
||||||
nodeParameters,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('resets state when posting apply confirmation fails', async () => {
|
it('resets state when posting apply confirmation fails', async () => {
|
||||||
|
|
@ -171,13 +153,7 @@ describe('useWorkflowSetupApply', () => {
|
||||||
|
|
||||||
expect(h.store.confirmAction).toHaveBeenCalledWith(
|
expect(h.store.confirmAction).toHaveBeenCalledWith(
|
||||||
'req-2',
|
'req-2',
|
||||||
true,
|
expect.objectContaining({ kind: 'setupWorkflowApply' }),
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
expect.any(Object),
|
|
||||||
);
|
);
|
||||||
expect(h.store.resolveConfirmation).toHaveBeenCalledWith('req-2', 'approved');
|
expect(h.store.resolveConfirmation).toHaveBeenCalledWith('req-2', 'approved');
|
||||||
});
|
});
|
||||||
|
|
@ -247,7 +223,10 @@ describe('useWorkflowSetupApply', () => {
|
||||||
|
|
||||||
await h.applyMachine.defer();
|
await h.applyMachine.defer();
|
||||||
|
|
||||||
expect(h.store.confirmAction).toHaveBeenCalledWith('req-1', false);
|
expect(h.store.confirmAction).toHaveBeenCalledWith('req-1', {
|
||||||
|
kind: 'approval',
|
||||||
|
approved: false,
|
||||||
|
});
|
||||||
expect(h.applyMachine.terminalState.value).toBe('deferred');
|
expect(h.applyMachine.terminalState.value).toBe('deferred');
|
||||||
expect(h.store.resolveConfirmation).toHaveBeenCalledWith('req-1', 'deferred');
|
expect(h.store.resolveConfirmation).toHaveBeenCalledWith('req-1', 'deferred');
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -89,19 +89,10 @@ export function useWorkflowSetupApply(deps: {
|
||||||
if (terminalState.value === 'applying') return;
|
if (terminalState.value === 'applying') return;
|
||||||
terminalState.value = 'applying';
|
terminalState.value = 'applying';
|
||||||
|
|
||||||
const postSuccess = await deps.store.confirmAction(
|
const postSuccess = await deps.store.confirmAction(deps.requestId.value, {
|
||||||
deps.requestId.value,
|
kind: 'setupWorkflowApply',
|
||||||
true,
|
...payload,
|
||||||
undefined,
|
});
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
undefined,
|
|
||||||
{
|
|
||||||
action: 'apply',
|
|
||||||
...payload,
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// confirmAction already toasts on POST failure; just reset so the wizard
|
// confirmAction already toasts on POST failure; just reset so the wizard
|
||||||
// re-renders with the user's selections and they can try again.
|
// re-renders with the user's selections and they can try again.
|
||||||
|
|
@ -141,7 +132,10 @@ export function useWorkflowSetupApply(deps: {
|
||||||
if (terminalState.value === 'applying') return;
|
if (terminalState.value === 'applying') return;
|
||||||
terminalState.value = 'applying';
|
terminalState.value = 'applying';
|
||||||
|
|
||||||
const success = await deps.store.confirmAction(deps.requestId.value, false);
|
const success = await deps.store.confirmAction(deps.requestId.value, {
|
||||||
|
kind: 'approval',
|
||||||
|
approved: false,
|
||||||
|
});
|
||||||
if (success) {
|
if (success) {
|
||||||
terminalState.value = 'deferred';
|
terminalState.value = 'deferred';
|
||||||
deps.store.resolveConfirmation(deps.requestId.value, 'deferred');
|
deps.store.resolveConfirmation(deps.requestId.value, 'deferred');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user