switch to using roles endpoint to get apps for roles page

This commit is contained in:
Keviin Åberg Kultalahti 2021-05-17 16:11:08 +02:00
parent 7082a1aaa2
commit b0265efb29
1 changed files with 6 additions and 5 deletions

View File

@ -15,7 +15,7 @@
notifications, notifications,
} from "@budibase/bbui" } from "@budibase/bbui"
import { fetchData } from "helpers" import { fetchData } from "helpers"
import { users, apps } from "stores/portal" import { users } from "stores/portal"
import UpdateRolesModal from "./_components/UpdateRolesModal.svelte" import UpdateRolesModal from "./_components/UpdateRolesModal.svelte"
@ -28,14 +28,15 @@
role: { type: "options" }, role: { type: "options" },
} }
// Here we need to merge the Apps list and the roles response to get something that makes sense for the table // Merge the Apps list and the roles response to get something that makes sense for the table
$: appList = $apps.map(app => ({ $: appList = Object.keys($apps?.data).map(app => ({
...app, name: $apps?.data?.[app]?.name,
role: $roleFetch?.data?.roles?.[app._id], role: $roleFetch?.data?.roles?.[app],
})) }))
let selectedApp let selectedApp
const roleFetch = fetchData(`/api/admin/users/${userId}`) const roleFetch = fetchData(`/api/admin/users/${userId}`)
const apps = fetchData(`/api/admin/roles`)
async function deleteUser() { async function deleteUser() {
const res = await users.del(userId) const res = await users.del(userId)