mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
feat(editor): Allow unknown nodes on new canvas (no-changelog) (#10962)
This commit is contained in:
parent
dd3b2cb62d
commit
5ce05b33d2
|
@ -313,7 +313,6 @@ onBeforeUnmount(() => {
|
||||||
@open:contextmenu="onOpenContextMenuFromNode"
|
@open:contextmenu="onOpenContextMenuFromNode"
|
||||||
>
|
>
|
||||||
<NodeIcon
|
<NodeIcon
|
||||||
v-if="nodeTypeDescription"
|
|
||||||
:node-type="nodeTypeDescription"
|
:node-type="nodeTypeDescription"
|
||||||
:size="nodeIconSize"
|
:size="nodeIconSize"
|
||||||
:shrink="false"
|
:shrink="false"
|
||||||
|
|
|
@ -102,15 +102,6 @@ describe('useCanvasOperations', () => {
|
||||||
expect(result).toBe(expectedDescription);
|
expect(result).toBe(expectedDescription);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error when node type does not exist', () => {
|
|
||||||
const type = 'nonexistentType';
|
|
||||||
const { requireNodeTypeDescription } = useCanvasOperations({ router });
|
|
||||||
|
|
||||||
expect(() => {
|
|
||||||
requireNodeTypeDescription(type);
|
|
||||||
}).toThrow();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should return node type description when only type is provided and it exists', () => {
|
it('should return node type description when only type is provided and it exists', () => {
|
||||||
const nodeTypesStore = useNodeTypesStore();
|
const nodeTypesStore = useNodeTypesStore();
|
||||||
const type = 'testTypeWithoutVersion';
|
const type = 'testTypeWithoutVersion';
|
||||||
|
@ -123,6 +114,25 @@ describe('useCanvasOperations', () => {
|
||||||
|
|
||||||
expect(result).toBe(expectedDescription);
|
expect(result).toBe(expectedDescription);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should return placeholder node type description if node type doesn't exist", () => {
|
||||||
|
const type = 'nonexistentType';
|
||||||
|
|
||||||
|
const { requireNodeTypeDescription } = useCanvasOperations({ router });
|
||||||
|
const result = requireNodeTypeDescription(type);
|
||||||
|
|
||||||
|
expect(result).toEqual({
|
||||||
|
name: type,
|
||||||
|
displayName: type,
|
||||||
|
description: '',
|
||||||
|
defaults: {},
|
||||||
|
group: [],
|
||||||
|
inputs: [],
|
||||||
|
outputs: [],
|
||||||
|
properties: [],
|
||||||
|
version: 1,
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('addNode', () => {
|
describe('addNode', () => {
|
||||||
|
|
|
@ -445,16 +445,23 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
|
||||||
historyStore.stopRecordingUndo();
|
historyStore.stopRecordingUndo();
|
||||||
}
|
}
|
||||||
|
|
||||||
function requireNodeTypeDescription(type: INodeUi['type'], version?: INodeUi['typeVersion']) {
|
function requireNodeTypeDescription(
|
||||||
const nodeTypeDescription = nodeTypesStore.getNodeType(type, version);
|
type: INodeUi['type'],
|
||||||
if (!nodeTypeDescription) {
|
version?: INodeUi['typeVersion'],
|
||||||
throw new Error(
|
): INodeTypeDescription {
|
||||||
i18n.baseText('nodeView.showMessage.addNodeButton.message', {
|
return (
|
||||||
interpolate: { nodeTypeName: type },
|
nodeTypesStore.getNodeType(type, version) ?? {
|
||||||
}),
|
properties: [],
|
||||||
);
|
displayName: type,
|
||||||
}
|
name: type,
|
||||||
return nodeTypeDescription;
|
group: [],
|
||||||
|
description: '',
|
||||||
|
version: version ?? 1,
|
||||||
|
defaults: {},
|
||||||
|
inputs: [],
|
||||||
|
outputs: [],
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addNodes(
|
async function addNodes(
|
||||||
|
|
Loading…
Reference in a new issue