Skip to content

Commit

Permalink
allow for prefix matching
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanKolnik committed Apr 6, 2022
1 parent 8e29abd commit 24c2da2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/ui/src/components/preview/toolbar.tsx
Expand Up @@ -221,7 +221,12 @@ export function filterTools(
toolbarExclusions: string[];
}
) {
const filteredTabs = tabs.filter((t) => !toolbarExclusions.includes(t.id));
const isToolIncluded = (id: string) =>
toolbarExclusions.filter((exclusionKey) => id.match(new RegExp(`^${exclusionKey}.*`)))
.length === 0;

const filteredTabs = tabs.filter((tab) => isToolIncluded(tab.id));

const toolsLeft = [
menuTool,
filteredTabs.filter((p) => !p.hidden).length >= 1 && createTabsTool(filteredTabs),
Expand All @@ -240,7 +245,7 @@ export function filterTools(
path,
})) &&
!toolbarItemHasBeenExcluded(item, story) &&
!toolbarExclusions.includes(item.id);
isToolIncluded(item.id);

const left = toolsLeft.filter(filter);
const right = toolsRight.filter(filter);
Expand Down

0 comments on commit 24c2da2

Please sign in to comment.