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"
|
||||
>
|
||||
<NodeIcon
|
||||
v-if="nodeTypeDescription"
|
||||
:node-type="nodeTypeDescription"
|
||||
:size="nodeIconSize"
|
||||
:shrink="false"
|
||||
|
|
|
@ -102,15 +102,6 @@ describe('useCanvasOperations', () => {
|
|||
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', () => {
|
||||
const nodeTypesStore = useNodeTypesStore();
|
||||
const type = 'testTypeWithoutVersion';
|
||||
|
@ -123,6 +114,25 @@ describe('useCanvasOperations', () => {
|
|||
|
||||
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', () => {
|
||||
|
|
|
@ -445,16 +445,23 @@ export function useCanvasOperations({ router }: { router: ReturnType<typeof useR
|
|||
historyStore.stopRecordingUndo();
|
||||
}
|
||||
|
||||
function requireNodeTypeDescription(type: INodeUi['type'], version?: INodeUi['typeVersion']) {
|
||||
const nodeTypeDescription = nodeTypesStore.getNodeType(type, version);
|
||||
if (!nodeTypeDescription) {
|
||||
throw new Error(
|
||||
i18n.baseText('nodeView.showMessage.addNodeButton.message', {
|
||||
interpolate: { nodeTypeName: type },
|
||||
}),
|
||||
);
|
||||
function requireNodeTypeDescription(
|
||||
type: INodeUi['type'],
|
||||
version?: INodeUi['typeVersion'],
|
||||
): INodeTypeDescription {
|
||||
return (
|
||||
nodeTypesStore.getNodeType(type, version) ?? {
|
||||
properties: [],
|
||||
displayName: type,
|
||||
name: type,
|
||||
group: [],
|
||||
description: '',
|
||||
version: version ?? 1,
|
||||
defaults: {},
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
}
|
||||
return nodeTypeDescription;
|
||||
);
|
||||
}
|
||||
|
||||
async function addNodes(
|
||||
|
|
Loading…
Reference in a new issue