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)"

445463a605
This commit is contained in:
Mutasem Aldmour 2022-12-22 18:48:53 +01:00 committed by GitHub
parent 789682763c
commit e7cb1907cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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