diff --git a/packages/bbui/src/Form/Select.svelte b/packages/bbui/src/Form/Select.svelte
index fe5d19d92f..69126e648d 100644
--- a/packages/bbui/src/Form/Select.svelte
+++ b/packages/bbui/src/Form/Select.svelte
@@ -1,6 +1,7 @@
-
-
- rolesContext.updateGroupRole(e.detail, row._id)}
- on:remove={() => rolesContext.removeGroupRole(row._id)}
- />
-
-
-
diff --git a/packages/builder/src/pages/builder/portal/overview/[appId]/access/index.svelte b/packages/builder/src/pages/builder/portal/overview/[appId]/access/index.svelte
index 9e5aceedaa..4acec6aaec 100644
--- a/packages/builder/src/pages/builder/portal/overview/[appId]/access/index.svelte
+++ b/packages/builder/src/pages/builder/portal/overview/[appId]/access/index.svelte
@@ -16,15 +16,14 @@
import { roles } from "stores/backend"
import { API } from "api"
import { fetchData } from "@budibase/frontend-core"
- import UserRoleRenderer from "./_components/UserRoleRenderer.svelte"
- import GroupRoleRenderer from "./_components/GroupRoleRenderer.svelte"
+ import EditableRoleRenderer from "./_components/EditableRoleRenderer.svelte"
const userSchema = {
email: {
type: "string",
width: "1fr",
},
- userAppRole: {
+ role: {
displayName: "Access",
width: "150px",
borderLeft: true,
@@ -35,7 +34,7 @@
type: "string",
width: "1fr",
},
- groupAppRole: {
+ role: {
displayName: "Access",
width: "150px",
borderLeft: true,
@@ -43,12 +42,8 @@
}
const customRenderers = [
{
- column: "userAppRole",
- component: UserRoleRenderer,
- },
- {
- column: "groupAppRole",
- component: GroupRoleRenderer,
+ column: "role",
+ component: EditableRoleRenderer,
},
]
@@ -76,7 +71,7 @@
const getAppUsers = (users, appId) => {
return users.map(user => ({
...user,
- userAppRole: user.roles[Object.keys(user.roles).find(x => x === appId)],
+ role: user.roles[Object.keys(user.roles).find(x => x === appId)],
}))
}
@@ -90,13 +85,30 @@
})
.map(group => ({
...group,
- groupAppRole:
- group.roles[
- groups.actions.getGroupAppIds(group).find(x => x === appId)
- ],
+ role: group.roles[
+ groups.actions.getGroupAppIds(group).find(x => x === appId)
+ ],
}))
}
+ const updateRole = async (role, id) => {
+ // Check if this is a user or a group
+ if ($usersFetch.rows.some(user => user._id === id)) {
+ await updateUserRole(role, id)
+ } else {
+ await updateGroupRole(role, id)
+ }
+ }
+
+ const removeRole = async id => {
+ // Check if this is a user or a group
+ if ($usersFetch.rows.some(user => user._id === id)) {
+ await removeUserRole(id)
+ } else {
+ await removeGroupRole(id)
+ }
+ }
+
const updateUserRole = async (role, userId) => {
const user = $usersFetch.rows.find(user => user._id === userId)
if (!user) {
@@ -142,10 +154,8 @@
}
setContext("roles", {
- updateUserRole,
- removeUserRole,
- updateGroupRole,
- removeGroupRole,
+ updateRole,
+ removeRole,
})
onMount(async () => {
diff --git a/packages/builder/src/pages/builder/portal/settings/_layout.svelte b/packages/builder/src/pages/builder/portal/settings/_layout.svelte
index a17f625634..0ae25c17b4 100644
--- a/packages/builder/src/pages/builder/portal/settings/_layout.svelte
+++ b/packages/builder/src/pages/builder/portal/settings/_layout.svelte
@@ -2,6 +2,8 @@
import { url, isActive } from "@roxi/routify"
import { Page } from "@budibase/bbui"
import { Content, SideNav, SideNavItem } from "components/portal/page"
+
+ $: narrow = !$isActive("./users/index") && !$isActive("./groups/index")
diff --git a/packages/builder/src/pages/builder/portal/users/groups/[groupId].svelte b/packages/builder/src/pages/builder/portal/users/groups/[groupId].svelte
index 6e5bf63dba..b92ccc2769 100644
--- a/packages/builder/src/pages/builder/portal/users/groups/[groupId].svelte
+++ b/packages/builder/src/pages/builder/portal/users/groups/[groupId].svelte
@@ -7,10 +7,7 @@
Icon,
Popover,
notifications,
- List,
- ListItem,
- StatusLight,
- Divider,
+ Table,
ActionMenu,
MenuItem,
Modal,
@@ -18,32 +15,76 @@
import UserGroupPicker from "components/settings/UserGroupPicker.svelte"
import { createPaginationStore } from "helpers/pagination"
import { users, apps, groups } from "stores/portal"
- import { onMount } from "svelte"
- import { RoleUtils } from "@budibase/frontend-core"
+ import { onMount, setContext } from "svelte"
import { roles } from "stores/backend"
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
import CreateEditGroupModal from "./_components/CreateEditGroupModal.svelte"
import GroupIcon from "./_components/GroupIcon.svelte"
- import AppAddModal from "./_components/AppAddModal.svelte"
import { Breadcrumbs, Breadcrumb } from "components/portal/page"
+ import AppNameTableRenderer from "../users/_components/AppNameTableRenderer.svelte"
+ import RemoveUserTableRenderer from "./_components/RemoveUserTableRenderer.svelte"
+ import AppRoleTableRenderer from "../users/_components/AppRoleTableRenderer.svelte"
export let groupId
+ const userSchema = {
+ email: {
+ width: "1fr",
+ },
+ _id: {
+ displayName: "",
+ width: "auto",
+ borderLeft: true,
+ },
+ }
+ const appSchema = {
+ name: {
+ width: "2fr",
+ },
+ role: {
+ width: "1fr",
+ },
+ }
+ const customUserTableRenderers = [
+ {
+ column: "_id",
+ component: RemoveUserTableRenderer,
+ },
+ ]
+ const customAppTableRenderers = [
+ {
+ column: "name",
+ component: AppNameTableRenderer,
+ },
+ {
+ column: "role",
+ component: AppRoleTableRenderer,
+ },
+ ]
+
let popoverAnchor
let popover
let searchTerm = ""
let prevSearch = undefined
let pageInfo = createPaginationStore()
let loaded = false
- let editModal, deleteModal, appAddModal
+ let editModal, deleteModal
$: page = $pageInfo.page
$: fetchUsers(page, searchTerm)
$: group = $groups.find(x => x._id === groupId)
$: filtered = $users.data
- $: groupApps = $apps.filter(app =>
- groups.actions.getGroupAppIds(group).includes(apps.getProdAppID(app.devId))
- )
+ $: groupApps = $apps
+ .filter(app =>
+ groups.actions
+ .getGroupAppIds(group)
+ .includes(apps.getProdAppID(app.devId))
+ )
+ .map(app => ({
+ ...app,
+ role: group?.roles?.[apps.getProdAppID(app.devId)],
+ }))
+ $: console.log(groupApps)
$: {
if (loaded && !group?._id) {
$goto("./")
@@ -93,6 +134,22 @@
}
}
+ const removeUser = async id => {
+ await groups.actions.removeUser(groupId, id)
+ }
+
+ const removeApp = async app => {
+ await groups.actions.removeApp(groupId, apps.getProdAppID(app.devId))
+ }
+
+ setContext("users", {
+ removeUser,
+ })
+ setContext("roles", {
+ updateRole: () => {},
+ removeRole: removeApp,
+ })
+
onMount(async () => {
try {
await Promise.all([groups.actions.init(), apps.load(), roles.fetch()])
@@ -143,76 +200,35 @@
/>
-
- {#if group?.users.length}
- {#each group.users as user}
- $goto(`../users/${user._id}`)}
- hoverable
- >
- {
- groups.actions.removeUser(groupId, user._id)
- e.stopPropagation()
- }}
- hoverable
- size="S"
- name="Close"
- />
-
- {/each}
- {:else}
-
- {/if}
-
+
+ $goto(`../users/${e.detail._id}`)}
+ >
+
+ This user group doesn't have any users
+
+
-