diff --git a/packages/builder/src/pages/builder/portal/users/users/[userId].svelte b/packages/builder/src/pages/builder/portal/users/users/[userId].svelte index 67ea23ceed..d3e709db69 100644 --- a/packages/builder/src/pages/builder/portal/users/users/[userId].svelte +++ b/packages/builder/src/pages/builder/portal/users/users/[userId].svelte @@ -18,20 +18,63 @@ Modal, notifications, Banner, - StatusLight, + Table, } from "@budibase/bbui" - import { onMount } from "svelte" + import { onMount, setContext } from "svelte" import { users, auth, groups, apps, licensing } from "stores/portal" import { roles } from "stores/backend" import ForceResetPasswordModal from "./_components/ForceResetPasswordModal.svelte" import UserGroupPicker from "components/settings/UserGroupPicker.svelte" import DeleteUserModal from "./_components/DeleteUserModal.svelte" import GroupIcon from "../groups/_components/GroupIcon.svelte" - import { Constants, RoleUtils } from "@budibase/frontend-core" + import { Constants } from "@budibase/frontend-core" import { Breadcrumbs, Breadcrumb } from "components/portal/page" + import RemoveGroupTableRenderer from "./_components/RemoveGroupTableRenderer.svelte" + import GroupNameTableRenderer from "../groups/_components/GroupNameTableRenderer.svelte" + import AppNameTableRenderer from "./_components/AppNameTableRenderer.svelte" + import AppRoleTableRenderer from "./_components/AppRoleTableRenderer.svelte" export let userId + const groupSchema = { + name: { + width: "1fr", + }, + _id: { + displayName: "", + width: "auto", + borderLeft: true, + }, + } + const appSchema = { + name: { + width: "2fr", + }, + role: { + width: "1fr", + }, + } + const customGroupTableRenderers = [ + { + column: "name", + component: GroupNameTableRenderer, + }, + { + column: "_id", + component: RemoveGroupTableRenderer, + }, + ] + const customAppTableRenderers = [ + { + column: "name", + component: AppNameTableRenderer, + }, + { + column: "role", + component: AppRoleTableRenderer, + }, + ] + let deleteModal let resetPasswordModal let popoverAnchor @@ -113,11 +156,6 @@ .join("") } - const getRoleLabel = roleId => { - const role = $roles.find(x => x._id === roleId) - return role?.name || "Custom role" - } - async function updateUserFirstName(evt) { try { await users.save({ ...user, firstName: evt.target.value }) @@ -172,6 +210,10 @@ await fetchUser() } + setContext("groups", { + removeGroup, + }) + onMount(async () => { try { await Promise.all([ @@ -272,61 +314,43 @@ /> - - {#if userGroups.length} - {#each userGroups as group} - $goto(`../groups/${group._id}`)} - > - { - removeGroup(group._id) - e.stopPropagation() - }} - hoverable - size="S" - name="Close" - /> - - {/each} - {:else} - - {/if} - + $goto(`../groups/${e.detail._id}`)} + > +
+ This user is not in any groups +
+
{/if} Apps - - {#if privileged} - - This user's role grants admin access to all apps - - {:else if availableApps.length} - {#each availableApps as app} - $goto(`../../overview/${app.devId}`)} - > -
- - {getRoleLabel(app.role)} - -
-
- {/each} - {:else} - - {/if} -
+ {#if privileged} + + This user's role grants admin access to all apps + + {:else} + $goto(`../../overview/${e.detail.devId}`)} + > +
+ + This user doesn't have access to any apps + +
+
+ {/if}
{/if} @@ -348,19 +372,16 @@ grid-template-columns: 120px 1fr; align-items: center; } - .title { display: flex; align-items: center; justify-content: space-between; } - .tableTitle { display: flex; justify-content: space-between; align-items: flex-end; } - .subtitle { padding: 0 0 0 var(--spacing-m); display: flex; @@ -368,4 +389,8 @@ justify-content: center; align-items: stretch; } + .placeholder { + width: 100%; + text-align: center; + } diff --git a/packages/builder/src/pages/builder/portal/users/users/_components/AppNameTableRenderer.svelte b/packages/builder/src/pages/builder/portal/users/users/_components/AppNameTableRenderer.svelte new file mode 100644 index 0000000000..c5d6a55848 --- /dev/null +++ b/packages/builder/src/pages/builder/portal/users/users/_components/AppNameTableRenderer.svelte @@ -0,0 +1,30 @@ + + +
+ +
+ {value} +
+
+ + diff --git a/packages/builder/src/pages/builder/portal/users/users/_components/AppRoleTableRenderer.svelte b/packages/builder/src/pages/builder/portal/users/users/_components/AppRoleTableRenderer.svelte index e69de29bb2..5664a95045 100644 --- a/packages/builder/src/pages/builder/portal/users/users/_components/AppRoleTableRenderer.svelte +++ b/packages/builder/src/pages/builder/portal/users/users/_components/AppRoleTableRenderer.svelte @@ -0,0 +1,16 @@ + + + + {getRoleLabel(value)} + diff --git a/packages/builder/src/pages/builder/portal/users/users/_components/PasswordModal.svelte b/packages/builder/src/pages/builder/portal/users/users/_components/PasswordModal.svelte index 990a54610c..7b0d95719d 100644 --- a/packages/builder/src/pages/builder/portal/users/users/_components/PasswordModal.svelte +++ b/packages/builder/src/pages/builder/portal/users/users/_components/PasswordModal.svelte @@ -1,6 +1,6 @@