Merge pull request #7019 from Budibase/cheeks-fixes

User groups fixes
This commit is contained in:
Andrew Kingston 2022-08-01 15:52:51 +01:00 committed by GitHub
commit 88444df24b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 365 additions and 294 deletions

View File

@ -233,7 +233,10 @@
</div> </div>
{:else if getPrimaryOptionColour(option, idx)} {:else if getPrimaryOptionColour(option, idx)}
<span class="option-left"> <span class="option-left">
<StatusLight color={getPrimaryOptionColour(option, idx)} /> <StatusLight
square
color={getPrimaryOptionColour(option, idx)}
/>
</span> </span>
{/if} {/if}
<span class="spectrum-Menu-itemLabel"> <span class="spectrum-Menu-itemLabel">
@ -253,6 +256,7 @@
{#if getPrimaryOptionIcon(option, idx) && getPrimaryOptionColour(option, idx)} {#if getPrimaryOptionIcon(option, idx) && getPrimaryOptionColour(option, idx)}
<span class="option-right"> <span class="option-right">
<StatusLight <StatusLight
square
color={getPrimaryOptionColour(option, idx)} color={getPrimaryOptionColour(option, idx)}
/> />
</span> </span>
@ -281,7 +285,7 @@
</span> </span>
{:else if secondaryFieldColour} {:else if secondaryFieldColour}
<span class="option-left"> <span class="option-left">
<StatusLight color={secondaryFieldColour} /> <StatusLight square color={secondaryFieldColour} />
</span> </span>
{/if} {/if}
@ -319,6 +323,7 @@
{#if getSecondaryOptionColour(option, idx)} {#if getSecondaryOptionColour(option, idx)}
<span class="option-left"> <span class="option-left">
<StatusLight <StatusLight
square
color={getSecondaryOptionColour(option, idx)} color={getSecondaryOptionColour(option, idx)}
/> />
</span> </span>
@ -351,6 +356,13 @@
min-width: 0; min-width: 0;
width: 100%; 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 { .override-borders {
border-top-left-radius: 0px; border-top-left-radius: 0px;
border-bottom-left-radius: 0px; border-bottom-left-radius: 0px;

View File

@ -72,7 +72,7 @@
href: "/builder/portal/manage/groups", href: "/builder/portal/manage/groups",
} }
menu.splice(1, 0, item) menu.splice(2, 0, item)
} }
if (!$adminStore.cloud) { if (!$adminStore.cloud) {

View File

@ -18,23 +18,44 @@
import { users, apps, groups } from "stores/portal" import { users, apps, groups } from "stores/portal"
import { onMount } from "svelte" import { onMount } from "svelte"
import { RoleUtils } from "@budibase/frontend-core" import { RoleUtils } from "@budibase/frontend-core"
import { roles } from "stores/backend"
export let groupId export let groupId
let popoverAnchor let popoverAnchor
let popover let popover
let searchTerm = "" let searchTerm = ""
let selectedUsers = [] let selectedUsers = []
let prevSearch = undefined, let prevSearch = undefined
search = undefined
let pageInfo = createPaginationStore() let pageInfo = createPaginationStore()
let loaded = false
$: page = $pageInfo.page $: page = $pageInfo.page
$: fetchUsers(page, search) $: fetchUsers(page, searchTerm)
$: group = $groups.find(x => x._id === groupId) $: group = $groups.find(x => x._id === groupId)
async function addAll() { 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) 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) { async function selectUser(id) {
@ -97,106 +118,119 @@
prevSearch = search prevSearch = search
try { try {
pageInfo.loading() pageInfo.loading()
await users.search({ page, search }) await users.search({ page, email: search })
pageInfo.fetched($users.hasNextPage, $users.nextPage) pageInfo.fetched($users.hasNextPage, $users.nextPage)
} catch (error) { } catch (error) {
notifications.error("Error getting user list") 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 () => { onMount(async () => {
try { try {
await groups.actions.init() await Promise.all([groups.actions.init(), apps.load(), roles.fetch()])
await apps.load() loaded = true
} catch (error) { } catch (error) {
notifications.error("Error fetching User Group data") notifications.error("Error fetching user group data")
} }
}) })
</script> </script>
<Layout noPadding> {#if loaded}
<div> <Layout noPadding>
<ActionButton on:click={() => $goto("../groups")} size="S" icon="ArrowLeft"> <div>
Back <ActionButton
</ActionButton> on:click={() => $goto("../groups")}
</div> size="S"
<div class="header"> icon="ArrowLeft"
<div class="title"> >
<div style="background: {group?.color};" class="circle"> Back
<div> </ActionButton>
<Icon size="M" name={group?.icon} /> </div>
<div class="header">
<div class="title">
<div style="background: {group?.color};" class="circle">
<div>
<Icon size="M" name={group?.icon} />
</div>
</div>
<div class="text-padding">
<Heading>{group?.name}</Heading>
</div> </div>
</div> </div>
<div class="text-padding"> <div bind:this={popoverAnchor}>
<Heading>{group?.name}</Heading> <Button on:click={popover.show()} icon="UserAdd" cta>Add user</Button>
</div>
<Popover align="right" bind:this={popover} anchor={popoverAnchor}>
<UserGroupPicker
key={"email"}
title={"User"}
bind:searchTerm
bind:selected={selectedUsers}
bind:filtered
{addAll}
select={selectUser}
/>
</Popover>
</div>
<List>
{#if group?.users.length}
{#each group.users as user}
<ListItem title={user?.email} avatar
><Icon
on:click={() => removeUser(user?._id)}
hoverable
size="L"
name="Close"
/></ListItem
>
{/each}
{:else}
<ListItem icon="UserGroup" title="You have no users in this team" />
{/if}
</List>
<div
style="flex-direction: column; margin-top: var(--spacing-m)"
class="title"
>
<Heading weight="light" size="XS">Apps</Heading>
<div style="margin-top: var(--spacing-xs)">
<Body size="S"
>Manage apps that this User group has been assigned to</Body
>
</div> </div>
</div> </div>
<div bind:this={popoverAnchor}>
<Button on:click={popover.show()} icon="UserAdd" cta>Add User</Button>
</div>
<Popover align="right" bind:this={popover} anchor={popoverAnchor}>
<UserGroupPicker
key={"email"}
title={"User"}
bind:searchTerm
bind:selected={selectedUsers}
bind:filtered
{addAll}
select={selectUser}
/>
</Popover>
</div>
<List> <List>
{#if group?.users.length} {#if groupApps.length}
{#each group.users as user} {#each groupApps as app}
<ListItem title={user?.email} avatar <ListItem
><Icon title={app.name}
on:click={() => removeUser(user?._id)} icon={app?.icon?.name || "Apps"}
hoverable iconBackground={app?.icon?.color || ""}
size="L" >
name="Close" <div class="title ">
/></ListItem <StatusLight
> square
{/each} color={RoleUtils.getRoleColour(group.roles[`app_${app.appId}`])}
{:else} >
<ListItem icon="UserGroup" title="You have no users in this team" /> {getRoleLabel(app.appId)}
{/if} </StatusLight>
</List>
<div
style="flex-direction: column; margin-top: var(--spacing-m)"
class="title"
>
<Heading weight="light" size="XS">Apps</Heading>
<div style="margin-top: var(--spacing-xs)">
<Body size="S">Manage apps that this User group has been assigned to</Body
>
</div>
</div>
<List>
{#if groupApps.length}
{#each groupApps as app}
<ListItem
title={app.name}
icon={app?.icon?.name || "Apps"}
iconBackground={app?.icon?.color || ""}
>
<div class="title ">
<StatusLight
color={RoleUtils.getRoleColour(group.roles[app.appId])}
/>
<div style="margin-left: var(--spacing-s);">
<Body size="XS">{group.roles[app.appId]}</Body>
</div> </div>
</div> </ListItem>
</ListItem> {/each}
{/each} {:else}
{:else} <ListItem icon="UserGroup" title="No apps" />
<ListItem icon="UserGroup" title="No apps" /> {/if}
{/if} </List>
</List> </Layout>
</Layout> {/if}
<style> <style>
.text-padding { .text-padding {

View File

@ -14,13 +14,9 @@
import { Constants } from "@budibase/frontend-core" import { Constants } from "@budibase/frontend-core"
import CreateEditGroupModal from "./_components/CreateEditGroupModal.svelte" import CreateEditGroupModal from "./_components/CreateEditGroupModal.svelte"
import UserGroupsRow from "./_components/UserGroupsRow.svelte" import UserGroupsRow from "./_components/UserGroupsRow.svelte"
import { cloneDeep } from "lodash/fp"
$: hasGroupsLicense = $auth.user?.license.features.includes( const DefaultGroup = {
Constants.Features.USER_GROUPS
)
let modal
let group = {
name: "", name: "",
icon: "UserGroup", icon: "UserGroup",
color: "var(--spectrum-global-color-blue-600)", color: "var(--spectrum-global-color-blue-600)",
@ -28,6 +24,12 @@
apps: [], apps: [],
roles: {}, roles: {},
} }
let modal
let group = cloneDeep(DefaultGroup)
$: hasGroupsLicense = $auth.user?.license.features.includes(
Constants.Features.USER_GROUPS
)
async function deleteGroup(group) { async function deleteGroup(group) {
try { try {
@ -45,6 +47,11 @@
} }
} }
const showCreateGroupModal = () => {
group = cloneDeep(DefaultGroup)
modal?.show()
}
onMount(async () => { onMount(async () => {
try { try {
if (hasGroupsLicense) { if (hasGroupsLicense) {
@ -78,10 +85,11 @@
icon={hasGroupsLicense ? "UserGroup" : ""} icon={hasGroupsLicense ? "UserGroup" : ""}
cta={hasGroupsLicense} cta={hasGroupsLicense}
on:click={hasGroupsLicense on:click={hasGroupsLicense
? () => modal.show() ? showCreateGroupModal
: window.open("https://budibase.com/pricing/", "_blank")} : window.open("https://budibase.com/pricing/", "_blank")}
>{hasGroupsLicense ? "Create user group" : "Upgrade Account"}</Button
> >
{hasGroupsLicense ? "Create user group" : "Upgrade Account"}
</Button>
{#if !hasGroupsLicense} {#if !hasGroupsLicense}
<Button <Button
newStyles newStyles
@ -130,7 +138,7 @@
.groupTable :global(> div) { .groupTable :global(> div) {
background: var(--bg-color); background: var(--bg-color);
height: 70px; height: 55px;
display: grid; display: grid;
align-items: center; align-items: center;
grid-gap: var(--spacing-xl); grid-gap: var(--spacing-xl);

View File

@ -21,9 +21,9 @@
StatusLight, StatusLight,
} from "@budibase/bbui" } from "@budibase/bbui"
import { onMount } from "svelte" import { onMount } from "svelte"
import { fetchData } from "helpers" import { fetchData } from "helpers"
import { users, auth, groups, apps } from "stores/portal" import { users, auth, groups, apps } from "stores/portal"
import { roles } from "stores/backend"
import { Constants } from "@budibase/frontend-core" import { Constants } from "@budibase/frontend-core"
import ForceResetPasswordModal from "./_components/ForceResetPasswordModal.svelte" import ForceResetPasswordModal from "./_components/ForceResetPasswordModal.svelte"
import { RoleUtils } from "@budibase/frontend-core" import { RoleUtils } from "@budibase/frontend-core"
@ -40,6 +40,7 @@
let selectedGroups = [] let selectedGroups = []
let allAppList = [] let allAppList = []
let user let user
let loaded = false
$: fetchUser(userId) $: fetchUser(userId)
$: fullName = $userFetch?.data?.firstName $: fullName = $userFetch?.data?.firstName
@ -49,6 +50,8 @@
$: hasGroupsLicense = $auth.user?.license.features.includes( $: hasGroupsLicense = $auth.user?.license.features.includes(
Constants.Features.USER_GROUPS Constants.Features.USER_GROUPS
) )
$: nameLabel = getNameLabel($userFetch)
$: initials = getInitials(nameLabel)
$: allAppList = $apps $: allAppList = $apps
.filter(x => { .filter(x => {
@ -91,6 +94,39 @@
const userFetch = fetchData(`/api/global/users/${userId}`) const userFetch = fetchData(`/api/global/users/${userId}`)
const getNameLabel = userFetch => {
const { firstName, lastName, email } = userFetch?.data || {}
if (!firstName && !lastName) {
return email || ""
}
let label
if (firstName) {
label = firstName
if (lastName) {
label += ` ${lastName}`
}
} else {
label = lastName
}
return label
}
const getInitials = nameLabel => {
if (!nameLabel) {
return "?"
}
return nameLabel
.split(" ")
.slice(0, 2)
.map(x => x[0])
.join("")
}
const getRoleLabel = roleId => {
const role = $roles.find(x => x._id === roleId)
return role?.name || "Custom role"
}
function getHighestRole(roles) { function getHighestRole(roles) {
let highestRole let highestRole
let highestRoleNumber = 0 let highestRoleNumber = 0
@ -171,176 +207,168 @@
function addAll() {} function addAll() {}
onMount(async () => { onMount(async () => {
try { try {
await groups.actions.init() await Promise.all([groups.actions.init(), apps.load(), roles.fetch()])
await apps.load() loaded = true
} catch (error) { } catch (error) {
notifications.error("Error getting User groups") notifications.error("Error getting user groups")
} }
}) })
</script> </script>
<Layout gap="L" noPadding> {#if loaded}
<Layout gap="XS" noPadding> <Layout gap="L" noPadding>
<div>
<ActionButton on:click={() => $goto("./")} size="S" icon="ArrowLeft">
Back
</ActionButton>
</div>
</Layout>
<Layout gap="XS" noPadding>
<div class="title">
<div>
<div style="display: flex;">
<Avatar
size="XXL"
initials={user?.email
.split(" ")
.map(x => x[0])
.join("")}
/>
{#if fullName}
<div class="subtitle">
<Heading size="S">{fullName}</Heading>
<Body size="XS">{$userFetch?.data?.email}</Body>
</div>
{:else}
<div class="alignEmail">
<Heading size="S">{$userFetch?.data?.email}</Heading>
</div>
{/if}
</div>
</div>
<div>
<ActionMenu align="right">
<span slot="control">
<Icon hoverable name="More" />
</span>
<MenuItem on:click={resetPasswordModal.show} icon="Refresh"
>Force Password Reset</MenuItem
>
<MenuItem on:click={deleteModal.show} icon="Delete">Delete</MenuItem>
</ActionMenu>
</div>
</div>
</Layout>
<Layout gap="S" noPadding>
<div class="fields">
<div class="field">
<Label size="L">First name</Label>
<Input
thin
value={$userFetch?.data?.firstName}
on:blur={updateUserFirstName}
/>
</div>
<div class="field">
<Label size="L">Last name</Label>
<Input
thin
value={$userFetch?.data?.lastName}
on:blur={updateUserLastName}
/>
</div>
<!-- don't let a user remove the privileges that let them be here -->
{#if userId !== $auth.user._id}
<div class="field">
<Label size="L">Role</Label>
<Select
value={globalRole}
options={Constants.BbRoles}
on:change={updateUserRole}
/>
</div>
{/if}
</div>
</Layout>
{#if hasGroupsLicense}
<!-- User groups -->
<Layout gap="XS" noPadding> <Layout gap="XS" noPadding>
<div class="tableTitle"> <div>
<ActionButton on:click={() => $goto("./")} size="S" icon="ArrowLeft">
Back
</ActionButton>
</div>
</Layout>
<Layout gap="XS" noPadding>
<div class="title">
<div> <div>
<Heading size="XS">User groups</Heading> <div style="display: flex;">
<Body size="S">Add or remove this user from user groups</Body> <Avatar size="XXL" {initials} />
<div class="subtitle">
<Heading size="S">{nameLabel}</Heading>
{#if nameLabel !== $userFetch?.data?.email}
<Body size="XS">{$userFetch?.data?.email}</Body>
{/if}
</div>
</div>
</div> </div>
<div bind:this={popoverAnchor}> <div>
<Button on:click={popover.show()} icon="UserGroup" cta <ActionMenu align="right">
>Add User Group</Button <span slot="control">
> <Icon hoverable name="More" />
</span>
<MenuItem on:click={resetPasswordModal.show} icon="Refresh"
>Force Password Reset</MenuItem
>
<MenuItem on:click={deleteModal.show} icon="Delete">Delete</MenuItem
>
</ActionMenu>
</div> </div>
<Popover align="right" bind:this={popover} anchor={popoverAnchor}> </div>
<UserGroupPicker </Layout>
key={"name"} <Layout gap="S" noPadding>
title={"Group"} <div class="fields">
bind:searchTerm <div class="field">
bind:selected={selectedGroups} <Label size="L">First name</Label>
bind:filtered={filteredGroups} <Input
{addAll} thin
select={addGroup} value={$userFetch?.data?.firstName}
on:blur={updateUserFirstName}
/> />
</Popover> </div>
<div class="field">
<Label size="L">Last name</Label>
<Input
thin
value={$userFetch?.data?.lastName}
on:blur={updateUserLastName}
/>
</div>
<!-- don't let a user remove the privileges that let them be here -->
{#if userId !== $auth.user._id}
<div class="field">
<Label size="L">Role</Label>
<Select
value={globalRole}
options={Constants.BbRoles}
on:change={updateUserRole}
/>
</div>
{/if}
</div>
</Layout>
{#if hasGroupsLicense}
<!-- User groups -->
<Layout gap="XS" noPadding>
<div class="tableTitle">
<div>
<Heading size="XS">User groups</Heading>
<Body size="S">Add or remove this user from user groups</Body>
</div>
<div bind:this={popoverAnchor}>
<Button on:click={popover.show()} icon="UserGroup" cta>
Add user group
</Button>
</div>
<Popover align="right" bind:this={popover} anchor={popoverAnchor}>
<UserGroupPicker
key={"name"}
title={"Group"}
bind:searchTerm
bind:selected={selectedGroups}
bind:filtered={filteredGroups}
{addAll}
select={addGroup}
/>
</Popover>
</div>
<List>
{#if userGroups.length}
{#each userGroups as group}
<ListItem
title={group.name}
icon={group.icon}
iconBackground={group.color}
><Icon
on:click={removeGroup(group._id)}
hoverable
size="L"
name="Close"
/></ListItem
>
{/each}
{:else}
<ListItem icon="UserGroup" title="No groups" />
{/if}
</List>
</Layout>
{/if}
<!-- User Apps -->
<Layout gap="S" noPadding>
<div class="appsTitle">
<Heading weight="light" size="XS">Apps</Heading>
<div style="margin-top: var(--spacing-xs)">
<Body size="S">Manage apps that this user has been assigned to</Body>
</div>
</div> </div>
<List> <List>
{#if userGroups.length} {#if allAppList.length}
{#each userGroups as group} {#each allAppList as app}
<ListItem <div
title={group.name} class="pointer"
icon={group.icon} on:click={$goto(`../../overview/${app.devId}`)}
iconBackground={group.color}
><Icon
on:click={removeGroup(group._id)}
hoverable
size="L"
name="Close"
/></ListItem
> >
<ListItem
title={app.name}
iconBackground={app?.icon?.color || ""}
icon={app?.icon?.name || "Apps"}
>
<div class="title ">
<StatusLight
square
color={RoleUtils.getRoleColour(getHighestRole(app.roles))}
>
{getRoleLabel(getHighestRole(app.roles))}
</StatusLight>
</div>
</ListItem>
</div>
{/each} {/each}
{:else} {:else}
<ListItem icon="UserGroup" title="No groups" /> <ListItem icon="Apps" title="No apps" />
{/if} {/if}
</List> </List>
</Layout> </Layout>
{/if}
<!-- User Apps -->
<Layout gap="S" noPadding>
<div class="appsTitle">
<Heading weight="light" size="XS">Apps</Heading>
<div style="margin-top: var(--spacing-xs)">
<Body size="S">Manage apps that this user has been assigned to</Body>
</div>
</div>
<List>
{#if allAppList.length}
{#each allAppList as app}
<div class="pointer" on:click={$goto(`../../overview/${app.devId}`)}>
<ListItem
title={app.name}
iconBackground={app?.icon?.color || ""}
icon={app?.icon?.name || "Apps"}
>
<div class="title ">
<StatusLight
color={RoleUtils.getRoleColour(getHighestRole(app.roles))}
/>
<div style="margin-left: var(--spacing-s);">
<Body size="XS"
>{Constants.Roles[getHighestRole(app.roles)]}</Body
>
</div>
</div>
</ListItem>
</div>
{/each}
{:else}
<ListItem icon="Apps" title="No apps" />
{/if}
</List>
</Layout> </Layout>
</Layout> {/if}
<Modal bind:this={deleteModal}> <Modal bind:this={deleteModal}>
<DeleteUserModal user={$userFetch.data} /> <DeleteUserModal user={$userFetch.data} />
@ -380,17 +408,14 @@
.subtitle { .subtitle {
padding: 0 0 0 var(--spacing-m); padding: 0 0 0 var(--spacing-m);
display: inline-block; display: flex;
flex-direction: column;
justify-content: center;
align-items: stretch;
} }
.appsTitle { .appsTitle {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.alignEmail {
display: flex;
align-items: center;
margin-left: var(--spacing-m);
}
</style> </style>

View File

@ -123,12 +123,7 @@
.fix-height { .fix-height {
margin-bottom: 5%; margin-bottom: 5%;
} }
.normal-height { .normal-height {
margin-bottom: 0%; margin-bottom: 0%;
} }
:global(.spectrum-Picker) {
border-top-left-radius: 0px;
}
</style> </style>

View File

@ -108,10 +108,6 @@
</ModalContent> </ModalContent>
<style> <style>
:global(.spectrum-Picker) {
border-top-left-radius: 0px;
}
.dropzone { .dropzone {
text-align: center; text-align: center;
display: flex; display: flex;

View File

@ -79,10 +79,6 @@
display: flex; display: flex;
} }
:global(.spectrum-Picker) {
border-top-left-radius: 0px;
}
.container { .container {
width: 100%; width: 100%;
height: var(--spectrum-alias-item-height-l); height: var(--spectrum-alias-item-height-l);

View File

@ -249,10 +249,10 @@
dataCy="add-user" dataCy="add-user"
on:click={createUserModal.show} on:click={createUserModal.show}
icon="UserAdd" icon="UserAdd"
cta>Add Users</Button cta>Add users</Button
> >
<Button on:click={importUsersModal.show} icon="Import" primary <Button on:click={importUsersModal.show} icon="Import" primary
>Import Users</Button >Import users</Button
> >
<div class="field"> <div class="field">

View File

@ -3,6 +3,7 @@
ModalContent, ModalContent,
PickerDropdown, PickerDropdown,
ActionButton, ActionButton,
Layout,
notifications, notifications,
} from "@budibase/bbui" } from "@budibase/bbui"
import { roles } from "stores/backend" import { roles } from "stores/backend"
@ -38,9 +39,9 @@
} }
} }
$: filteredGroups = $groups.filter(element => { $: filteredGroups = $groups.filter(group => {
return !element.apps.find(y => { return !group.apps.find(appId => {
return y.appId === app.appId return appId === app.appId
}) })
}) })
@ -78,24 +79,26 @@
onConfirm={() => addData(appData)} onConfirm={() => addData(appData)}
showCloseIcon={false} showCloseIcon={false}
> >
{#each appData as input, index} <Layout noPadding gap="XS">
<PickerDropdown {#each appData as input, index}
autocomplete <PickerDropdown
primaryOptions={optionSections} autocomplete
secondaryOptions={$roles} primaryOptions={optionSections}
bind:primaryValue={input.id} secondaryOptions={$roles}
bind:secondaryValue={input.role} secondaryPlaceholder="Access"
bind:searchTerm={search} bind:primaryValue={input.id}
getPrimaryOptionLabel={group => group.name} bind:secondaryValue={input.role}
getPrimaryOptionValue={group => group.name} bind:searchTerm={search}
getPrimaryOptionIcon={group => group.icon} getPrimaryOptionLabel={group => group.name}
getPrimaryOptionColour={group => group.colour} getPrimaryOptionValue={group => group.name}
getSecondaryOptionLabel={role => role.name} getPrimaryOptionIcon={group => group.icon}
getSecondaryOptionValue={role => role._id} getPrimaryOptionColour={group => group.colour}
getSecondaryOptionColour={role => RoleUtils.getRoleColour(role._id)} getSecondaryOptionLabel={role => role.name}
/> getSecondaryOptionValue={role => role._id}
{/each} getSecondaryOptionColour={role => RoleUtils.getRoleColour(role._id)}
/>
{/each}
</Layout>
<div> <div>
<ActionButton on:click={addNewInput} icon="Add">Add email</ActionButton> <ActionButton on:click={addNewInput} icon="Add">Add email</ActionButton>
</div> </div>

View File

@ -5,7 +5,7 @@
import { store } from "builderStore" import { store } from "builderStore"
import clientPackage from "@budibase/client/package.json" import clientPackage from "@budibase/client/package.json"
import { processStringSync } from "@budibase/string-templates" import { processStringSync } from "@budibase/string-templates"
import { users, auth } from "stores/portal" import { users, auth, apps } from "stores/portal"
import { createEventDispatcher, onMount } from "svelte" import { createEventDispatcher, onMount } from "svelte"
export let app export let app
@ -40,9 +40,11 @@
} }
onMount(async () => { onMount(async () => {
let resp = await users.getUserCountByApp({ appId: "app_" + app.appId }) let resp = await users.getUserCountByApp({
appId: apps.getProdAppID(app.devId),
})
userCount = resp.userCount userCount = resp.userCount
await users.search({ appId: "app_" + app.appId, limit: 4 }) await users.search({ appId: apps.getProdAppID(app.devId), limit: 4 })
}) })
</script> </script>