From eb0230d13c0464d94ea00f0e3ac4a36a7ccbf5bb Mon Sep 17 00:00:00 2001 From: Marin Minnerly Date: Mon, 16 Dec 2024 15:02:53 -0800 Subject: [PATCH] Only show unavailable storybooks if there are any --- src/Storybook/StorybookTreeView.luau | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/Storybook/StorybookTreeView.luau b/src/Storybook/StorybookTreeView.luau index 87d48d37..ad11aad4 100644 --- a/src/Storybook/StorybookTreeView.luau +++ b/src/Storybook/StorybookTreeView.luau @@ -42,19 +42,21 @@ local function StorybookTreeView(props: Props) storybookByNodeId.current[root.id] = storybook end - local unavailableStorybooks: TreeNode = { - id = HttpService:GenerateGUID(), - label = "Unavailable Storybooks", - icon = "folder", - isExpanded = false, - children = {}, - } - for _, unavailableStorybook in props.storybooks.unavailable do - local root = createTreeNodesForStorybook(unavailableStorybook.storybook) - table.insert(unavailableStorybooks.children, root) - storybookByNodeId.current[root.id] = unavailableStorybook.storybook + if #props.storybooks.unavailable > 0 then + local unavailableStorybooks: TreeNode = { + id = HttpService:GenerateGUID(), + label = "Unavailable Storybooks", + icon = "folder", + isExpanded = false, + children = {}, + } + for _, unavailableStorybook in props.storybooks.unavailable do + local root = createTreeNodesForStorybook(unavailableStorybook.storybook) + table.insert(unavailableStorybooks.children, root) + storybookByNodeId.current[root.id] = unavailableStorybook.storybook + end + table.insert(roots, unavailableStorybooks) end - table.insert(roots, unavailableStorybooks) treeViewContext.setRoots(roots)