Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(editor): Show input number for multi-input nodes #4000

Merged
merged 5 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions packages/editor-ui/src/components/InputPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
<template slot="prepend">
<span :class="$style.title">{{ $locale.baseText('ndv.input') }}</span>
</template>
<n8n-option v-for="node in parentNodes" :value="node.name" :key="node.name" class="node-option">
<n8n-option v-for="node of parentNodes" :value="node.name" :key="node.name" class="node-option" :label="`${truncate(node.name)} ${getMultipleNodesText(node.name)}`">
{{ truncate(node.name) }}&nbsp;
<span >{{ $locale.baseText('ndv.input.nodeDistance', {adjustToNumber: node.depth}) }}</span>
<span v-if="getMultipleNodesText(node.name)">{{ getMultipleNodesText(node.name) }}</span>
<span v-else>{{ $locale.baseText('ndv.input.nodeDistance', {adjustToNumber: node.depth}) }}</span>
</n8n-option>
</n8n-select>
<span v-else :class="$style.title">{{ $locale.baseText('ndv.input') }}</span>
Expand Down Expand Up @@ -73,7 +74,7 @@ import { workflowHelpers } from '@/components/mixins/workflowHelpers';
import mixins from 'vue-typed-mixins';
import NodeExecuteButton from './NodeExecuteButton.vue';
import WireMeUp from './WireMeUp.vue';
import { CRON_NODE_TYPE, INTERVAL_NODE_TYPE, LOCAL_STORAGE_MAPPING_FLAG, START_NODE_TYPE } from '@/constants';
import { CRON_NODE_TYPE, INTERVAL_NODE_TYPE, LOCAL_STORAGE_MAPPING_FLAG, START_NODE_TYPE, MULTIPLE_INPUT_NODE_TYPES } from '@/constants';

export default mixins(
workflowHelpers,
Expand Down Expand Up @@ -169,8 +170,23 @@ export default mixins(
const node = this.parentNodes.find((node) => this.currentNode && node.name === this.currentNode.name);
return node ? node.depth: -1;
},
isMultiInputNode (): boolean {
if(!this.activeNode) return false;

return MULTIPLE_INPUT_NODE_TYPES.includes(this.activeNode.type);
},
},
methods: {
getMultipleNodesText(nodeName?: string):string {
if(!this.isMultiInputNode || !this.activeNode) return '';

const currentNodeConnections = this.currentWorkflow.connectionsByDestinationNode[this.activeNode.name].main || [];
const nodeIndex = currentNodeConnections.findIndex( n => n[0] && n[0].node === nodeName);

return nodeIndex >= 0
? this.$locale.baseText('ndv.input.nodePosition', { interpolate: { index: `${nodeIndex + 1}` } })
mutdmour marked this conversation as resolved.
Show resolved Hide resolved
: '';
},
onNodeExecute() {
this.$emit('execute');
if (this.activeNode) {
Expand Down
5 changes: 5 additions & 0 deletions packages/editor-ui/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,17 @@ export const WOOCOMMERCE_TRIGGER_NODE_TYPE = 'n8n-nodes-base.wooCommerceTrigger'
export const XERO_NODE_TYPE = 'n8n-nodes-base.xero';
export const ZENDESK_NODE_TYPE = 'n8n-nodes-base.zendesk';
export const ZENDESK_TRIGGER_NODE_TYPE = 'n8n-nodes-base.zendeskTrigger';
export const MERGE_NODE_TYPE = 'n8n-nodes-base.merge';
OlegIvaniv marked this conversation as resolved.
Show resolved Hide resolved

export const MULTIPLE_OUTPUT_NODE_TYPES = [
IF_NODE_TYPE,
SWITCH_NODE_TYPE,
];

export const MULTIPLE_INPUT_NODE_TYPES = [
mutdmour marked this conversation as resolved.
Show resolved Hide resolved
MERGE_NODE_TYPE,
];

export const PIN_DATA_NODE_TYPES_DENYLIST = [
...MULTIPLE_OUTPUT_NODE_TYPES,
SPLIT_IN_BATCHES_NODE_TYPE,
Expand Down
1 change: 1 addition & 0 deletions packages/editor-ui/src/plugins/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@
"ndv.featureRequest": "I wish this node would...",
"ndv.input": "Input",
"ndv.input.nodeDistance": "({count} node back) | ({count} nodes back)",
"ndv.input.nodePosition": "(Input {index})",
OlegIvaniv marked this conversation as resolved.
Show resolved Hide resolved
"ndv.input.noNodesFound": "No nodes found",
"ndv.input.parentNodes": "Parent nodes",
"ndv.input.tooMuchData.title": "Input data is huge",
Expand Down