From 0f464c268062a12031c9ccb389ad23556da6ff7b Mon Sep 17 00:00:00 2001 From: Cameron Clark Date: Mon, 19 Feb 2024 11:47:07 +0000 Subject: [PATCH] ffix --- .../client/src/framework/workspace/dock.ts | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/how-to/workspace-platform-starter/client/src/framework/workspace/dock.ts b/how-to/workspace-platform-starter/client/src/framework/workspace/dock.ts index fe7570800a..3e48d192e7 100644 --- a/how-to/workspace-platform-starter/client/src/framework/workspace/dock.ts +++ b/how-to/workspace-platform-starter/client/src/framework/workspace/dock.ts @@ -249,7 +249,8 @@ async function buildButtonsFromEntries(entries: DockButtonTypes[]): Promise !isEmpty(button)); + const buttonsFlat = buttons.flat(); + return buttonsFlat.filter((button): button is DockButton => !isEmpty(button)); } /** @@ -341,8 +342,8 @@ async function addEntriesAsDropdown( if (!isStringValue(entry.tooltip)) { logger.error("You must specify the tooltip for a DockButtonDropdown"); } else { - const opts: Promise[] = entry.options.map( - async (option): Promise => { + const opts = entry.options.map( + async (option): Promise => { if (Array.isArray(option.conditions)) { for (const c of option.conditions) { usedConditions.add(c); @@ -403,7 +404,8 @@ async function addEntriesAsDropdown( ); const optionPromises = await Promise.all(opts); - const filteredOptions = optionPromises.filter((o): o is DockButton => !isEmpty(o)); + const optionsFlat = optionPromises.flat(); + const filteredOptions = optionsFlat.filter((o): o is DockButton => !isEmpty(o)); if (filteredOptions.length === 0) { return { @@ -435,7 +437,7 @@ async function addEntriesByAppTag( entry: Omit & { id?: string }, iconFolder: string, colorSchemeMode: ColorSchemeMode -): Promise { +): Promise<(DockButton | undefined)[] | undefined> { if (!Array.isArray(entry.tags)) { logger.error("You must specify an array for the tags parameter for an DockButtonAppsByTag"); } else { @@ -444,10 +446,11 @@ async function addEntriesByAppTag( const dockApps = await getAppsByTag(entry.tags, false, { private: false }); if (entry.display === "individual") { + const entries: DockButton[] = []; // Individual so show a button for each app for (const dockApp of dockApps) { const icon = entry.iconUrl ?? getAppIcon(dockApp); - return { + entries.push({ id: `${entry.id}-${dockApp.appId}`, tooltip: entry.tooltip ?? dockApp.title, iconUrl: themeUrl(icon, iconFolder, colorSchemeMode), @@ -458,8 +461,10 @@ async function addEntriesByAppTag( appId: dockApp.appId } } - }; + }); } + + return entries; } else if (entry.display === "group") { // Group display so show a drop down with all the entries in it if (!isStringValue(entry.tooltip)) { @@ -498,12 +503,14 @@ async function addEntriesByAppTag( }); } - return addDropdownOrMenu( - entry.id, - entry.tooltip ?? "", - themeUrl(iconUrl, iconFolder, colorSchemeMode), - opts - ); + return [ + await addDropdownOrMenu( + entry.id, + entry.tooltip ?? "", + themeUrl(iconUrl, iconFolder, colorSchemeMode), + opts + ) + ]; } } }