fix(editor): Fix displaying of some trigger nodes in the creator panel (#5040)

This commit is contained in:
OlegIvaniv 2022-12-28 09:21:22 +01:00 committed by GitHub
parent 18140e059b
commit 4daf905ce2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -306,8 +306,16 @@ 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
// they won't be discarded 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;
return 0;
})
.reduce((acc: Record<string, INodeTypeDescription>, node: INodeTypeDescription) => {
const clonedNode = deepCopy(node); const clonedNode = deepCopy(node);
const isCoreNode = node.codex?.categories?.includes(CORE_NODES_CATEGORY); const isCoreNode = node.codex?.categories?.includes(CORE_NODES_CATEGORY);
const actions = node.actions || []; const actions = node.actions || [];
@ -324,14 +332,15 @@ export const useNodeCreatorStore = defineStore(STORES.NODE_CREATOR, {
acc[normalizedName].displayName = node.displayName.replace('Trigger', ''); acc[normalizedName].displayName = node.displayName.replace('Trigger', '');
} }
acc[normalizedName].actions = filterSinglePlaceholderAction(
acc[normalizedName].actions || [],
);
return acc; return acc;
}, }, {});
{},
); const filteredNodes = Object.values(mergedNodes).map((node) => ({
return Object.values(mergedNodes); ...node,
actions: filterSinglePlaceholderAction(node.actions || []),
}));
return filteredNodes;
}, },
getNodeTypesWithManualTrigger: getNodeTypesWithManualTrigger:
() => () =>