mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat(Switch Node): Add support for infinite Switch outputs (#7499)
Github issue / Community forum post (link here to close automatically): https://community.n8n.io/t/add-more-outputs-to-switch-node/3864 --------- Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
This commit is contained in:
@@ -502,6 +502,7 @@ import type {
|
||||
IBinaryKeyData,
|
||||
IDataObject,
|
||||
INodeExecutionData,
|
||||
INodeOutputConfiguration,
|
||||
INodeTypeDescription,
|
||||
IRunData,
|
||||
IRunExecutionData,
|
||||
@@ -543,6 +544,7 @@ import { useWorkflowsStore } from '@/stores/workflows.store';
|
||||
import { useNDVStore } from '@/stores/ndv.store';
|
||||
import { useNodeTypesStore } from '@/stores/nodeTypes.store';
|
||||
import { useToast } from '@/composables';
|
||||
import { isObject } from 'lodash-es';
|
||||
|
||||
const RunDataTable = defineAsyncComponent(async () => import('@/components/RunDataTable.vue'));
|
||||
const RunDataJson = defineAsyncComponent(async () => import('@/components/RunDataJson.vue'));
|
||||
@@ -891,9 +893,8 @@ export default defineComponent({
|
||||
return this.outputIndex;
|
||||
},
|
||||
branches(): ITab[] {
|
||||
function capitalize(name: string) {
|
||||
return name.charAt(0).toLocaleUpperCase() + name.slice(1);
|
||||
}
|
||||
const capitalize = (name: string) => name.charAt(0).toLocaleUpperCase() + name.slice(1);
|
||||
|
||||
const branches: ITab[] = [];
|
||||
|
||||
for (let i = 0; i <= this.maxOutputIndex; i++) {
|
||||
@@ -903,6 +904,7 @@ export default defineComponent({
|
||||
const itemsCount = this.getDataCount(this.runIndex, i);
|
||||
const items = this.$locale.baseText('ndv.output.items', { adjustToNumber: itemsCount });
|
||||
let outputName = this.getOutputName(i);
|
||||
|
||||
if (`${outputName}` === `${i}`) {
|
||||
outputName = `${this.$locale.baseText('ndv.output')} ${outputName}`;
|
||||
} else {
|
||||
@@ -936,6 +938,18 @@ export default defineComponent({
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getResolvedNodeOutputs() {
|
||||
if (this.node && this.nodeType) {
|
||||
const workflow = this.workflowsStore.getCurrentWorkflow();
|
||||
const workflowNode = workflow.getNode(this.node.name);
|
||||
|
||||
if (workflowNode) {
|
||||
const outputs = NodeHelpers.getNodeOutputs(workflow, workflowNode, this.nodeType);
|
||||
return outputs;
|
||||
}
|
||||
}
|
||||
return [];
|
||||
},
|
||||
onItemHover(itemIndex: number | null) {
|
||||
if (itemIndex === null) {
|
||||
this.$emit('itemHover', null);
|
||||
@@ -1287,9 +1301,7 @@ export default defineComponent({
|
||||
this.closeBinaryDataDisplay();
|
||||
let outputTypes: ConnectionTypes[] = [];
|
||||
if (this.nodeType !== null && this.node !== null) {
|
||||
const workflow = this.workflowsStore.getCurrentWorkflow();
|
||||
const workflowNode = workflow.getNode(this.node.name);
|
||||
const outputs = NodeHelpers.getNodeOutputs(workflow, workflowNode, this.nodeType);
|
||||
const outputs = this.getResolvedNodeOutputs();
|
||||
outputTypes = NodeHelpers.getConnectionTypes(outputs);
|
||||
}
|
||||
this.connectionType = outputTypes.length === 0 ? NodeConnectionType.Main : outputTypes[0];
|
||||
@@ -1367,6 +1379,12 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
const nodeType = this.nodeType;
|
||||
const outputs = this.getResolvedNodeOutputs();
|
||||
const outputConfiguration = outputs?.[outputIndex] as INodeOutputConfiguration;
|
||||
|
||||
if (outputConfiguration && isObject(outputConfiguration)) {
|
||||
return outputConfiguration?.displayName;
|
||||
}
|
||||
if (!nodeType?.outputNames || nodeType.outputNames.length <= outputIndex) {
|
||||
return outputIndex + 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user