Skip to content

Commit

Permalink
chore: Add toolkit restriction
Browse files Browse the repository at this point in the history
  • Loading branch information
ramedina86 committed Sep 30, 2024
1 parent 7fc7b8c commit 5adc442
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/ui/src/core/typeHierarchy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,30 @@ function getAllowedSet(
): Set<Component["type"]> {
const { type, parentId } = components[componentId];
const supportedTypes = getSupportedComponentTypes().filter(
(t) => t !== "root",
(t) => t !== "root" && t !== "workflows_root",
);
const { allowedChildrenTypes } = getComponentDefinition(type);
const { allowedChildrenTypes, toolkit } = getComponentDefinition(type);
if (!allowedChildrenTypes) return new Set([]);

let allowed = new Set<string>(allowedChildrenTypes);
let allowed: Set<string> = new Set(allowedChildrenTypes);
if (allowedChildrenTypes.includes("*")) {
return new Set(supportedTypes);
allowed = new Set([...allowed, ...supportedTypes]);
}
if (allowed.delete("inherit")) {
if (!parentId) return allowed;
const parentContainable = getContainableTypes(components, parentId);
allowed = new Set([...allowed, ...parentContainable]);
}

if (toolkit) {
allowed = new Set(
Array.from(allowed).filter(
(childType) =>
getComponentDefinition(childType).toolkit == toolkit,
),
);
}

return allowed;
}

Expand Down

0 comments on commit 5adc442

Please sign in to comment.