mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(editor): Replace native Array.prototype.findLast with lodash.findLast (no-changelog) (#6885)
fix(editor): Replace native Array.findLast with lodash.findLast Signed-off-by: Oleg Ivaniv <me@olegivaniv.com>
This commit is contained in:
parent
b82cf5603a
commit
990068ff07
|
@ -32,6 +32,7 @@ import type {
|
||||||
IWorkflowDb,
|
IWorkflowDb,
|
||||||
IWorkflowsMap,
|
IWorkflowsMap,
|
||||||
WorkflowsState,
|
WorkflowsState,
|
||||||
|
NodeMetadataMap,
|
||||||
} from '@/Interface';
|
} from '@/Interface';
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
import type {
|
import type {
|
||||||
|
@ -58,6 +59,7 @@ import type {
|
||||||
IWorkflowSettings,
|
IWorkflowSettings,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
import { deepCopy, NodeHelpers, Workflow } from 'n8n-workflow';
|
import { deepCopy, NodeHelpers, Workflow } from 'n8n-workflow';
|
||||||
|
import { findLast } from 'lodash-es';
|
||||||
|
|
||||||
import { useRootStore } from './n8nRoot.store';
|
import { useRootStore } from './n8nRoot.store';
|
||||||
import {
|
import {
|
||||||
|
@ -84,7 +86,6 @@ import { useNDVStore } from './ndv.store';
|
||||||
import { useNodeTypesStore } from './nodeTypes.store';
|
import { useNodeTypesStore } from './nodeTypes.store';
|
||||||
import { useUsersStore } from '@/stores/users.store';
|
import { useUsersStore } from '@/stores/users.store';
|
||||||
import { useSettingsStore } from '@/stores/settings.store';
|
import { useSettingsStore } from '@/stores/settings.store';
|
||||||
import type { NodeMetadataMap } from '@/Interface';
|
|
||||||
|
|
||||||
const defaults: Omit<IWorkflowDb, 'id'> & { settings: NonNullable<IWorkflowDb['settings']> } = {
|
const defaults: Omit<IWorkflowDb, 'id'> & { settings: NonNullable<IWorkflowDb['settings']> } = {
|
||||||
name: '',
|
name: '',
|
||||||
|
@ -157,10 +158,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {
|
||||||
workflowTriggerNodes(): INodeUi[] {
|
workflowTriggerNodes(): INodeUi[] {
|
||||||
return this.workflow.nodes.filter((node: INodeUi) => {
|
return this.workflow.nodes.filter((node: INodeUi) => {
|
||||||
const nodeTypesStore = useNodeTypesStore();
|
const nodeTypesStore = useNodeTypesStore();
|
||||||
const nodeType = nodeTypesStore.getNodeType(
|
const nodeType = nodeTypesStore.getNodeType(node.type, node.typeVersion);
|
||||||
node.type as string,
|
|
||||||
node.typeVersion as number,
|
|
||||||
);
|
|
||||||
return nodeType && nodeType.group.includes('trigger');
|
return nodeType && nodeType.group.includes('trigger');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -168,11 +166,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {
|
||||||
return !!this.workflow.nodes.find((node: INodeUi) => !!node.webhookId);
|
return !!this.workflow.nodes.find((node: INodeUi) => !!node.webhookId);
|
||||||
},
|
},
|
||||||
getWorkflowRunData(): IRunData | null {
|
getWorkflowRunData(): IRunData | null {
|
||||||
if (
|
if (!this.workflowExecutionData?.data?.resultData) {
|
||||||
!this.workflowExecutionData ||
|
|
||||||
!this.workflowExecutionData.data ||
|
|
||||||
!this.workflowExecutionData.data.resultData
|
|
||||||
) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return this.workflowExecutionData.data.resultData.runData;
|
return this.workflowExecutionData.data.resultData.runData;
|
||||||
|
@ -260,13 +254,12 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {
|
||||||
return this.workflowExecutionData ? this.workflowExecutionData.executedNode : undefined;
|
return this.workflowExecutionData ? this.workflowExecutionData.executedNode : undefined;
|
||||||
},
|
},
|
||||||
getParametersLastUpdate(): (name: string) => number | undefined {
|
getParametersLastUpdate(): (name: string) => number | undefined {
|
||||||
return (nodeName: string) =>
|
return (nodeName: string) => this.nodeMetadata[nodeName]?.parametersLastUpdatedAt;
|
||||||
this.nodeMetadata[nodeName] && this.nodeMetadata[nodeName].parametersLastUpdatedAt;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
isNodePristine(): (name: string) => boolean {
|
isNodePristine(): (name: string) => boolean {
|
||||||
return (nodeName: string) =>
|
return (nodeName: string) =>
|
||||||
this.nodeMetadata[nodeName] === undefined || this.nodeMetadata[nodeName].pristine === true;
|
this.nodeMetadata[nodeName] === undefined || this.nodeMetadata[nodeName].pristine;
|
||||||
},
|
},
|
||||||
// Executions getters
|
// Executions getters
|
||||||
getExecutionDataById(): (id: string) => IExecutionsSummary | undefined {
|
getExecutionDataById(): (id: string) => IExecutionsSummary | undefined {
|
||||||
|
@ -452,7 +445,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {
|
||||||
this.workflow.usedCredentials = data;
|
this.workflow.usedCredentials = data;
|
||||||
this.usedCredentials = data.reduce<{ [name: string]: IUsedCredential }>(
|
this.usedCredentials = data.reduce<{ [name: string]: IUsedCredential }>(
|
||||||
(accu, credential) => {
|
(accu, credential) => {
|
||||||
accu[credential.id!] = credential;
|
accu[credential.id] = credential;
|
||||||
return accu;
|
return accu;
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
|
@ -488,7 +481,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {
|
||||||
const nodeCredentials: INodeCredentials | undefined = (node as unknown as INode)
|
const nodeCredentials: INodeCredentials | undefined = (node as unknown as INode)
|
||||||
.credentials;
|
.credentials;
|
||||||
|
|
||||||
if (!nodeCredentials || !nodeCredentials[data.type]) {
|
if (!nodeCredentials?.[data.type]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -762,7 +755,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Add the new connection if it does not exist already
|
// Add the new connection if it does not exist already
|
||||||
if (connectionExists === false) {
|
if (!connectionExists) {
|
||||||
this.workflow.connections[sourceData.node][sourceData.type][sourceData.index].push(
|
this.workflow.connections[sourceData.node][sourceData.type][sourceData.index].push(
|
||||||
destinationData,
|
destinationData,
|
||||||
);
|
);
|
||||||
|
@ -858,8 +851,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {
|
||||||
// If node has any WorkflowResultData rename also that one that the data
|
// If node has any WorkflowResultData rename also that one that the data
|
||||||
// does still get displayed also after node got renamed
|
// does still get displayed also after node got renamed
|
||||||
if (
|
if (
|
||||||
this.workflowExecutionData !== null &&
|
this.workflowExecutionData?.data &&
|
||||||
this.workflowExecutionData.data &&
|
|
||||||
this.workflowExecutionData.data.resultData.runData.hasOwnProperty(nameData.old)
|
this.workflowExecutionData.data.resultData.runData.hasOwnProperty(nameData.old)
|
||||||
) {
|
) {
|
||||||
this.workflowExecutionData.data.resultData.runData[nameData.new] =
|
this.workflowExecutionData.data.resultData.runData[nameData.new] =
|
||||||
|
@ -919,11 +911,11 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const node = this.workflow.nodes[nodeIndex!];
|
const node = this.workflow.nodes[nodeIndex];
|
||||||
|
|
||||||
if (nodeIssueData.value === null) {
|
if (nodeIssueData.value === null) {
|
||||||
// Remove the value if one exists
|
// Remove the value if one exists
|
||||||
if (node.issues === undefined || node.issues[nodeIssueData.type] === undefined) {
|
if (node.issues?.[nodeIssueData.type] === undefined) {
|
||||||
// No values for type exist so nothing has to get removed
|
// No values for type exist so nothing has to get removed
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1079,7 +1071,8 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {
|
||||||
},
|
},
|
||||||
|
|
||||||
setLastNodeParameters(updateInformation: IUpdateInformation) {
|
setLastNodeParameters(updateInformation: IUpdateInformation) {
|
||||||
const latestNode = this.workflow.nodes.findLast(
|
const latestNode = findLast(
|
||||||
|
this.workflow.nodes,
|
||||||
(node) => node.type === updateInformation.key,
|
(node) => node.type === updateInformation.key,
|
||||||
) as INodeUi;
|
) as INodeUi;
|
||||||
const nodeType = useNodeTypesStore().getNodeType(latestNode.type);
|
const nodeType = useNodeTypesStore().getNodeType(latestNode.type);
|
||||||
|
@ -1097,7 +1090,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {
|
||||||
},
|
},
|
||||||
|
|
||||||
addNodeExecutionData(pushData: IPushDataNodeExecuteAfter): void {
|
addNodeExecutionData(pushData: IPushDataNodeExecuteAfter): void {
|
||||||
if (this.workflowExecutionData === null || !this.workflowExecutionData.data) {
|
if (!this.workflowExecutionData?.data) {
|
||||||
throw new Error('The "workflowExecutionData" is not initialized!');
|
throw new Error('The "workflowExecutionData" is not initialized!');
|
||||||
}
|
}
|
||||||
if (this.workflowExecutionData.data.resultData.runData[pushData.nodeName] === undefined) {
|
if (this.workflowExecutionData.data.resultData.runData[pushData.nodeName] === undefined) {
|
||||||
|
@ -1119,7 +1112,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {
|
||||||
this.workflowExecutionPairedItemMappings = getPairedItemsMapping(this.workflowExecutionData);
|
this.workflowExecutionPairedItemMappings = getPairedItemsMapping(this.workflowExecutionData);
|
||||||
},
|
},
|
||||||
clearNodeExecutionData(nodeName: string): void {
|
clearNodeExecutionData(nodeName: string): void {
|
||||||
if (this.workflowExecutionData === null || !this.workflowExecutionData.data) {
|
if (!this.workflowExecutionData?.data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1138,7 +1131,7 @@ export const useWorkflowsStore = defineStore(STORES.WORKFLOWS, {
|
||||||
},
|
},
|
||||||
|
|
||||||
pinDataByNodeName(nodeName: string): INodeExecutionData[] | undefined {
|
pinDataByNodeName(nodeName: string): INodeExecutionData[] | undefined {
|
||||||
if (!this.workflow.pinData || !this.workflow.pinData[nodeName]) return undefined;
|
if (!this.workflow.pinData?.[nodeName]) return undefined;
|
||||||
|
|
||||||
return this.workflow.pinData[nodeName].map((item) => item.json) as INodeExecutionData[];
|
return this.workflow.pinData[nodeName].map((item) => item.json) as INodeExecutionData[];
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue