From e7cb1907cdf90e9497c24f39f3e9b53e5470762c Mon Sep 17 00:00:00 2001 From: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com> Date: Thu, 22 Dec 2022 18:48:53 +0100 Subject: [PATCH] fix: Show trigger actions again in nodes panel (#5016) Revert "fix(editor): Correctly display trigger nodes without actions and with related regular node in the "On App Events" category (#4976)" 445463a605f5f327f897b23a9b4504939358d0df --- packages/editor-ui/src/stores/nodeCreator.ts | 53 ++++++++------------ 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/packages/editor-ui/src/stores/nodeCreator.ts b/packages/editor-ui/src/stores/nodeCreator.ts index 1466115e6f..caff3a5d4e 100644 --- a/packages/editor-ui/src/stores/nodeCreator.ts +++ b/packages/editor-ui/src/stores/nodeCreator.ts @@ -305,40 +305,31 @@ export const useNodeCreatorStore = defineStore(STORES.NODE_CREATOR, { return nodesWithActions; }, mergedAppNodes(): INodeTypeDescription[] { - const mergedNodes = [...this.visibleNodesWithActions] - // Sort triggers so they are always on top and when later get merged - // they won't be disacrded if they have the same name as a core node which doesn't contain actions - .sort((a, b) => { - if (a.group.includes('trigger')) return -1; - if (b.group.includes('trigger')) return 1; + const mergedNodes = this.visibleNodesWithActions.reduce( + (acc: Record, 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]; - return 0; - }) - .reduce( - (acc: Record, 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 (existingNode) existingNode.actions?.push(...actions); + else acc[normalizedName] = clonedNode; - if (existingNode) existingNode.actions?.push(...actions); - else acc[normalizedName] = clonedNode; + if (!isCoreNode) { + acc[normalizedName].displayName = node.displayName.replace('Trigger', ''); + } - if (!isCoreNode) { - acc[normalizedName].displayName = node.displayName.replace('Trigger', ''); - } - - acc[normalizedName].actions = filterSinglePlaceholderAction( - acc[normalizedName].actions || [], - ); - return acc; - }, - {}, - ); + acc[normalizedName].actions = filterSinglePlaceholderAction( + acc[normalizedName].actions || [], + ); + return acc; + }, + {}, + ); return Object.values(mergedNodes); }, getNodeTypesWithManualTrigger: