mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
✨ Load node properties on demand (#1089)
* ⚡ Changed rest api endpoint to omit node properties by default. ⚡ Created another endpoint to return all node information based on a list of names * refactor: changed endpoint to POST instead of GET * Changed properties to be optional for node description * Removed eager loading for node properties. All nodes will have their properties fetched when used in a workflow. Works when opening an already saved workflow, creating a new one from scratch or pasting JSON / URLs. * Removing unnecessary dependency
This commit is contained in:
@@ -1563,6 +1563,11 @@ export default mixins(
|
||||
return;
|
||||
}
|
||||
|
||||
// Before proceeding we must check if all nodes contain the `properties` attribute.
|
||||
// Nodes are loaded without this information so we must make sure that all nodes
|
||||
// being added have this information.
|
||||
await this.loadNodesProperties(nodes.map(node => node.type));
|
||||
|
||||
// Add the node to the node-list
|
||||
let nodeType: INodeTypeDescription | null;
|
||||
let foundNodeIssues: INodeIssues | null;
|
||||
@@ -1673,6 +1678,9 @@ export default mixins(
|
||||
let oldName: string;
|
||||
let newName: string;
|
||||
const createNodes: INode[] = [];
|
||||
|
||||
await this.loadNodesProperties(data.nodes.map(node => node.type));
|
||||
|
||||
data.nodes.forEach(node => {
|
||||
if (nodeTypesCount[node.type] !== undefined) {
|
||||
if (nodeTypesCount[node.type].exist >= nodeTypesCount[node.type].max) {
|
||||
@@ -1896,6 +1904,17 @@ export default mixins(
|
||||
const credentials = await this.restApi().getAllCredentials();
|
||||
this.$store.commit('setCredentials', credentials);
|
||||
},
|
||||
async loadNodesProperties(nodeNames: string[]): Promise<void> {
|
||||
const allNodes = this.$store.getters.allNodeTypes;
|
||||
const nodesToBeFetched = allNodes.filter((node: INodeTypeDescription) => nodeNames.includes(node.name) && !node.hasOwnProperty('properties')).map((node: INodeTypeDescription) => node.name) as string[];
|
||||
if (nodesToBeFetched.length > 0) {
|
||||
// Only call API if node information is actually missing
|
||||
this.startLoading();
|
||||
const nodeInfo = await this.restApi().getNodesInformation(nodesToBeFetched);
|
||||
this.$store.commit('updateNodeTypes', nodeInfo);
|
||||
this.stopLoading();
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
async mounted () {
|
||||
|
||||
Reference in New Issue
Block a user