feat: Improvements to pairedItem

This commit is contained in:
Jan Oberhauser
2022-07-22 12:19:45 +02:00
parent 2f4f2cfb86
commit 1348349748
19 changed files with 161 additions and 90 deletions

View File

@@ -2,7 +2,7 @@
<div>
<div class="error-header">
<div class="error-message">{{ $locale.baseText('nodeErrorView.error') + ': ' + getErrorMessage() }}</div>
<div class="error-description" v-if="error.description">{{error.description}}</div>
<div class="error-description" v-if="error.description">{{getErrorDescription()}}</div>
</div>
<details>
<summary class="error-details__summary">
@@ -139,6 +139,14 @@ export default mixins(
},
},
methods: {
getErrorDescription (): string {
if (!this.error.context || !this.error.context.descriptionTemplate) {
return this.error.description;
}
const parameterName = this.parameterDisplayName(this.error.context.parameter);
return this.error.context.descriptionTemplate.replace(/%%PARAMETER%%/g, parameterName);
},
getErrorMessage (): string {
if (!this.error.context || !this.error.context.messageTemplate) {
return this.error.message;

View File

@@ -343,7 +343,6 @@ import {
INodeTypeDescription,
IRunData,
IRunExecutionData,
PinData,
} from 'n8n-workflow';
import {

View File

@@ -21,10 +21,10 @@ import {
IContextObject,
IDataObject,
INodeExecutionData,
IPinData,
IRunData,
IRunExecutionData,
IWorkflowDataProxyAdditionalKeys,
PinData,
Workflow,
WorkflowDataProxy,
} from 'n8n-workflow';
@@ -307,11 +307,11 @@ export default mixins(
* Get the node's output using pinData
*
* @param {string} nodeName The name of the node to get the data of
* @param {PinData[string]} pinData The node's pin data
* @param {IPinData[string]} pinData The node's pin data
* @param {string} filterText Filter text for parameters
* @param {boolean} [useShort=false] Use short notation $json vs. $node[NodeName].json
*/
getNodePinDataOutput(nodeName: string, pinData: PinData[string], filterText: string, useShort = false): IVariableSelectorOption[] | null {
getNodePinDataOutput(nodeName: string, pinData: IPinData[string], filterText: string, useShort = false): IVariableSelectorOption[] | null {
const outputData = pinData.map((data) => ({ json: data } as INodeExecutionData))[0];
return this.getNodeOutput(nodeName, outputData, filterText, useShort);

View File

@@ -1,17 +1,17 @@
import Vue from 'vue';
import { INodeUi } from "@/Interface";
import {IDataObject, PinData} from "n8n-workflow";
import {stringSizeInBytes} from "@/components/helpers";
import {MAX_WORKFLOW_PINNED_DATA_SIZE, PIN_DATA_NODE_TYPES_DENYLIST} from "@/constants";
import { INodeUi } from '@/Interface';
import { IPinData } from 'n8n-workflow';
import { stringSizeInBytes } from '@/components/helpers';
import { MAX_WORKFLOW_PINNED_DATA_SIZE, PIN_DATA_NODE_TYPES_DENYLIST } from '@/constants';
interface PinDataContext {
interface IPinDataContext {
node: INodeUi;
$showError(error: Error, title: string): void;
}
export const pinData = (Vue as Vue.VueConstructor<Vue & PinDataContext>).extend({
export const pinData = (Vue as Vue.VueConstructor<Vue & IPinDataContext>).extend({
computed: {
pinData (): PinData[string] | undefined {
pinData (): IPinData[string] | undefined {
return this.node ? this.$store.getters['pinDataByNodeName'](this.node!.name) : undefined;
},
hasPinData (): boolean {

View File

@@ -21,6 +21,7 @@ import {
INodeTypeData,
INodeTypeDescription,
INodeVersionedType,
IPinData,
IRunData,
IRunExecutionData,
IWorfklowIssues,
@@ -30,7 +31,6 @@ import {
IExecuteData,
INodeConnection,
IWebhookDescription,
PinData,
} from 'n8n-workflow';
import {
@@ -330,11 +330,16 @@ export const workflowHelpers = mixins(
const workflowName = this.$store.getters.workflowName;
if (copyData === true) {
return new Workflow({ id: workflowId, name: workflowName, nodes: JSON.parse(JSON.stringify(nodes)), connections: JSON.parse(JSON.stringify(connections)), active: false, nodeTypes, settings: this.$store.getters.workflowSettings});
} else {
return new Workflow({ id: workflowId, name: workflowName, nodes, connections, active: false, nodeTypes, settings: this.$store.getters.workflowSettings});
}
return new Workflow({
id: workflowId,
name: workflowName,
nodes: copyData ? JSON.parse(JSON.stringify(nodes)) : nodes,
connections: copyData? JSON.parse(JSON.stringify(connections)): connections,
active: false,
nodeTypes,
settings: this.$store.getters.workflowSettings,
pinData: this.$store.getters.pinData,
});
},
// Returns the currently loaded workflow as JSON.
@@ -526,7 +531,7 @@ export const workflowHelpers = mixins(
}
parentNode.forEach((parentNodeName) => {
const pinData: PinData[string] = this.$store.getters['pinDataByNodeName'](parentNodeName);
const pinData: IPinData[string] = this.$store.getters['pinDataByNodeName'](parentNodeName);
if (pinData) {
runExecutionData = {