diff --git a/packages/bbui/src/Form/Core/PickerDropdown.svelte b/packages/bbui/src/Form/Core/PickerDropdown.svelte index 5682a91218..fbe43717ba 100644 --- a/packages/bbui/src/Form/Core/PickerDropdown.svelte +++ b/packages/bbui/src/Form/Core/PickerDropdown.svelte @@ -233,7 +233,10 @@ {:else if getPrimaryOptionColour(option, idx)} - + {/if} @@ -253,6 +256,7 @@ {#if getPrimaryOptionIcon(option, idx) && getPrimaryOptionColour(option, idx)} @@ -281,7 +285,7 @@ {:else if secondaryFieldColour} - + {/if} @@ -319,6 +323,7 @@ {#if getSecondaryOptionColour(option, idx)} @@ -351,6 +356,13 @@ min-width: 0; width: 100%; } + .spectrum-InputGroup :global(.spectrum-Search-input) { + border: none; + border-bottom: 1px solid var(--spectrum-global-color-gray-300); + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; + } + .override-borders { border-top-left-radius: 0px; border-bottom-left-radius: 0px; diff --git a/packages/builder/src/pages/builder/portal/_layout.svelte b/packages/builder/src/pages/builder/portal/_layout.svelte index 26409ef695..21259c4d84 100644 --- a/packages/builder/src/pages/builder/portal/_layout.svelte +++ b/packages/builder/src/pages/builder/portal/_layout.svelte @@ -72,7 +72,7 @@ href: "/builder/portal/manage/groups", } - menu.splice(1, 0, item) + menu.splice(2, 0, item) } if (!$adminStore.cloud) { diff --git a/packages/builder/src/pages/builder/portal/manage/groups/[groupId].svelte b/packages/builder/src/pages/builder/portal/manage/groups/[groupId].svelte index 2bcfd85cb6..17c16c639b 100644 --- a/packages/builder/src/pages/builder/portal/manage/groups/[groupId].svelte +++ b/packages/builder/src/pages/builder/portal/manage/groups/[groupId].svelte @@ -18,23 +18,44 @@ import { users, apps, groups } from "stores/portal" import { onMount } from "svelte" import { RoleUtils } from "@budibase/frontend-core" + import { roles } from "stores/backend" export let groupId + let popoverAnchor let popover let searchTerm = "" let selectedUsers = [] - let prevSearch = undefined, - search = undefined + let prevSearch = undefined let pageInfo = createPaginationStore() + let loaded = false $: page = $pageInfo.page - $: fetchUsers(page, search) + $: fetchUsers(page, searchTerm) $: group = $groups.find(x => x._id === groupId) async function addAll() { - group.users = selectedUsers + selectedUsers = [...selectedUsers, ...filtered.map(u => u._id)] + + let reducedUserObjects = filtered.map(u => { + return { + _id: u._id, + email: u.email, + } + }) + group.users = [...reducedUserObjects, ...group.users] + await groups.actions.save(group) + + $users.data.forEach(async user => { + let userToEdit = await users.get(user._id) + let userGroups = userToEdit.userGroups || [] + userGroups.push(groupId) + await users.save({ + ...userToEdit, + userGroups, + }) + }) } async function selectUser(id) { @@ -97,106 +118,119 @@ prevSearch = search try { pageInfo.loading() - await users.search({ page, search }) + await users.search({ page, email: search }) pageInfo.fetched($users.hasNextPage, $users.nextPage) } catch (error) { notifications.error("Error getting user list") } } + const getRoleLabel = appId => { + const roleId = group?.roles?.[`app_${appId}`] + const role = $roles.find(x => x._id === roleId) + return role?.name || "Custom role" + } + onMount(async () => { try { - await groups.actions.init() - await apps.load() + await Promise.all([groups.actions.init(), apps.load(), roles.fetch()]) + loaded = true } catch (error) { - notifications.error("Error fetching User Group data") + notifications.error("Error fetching user group data") } }) - -
- $goto("../groups")} size="S" icon="ArrowLeft"> - Back - -
-
-
-
-
- +{#if loaded} + +
+ $goto("../groups")} + size="S" + icon="ArrowLeft" + > + Back + +
+
+
+
+
+ +
+
+
+ {group?.name}
-
- {group?.name} +
+ +
+ + + +
+ + + {#if group?.users.length} + {#each group.users as user} + removeUser(user?._id)} + hoverable + size="L" + name="Close" + /> + {/each} + {:else} + + {/if} + +
+ Apps +
+ Manage apps that this User group has been assigned to
-
- -
- - - -
- - {#if group?.users.length} - {#each group.users as user} - removeUser(user?._id)} - hoverable - size="L" - name="Close" - /> - {/each} - {:else} - - {/if} - -
- Apps -
- Manage apps that this User group has been assigned to -
-
- - - {#if groupApps.length} - {#each groupApps as app} - -
- -
- {group.roles[app.appId]} + + {#if groupApps.length} + {#each groupApps as app} + +
+ + {getRoleLabel(app.appId)} +
-
- - {/each} - {:else} - - {/if} - - + + {/each} + {:else} + + {/if} + + +{/if} diff --git a/packages/builder/src/pages/builder/portal/manage/users/_components/AddUserModal.svelte b/packages/builder/src/pages/builder/portal/manage/users/_components/AddUserModal.svelte index b1e26c03e8..fc9c4b8cf2 100644 --- a/packages/builder/src/pages/builder/portal/manage/users/_components/AddUserModal.svelte +++ b/packages/builder/src/pages/builder/portal/manage/users/_components/AddUserModal.svelte @@ -123,12 +123,7 @@ .fix-height { margin-bottom: 5%; } - .normal-height { margin-bottom: 0%; } - - :global(.spectrum-Picker) { - border-top-left-radius: 0px; - } diff --git a/packages/builder/src/pages/builder/portal/manage/users/_components/ImportUsersModal.svelte b/packages/builder/src/pages/builder/portal/manage/users/_components/ImportUsersModal.svelte index 64334b4ab2..bc8a0d1f1f 100644 --- a/packages/builder/src/pages/builder/portal/manage/users/_components/ImportUsersModal.svelte +++ b/packages/builder/src/pages/builder/portal/manage/users/_components/ImportUsersModal.svelte @@ -108,10 +108,6 @@