fix(editor): Correctly display trigger nodes without actions and with related regular node in the "On App Events" category (#4976)

Fix an issue where trigger nodes without action and with related regular node wouldn't show in the "On App Events" category
This commit is contained in:
OlegIvaniv
2022-12-19 17:42:30 +01:00
committed by GitHub
parent 570ed3b521
commit 445463a605

View File

@@ -305,31 +305,40 @@ export const useNodeCreatorStore = defineStore(STORES.NODE_CREATOR, {
return nodesWithActions; return nodesWithActions;
}, },
mergedAppNodes(): INodeTypeDescription[] { mergedAppNodes(): INodeTypeDescription[] {
const mergedNodes = this.visibleNodesWithActions.reduce( const mergedNodes = [...this.visibleNodesWithActions]
(acc: Record<string, INodeTypeDescription>, node: INodeTypeDescription) => { // Sort triggers so they are always on top and when later get merged
const clonedNode = deepCopy(node); // they won't be disacrded if they have the same name as a core node which doesn't contain actions
const isCoreNode = node.codex?.categories?.includes(CORE_NODES_CATEGORY); .sort((a, b) => {
const actions = node.actions || []; if (a.group.includes('trigger')) return -1;
// Do not merge core nodes if (b.group.includes('trigger')) return 1;
const normalizedName = isCoreNode
? node.name
: node.name.toLowerCase().replace('trigger', '');
const existingNode = acc[normalizedName];
if (existingNode) existingNode.actions?.push(...actions); return 0;
else acc[normalizedName] = clonedNode; })
.reduce(
(acc: Record<string, INodeTypeDescription>, node: INodeTypeDescription) => {
const clonedNode = deepCopy(node);
const isCoreNode = node.codex?.categories?.includes(CORE_NODES_CATEGORY);
const actions = node.actions || [];
// Do not merge core nodes
const normalizedName = isCoreNode
? node.name
: node.name.toLowerCase().replace('trigger', '');
const existingNode = acc[normalizedName];
if (!isCoreNode) { if (existingNode) existingNode.actions?.push(...actions);
acc[normalizedName].displayName = node.displayName.replace('Trigger', ''); else acc[normalizedName] = clonedNode;
}
acc[normalizedName].actions = filterSinglePlaceholderAction( if (!isCoreNode) {
acc[normalizedName].actions || [], acc[normalizedName].displayName = node.displayName.replace('Trigger', '');
); }
return acc;
}, acc[normalizedName].actions = filterSinglePlaceholderAction(
{}, acc[normalizedName].actions || [],
); );
return acc;
},
{},
);
return Object.values(mergedNodes); return Object.values(mergedNodes);
}, },
getNodeTypesWithManualTrigger: getNodeTypesWithManualTrigger: