Fixing #4205 - making sure builder loads the correct role for the query.

This commit is contained in:
mike12345567 2022-01-26 18:59:41 +00:00
parent 3567e7ddb6
commit 9d3486eb8a
1 changed files with 10 additions and 8 deletions

View File

@ -1,16 +1,14 @@
<script>
import { Label, Select } from "@budibase/bbui"
import { permissions, roles } from "stores/backend"
import { onMount } from "svelte"
import { Roles } from "constants/backend"
export let query
export let saveId
export let label
$: updateRole(roleId, saveId)
$: getPermissions(query)
let roleId, loaded
let roleId, loaded, fetched
async function updateRole(role, id) {
roleId = role
@ -26,19 +24,23 @@
}
}
onMount(async () => {
if (!query || !query._id) {
async function getPermissions(queryToFetch) {
if (fetched?._id === queryToFetch?._id) {
return
}
fetched = queryToFetch
if (!queryToFetch || !queryToFetch._id) {
roleId = Roles.BASIC
loaded = true
return
}
try {
roleId = (await permissions.forResource(query._id))["read"]
roleId = (await permissions.forResource(queryToFetch._id))["read"]
} catch (err) {
roleId = Roles.BASIC
}
loaded = true
})
}
</script>
{#if loaded}