Skip to content

Commit

Permalink
fix(editor): Fix displaying of some trigger nodes in the creator panel (
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegIvaniv authored Dec 28, 2022
1 parent 18140e0 commit 4daf905
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions packages/editor-ui/src/stores/nodeCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,16 @@ export const useNodeCreatorStore = defineStore(STORES.NODE_CREATOR, {
return nodesWithActions;
},
mergedAppNodes(): INodeTypeDescription[] {
const mergedNodes = this.visibleNodesWithActions.reduce(
(acc: Record<string, INodeTypeDescription>, node: INodeTypeDescription) => {
const mergedNodes = [...this.visibleNodesWithActions]
// 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 isCoreNode = node.codex?.categories?.includes(CORE_NODES_CATEGORY);
const actions = node.actions || [];
Expand All @@ -324,14 +332,15 @@ export const useNodeCreatorStore = defineStore(STORES.NODE_CREATOR, {
acc[normalizedName].displayName = node.displayName.replace('Trigger', '');
}

acc[normalizedName].actions = filterSinglePlaceholderAction(
acc[normalizedName].actions || [],
);
return acc;
},
{},
);
return Object.values(mergedNodes);
}, {});

const filteredNodes = Object.values(mergedNodes).map((node) => ({
...node,
actions: filterSinglePlaceholderAction(node.actions || []),
}));

return filteredNodes;
},
getNodeTypesWithManualTrigger:
() =>
Expand Down

0 comments on commit 4daf905

Please sign in to comment.