From 1f8f5bbc12d8416b1705a2c71e8bc0e204fc7418 Mon Sep 17 00:00:00 2001 From: Dean Date: Wed, 2 Nov 2022 00:41:15 +0000 Subject: [PATCH] General fixes to app list group filtering --- .../bbui/src/Form/Core/PickerDropdown.svelte | 2 ++ packages/bbui/src/Form/PickerDropdown.svelte | 1 + .../apps/_components/AcessFilter.svelte | 26 ++++++++++++++----- .../pages/builder/portal/apps/index.svelte | 24 ++++++++++++++--- 4 files changed, 43 insertions(+), 10 deletions(-) diff --git a/packages/bbui/src/Form/Core/PickerDropdown.svelte b/packages/bbui/src/Form/Core/PickerDropdown.svelte index 604e446099..b0a884738f 100644 --- a/packages/bbui/src/Form/Core/PickerDropdown.svelte +++ b/packages/bbui/src/Form/Core/PickerDropdown.svelte @@ -61,6 +61,7 @@ const onPickPrimary = newValue => { dispatch("pickprimary", newValue) primaryOpen = false + dispatch("closed") } const onClearPrimary = () => { @@ -92,6 +93,7 @@ if (primaryOpen) { event.stopPropagation() primaryOpen = false + dispatch("closed") } } diff --git a/packages/bbui/src/Form/PickerDropdown.svelte b/packages/bbui/src/Form/PickerDropdown.svelte index b64a4bd117..58f68a6386 100644 --- a/packages/bbui/src/Form/PickerDropdown.svelte +++ b/packages/bbui/src/Form/PickerDropdown.svelte @@ -128,5 +128,6 @@ on:blur on:focus on:keyup + on:closed /> diff --git a/packages/builder/src/pages/builder/portal/apps/_components/AcessFilter.svelte b/packages/builder/src/pages/builder/portal/apps/_components/AcessFilter.svelte index 61e9609cc3..08cadc694e 100644 --- a/packages/builder/src/pages/builder/portal/apps/_components/AcessFilter.svelte +++ b/packages/builder/src/pages/builder/portal/apps/_components/AcessFilter.svelte @@ -5,9 +5,16 @@ const dispatch = createEventDispatcher() + let filter = null + $: filteredGroups = !filter + ? $groups + : $groups.filter(group => + group.name?.toLowerCase().includes(filter.toLowerCase()) + ) + $: optionSections = { groups: { - data: $groups, + data: filteredGroups, getLabel: group => group.name, getValue: group => group._id, getIcon: group => group.icon, @@ -15,21 +22,28 @@ }, } - $: appData = [{ id: "", role: "" }] - $: onChange = selected => { const { detail } = selected - if (!detail) return + if (!detail || Object.keys(detail).length == 0) { + dispatch("change", null) + return + } const groupSelected = $groups.find(x => x._id === detail) - const appIds = groupSelected?.apps || null - dispatch("change", appIds) + const appRoleIds = groupSelected?.roles + ? Object.keys(groupSelected?.roles) + : [] + dispatch("change", appRoleIds) } { + filter = null + }} /> diff --git a/packages/builder/src/pages/builder/portal/apps/index.svelte b/packages/builder/src/pages/builder/portal/apps/index.svelte index 0b760c4b4a..562434eaf1 100644 --- a/packages/builder/src/pages/builder/portal/apps/index.svelte +++ b/packages/builder/src/pages/builder/portal/apps/index.svelte @@ -20,7 +20,14 @@ import { store, automationStore } from "builderStore" import { API } from "api" import { onMount } from "svelte" - import { apps, auth, admin, templates, licensing } from "stores/portal" + import { + apps, + auth, + admin, + templates, + licensing, + groups, + } from "stores/portal" import { goto } from "@roxi/routify" import AppRow from "components/start/AppRow.svelte" import { AppStatus } from "constants" @@ -59,10 +66,15 @@ $: enrichedApps = enrichApps($apps, $auth.user, sortBy) $: filteredApps = enrichedApps.filter( app => - app?.name?.toLowerCase().includes(searchTerm.toLowerCase()) && - (accessFilterList !== null ? accessFilterList.includes(app?.appId) : true) + (searchTerm + ? app?.name?.toLowerCase().includes(searchTerm.toLowerCase()) + : true) && + (accessFilterList !== null + ? accessFilterList?.includes( + `${app?.type}_${app?.tenantId}_${app?.appId}` + ) + : true) ) - $: lockedApps = filteredApps.filter(app => app?.lockedYou || app?.lockedOther) $: unlocked = lockedApps?.length === 0 $: automationErrors = getAutomationErrors(enrichedApps) @@ -231,6 +243,10 @@ // always load latest await licensing.init() + if ($licensing.groupsEnabled) { + await groups.actions.init() + } + if ($templates?.length === 0) { notifications.error( "There was a problem loading quick start templates."