feat(editor): Open NDV when a node is added to canvas v2 (no-changelog) (#10114)

This commit is contained in:
Elias Meire 2024-07-19 14:29:11 +02:00 committed by GitHub
parent 4559e3ae18
commit 062633ec9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 1 deletions

View file

@ -167,6 +167,20 @@ describe('useCanvasOperations', () => {
});
expect(result.credentials).toBeUndefined();
});
it('should open NDV when specified', async () => {
nodeTypesStore.setNodeTypes([mockNodeTypeDescription({ name: 'type' })]);
await canvasOperations.addNode(
{
type: 'type',
name: 'Test Name',
},
{ openNDV: true },
);
expect(ndvStore.activeNodeName).toBe('Test Name');
});
});
describe('updateNodePosition', () => {

View file

@ -76,7 +76,7 @@ import type {
import { NodeConnectionType, NodeHelpers, TelemetryHelpers } from 'n8n-workflow';
import { v4 as uuid } from 'uuid';
import type { Ref } from 'vue';
import { computed } from 'vue';
import { computed, nextTick } from 'vue';
import type { useRouter } from 'vue-router';
type AddNodeData = Partial<INodeUi> & {
@ -429,6 +429,12 @@ export function useCanvasOperations({
workflowsStore.setNodePristine(nodeData.name, true);
uiStore.stateIsDirty = true;
if (options.openNDV) {
void nextTick(() => {
ndvStore.setActiveNodeName(nodeData.name);
});
}
return nodeData;
}