Fixing #4205 - making sure builder loads the correct role for the query.
This commit is contained in:
parent
9b55ba8b13
commit
412b7e5f06
|
@ -1,16 +1,14 @@
|
||||||
<script>
|
<script>
|
||||||
import { Label, Select } from "@budibase/bbui"
|
import { Label, Select } from "@budibase/bbui"
|
||||||
import { permissions, roles } from "stores/backend"
|
import { permissions, roles } from "stores/backend"
|
||||||
import { onMount } from "svelte"
|
|
||||||
import { Roles } from "constants/backend"
|
import { Roles } from "constants/backend"
|
||||||
|
|
||||||
export let query
|
export let query
|
||||||
export let saveId
|
|
||||||
export let label
|
export let label
|
||||||
|
|
||||||
$: updateRole(roleId, saveId)
|
$: getPermissions(query)
|
||||||
|
|
||||||
let roleId, loaded
|
let roleId, loaded, fetched
|
||||||
|
|
||||||
async function updateRole(role, id) {
|
async function updateRole(role, id) {
|
||||||
roleId = role
|
roleId = role
|
||||||
|
@ -26,19 +24,23 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(async () => {
|
async function getPermissions(queryToFetch) {
|
||||||
if (!query || !query._id) {
|
if (fetched?._id === queryToFetch?._id) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fetched = queryToFetch
|
||||||
|
if (!queryToFetch || !queryToFetch._id) {
|
||||||
roleId = Roles.BASIC
|
roleId = Roles.BASIC
|
||||||
loaded = true
|
loaded = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
roleId = (await permissions.forResource(query._id))["read"]
|
roleId = (await permissions.forResource(queryToFetch._id))["read"]
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
roleId = Roles.BASIC
|
roleId = Roles.BASIC
|
||||||
}
|
}
|
||||||
loaded = true
|
loaded = true
|
||||||
})
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if loaded}
|
{#if loaded}
|
||||||
|
|
Loading…
Reference in New Issue