mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-09 22:24:05 -08:00
feat(editor): Add support for nodes with multiple main inputs in new canvas (no-changelog) (#10659)
This commit is contained in:
parent
fa31164a48
commit
a5a92ec8b1
|
@ -26,6 +26,46 @@ describe('CanvasNodeDefault', () => {
|
||||||
expect(getByTestId('canvas-default-node')).toMatchSnapshot();
|
expect(getByTestId('canvas-default-node')).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('inputs', () => {
|
||||||
|
it('should adjust height css variable based on the number of inputs (1 input)', () => {
|
||||||
|
const { getByText } = renderComponent({
|
||||||
|
global: {
|
||||||
|
provide: {
|
||||||
|
...createCanvasNodeProvide({
|
||||||
|
data: {
|
||||||
|
inputs: [{ type: NodeConnectionType.Main, index: 0 }],
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const nodeElement = getByText('Test Node').closest('.node');
|
||||||
|
expect(nodeElement).toHaveStyle({ '--canvas-node--main-input-count': '1' }); // height calculation based on the number of inputs
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should adjust height css variable based on the number of inputs (multiple inputs)', () => {
|
||||||
|
const { getByText } = renderComponent({
|
||||||
|
global: {
|
||||||
|
provide: {
|
||||||
|
...createCanvasNodeProvide({
|
||||||
|
data: {
|
||||||
|
inputs: [
|
||||||
|
{ type: NodeConnectionType.Main, index: 0 },
|
||||||
|
{ type: NodeConnectionType.Main, index: 0 },
|
||||||
|
{ type: NodeConnectionType.Main, index: 0 },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const nodeElement = getByText('Test Node').closest('.node');
|
||||||
|
expect(nodeElement).toHaveStyle({ '--canvas-node--main-input-count': '3' }); // height calculation based on the number of inputs
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('outputs', () => {
|
describe('outputs', () => {
|
||||||
it('should adjust height css variable based on the number of outputs (1 output)', () => {
|
it('should adjust height css variable based on the number of outputs (1 output)', () => {
|
||||||
const { getByText } = renderComponent({
|
const { getByText } = renderComponent({
|
||||||
|
|
|
@ -30,7 +30,7 @@ const {
|
||||||
hasIssues,
|
hasIssues,
|
||||||
render,
|
render,
|
||||||
} = useCanvasNode();
|
} = useCanvasNode();
|
||||||
const { mainOutputs, nonMainInputs, requiredNonMainInputs } = useNodeConnections({
|
const { mainOutputs, mainInputs, nonMainInputs, requiredNonMainInputs } = useNodeConnections({
|
||||||
inputs,
|
inputs,
|
||||||
outputs,
|
outputs,
|
||||||
connections,
|
connections,
|
||||||
|
@ -67,6 +67,7 @@ const styles = computed(() => {
|
||||||
stylesObject['--configurable-node--input-count'] = nonMainInputs.value.length + spacerCount;
|
stylesObject['--configurable-node--input-count'] = nonMainInputs.value.length + spacerCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stylesObject['--canvas-node--main-input-count'] = mainInputs.value.length;
|
||||||
stylesObject['--canvas-node--main-output-count'] = mainOutputs.value.length;
|
stylesObject['--canvas-node--main-output-count'] = mainOutputs.value.length;
|
||||||
|
|
||||||
return stylesObject;
|
return stylesObject;
|
||||||
|
@ -115,7 +116,12 @@ function openContextMenu(event: MouseEvent) {
|
||||||
|
|
||||||
<style lang="scss" module>
|
<style lang="scss" module>
|
||||||
.node {
|
.node {
|
||||||
--canvas-node--height: calc(100px + max(0, var(--canvas-node--main-output-count, 1) - 4) * 48px);
|
--canvas-node--max-vertical-handles: max(
|
||||||
|
var(--canvas-node--main-input-count),
|
||||||
|
var(--canvas-node--main-output-count),
|
||||||
|
1
|
||||||
|
);
|
||||||
|
--canvas-node--height: calc(100px + max(0, var(--canvas-node--max-vertical-handles) - 3) * 42px);
|
||||||
--canvas-node--width: 100px;
|
--canvas-node--width: 100px;
|
||||||
--canvas-node-border-width: 2px;
|
--canvas-node-border-width: 2px;
|
||||||
--configurable-node--min-input-count: 4;
|
--configurable-node--min-input-count: 4;
|
||||||
|
|
|
@ -4,7 +4,7 @@ exports[`CanvasNodeDefault > configurable > should render configurable node corr
|
||||||
<div
|
<div
|
||||||
class="node configurable"
|
class="node configurable"
|
||||||
data-test-id="canvas-configurable-node"
|
data-test-id="canvas-configurable-node"
|
||||||
style="--canvas-node--main-output-count: 0;"
|
style="--canvas-node--main-input-count: 0; --canvas-node--main-output-count: 0;"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ exports[`CanvasNodeDefault > configuration > should render configurable configur
|
||||||
<div
|
<div
|
||||||
class="node configurable configuration"
|
class="node configurable configuration"
|
||||||
data-test-id="canvas-configurable-node"
|
data-test-id="canvas-configurable-node"
|
||||||
style="--canvas-node--main-output-count: 0;"
|
style="--canvas-node--main-input-count: 0; --canvas-node--main-output-count: 0;"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ exports[`CanvasNodeDefault > configuration > should render configuration node co
|
||||||
<div
|
<div
|
||||||
class="node configuration"
|
class="node configuration"
|
||||||
data-test-id="canvas-configuration-node"
|
data-test-id="canvas-configuration-node"
|
||||||
style="--canvas-node--main-output-count: 0;"
|
style="--canvas-node--main-input-count: 0; --canvas-node--main-output-count: 0;"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ exports[`CanvasNodeDefault > should render node correctly 1`] = `
|
||||||
<div
|
<div
|
||||||
class="node"
|
class="node"
|
||||||
data-test-id="canvas-default-node"
|
data-test-id="canvas-default-node"
|
||||||
style="--canvas-node--main-output-count: 0;"
|
style="--canvas-node--main-input-count: 0; --canvas-node--main-output-count: 0;"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ exports[`CanvasNodeDefault > trigger > should render trigger node correctly 1`]
|
||||||
<div
|
<div
|
||||||
class="node trigger"
|
class="node trigger"
|
||||||
data-test-id="canvas-trigger-node"
|
data-test-id="canvas-trigger-node"
|
||||||
style="--canvas-node--main-output-count: 0;"
|
style="--canvas-node--main-input-count: 0; --canvas-node--main-output-count: 0;"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue