Merge pull request #2078 from mslourens/new_roles_bug

display role names instead of _id
This commit is contained in:
Michael Drury 2021-07-25 11:51:07 +01:00 committed by GitHub
commit a34e612424
3 changed files with 6 additions and 3 deletions

View File

@ -36,7 +36,8 @@
$: defaultRoleId = $userFetch?.data?.builder?.global ? "ADMIN" : "BASIC"
// Merge the Apps list and the roles response to get something that makes sense for the table
$: appList = Object.keys($apps?.data).map(id => {
const role = $userFetch?.data?.roles?.[id] || defaultRoleId
const roleId = $userFetch?.data?.roles?.[id] || defaultRoleId
const role = $apps?.data?.[id].roles.find(role => role._id === roleId)
return {
...$apps?.data?.[id],
_id: id,

View File

@ -4,7 +4,7 @@
const displayLimit = 5
$: roles = value?.filter(role => role != null) ?? []
$: roles = value?.filter(role => role != null).map(role => role.name) ?? []
$: tags = roles.slice(0, displayLimit)
$: leftover = roles.length - tags.length
</script>

View File

@ -10,8 +10,8 @@
const roles = app.roles
let options = roles
.filter(role => role._id !== "PUBLIC")
.map(role => ({ value: role._id, label: role.name }))
.filter(role => role.value !== "PUBLIC")
let selectedRole = user?.roles?.[app?._id]
async function updateUserRoles() {
@ -48,5 +48,7 @@
on:change
{options}
label="Role"
getOptionLabel={role => role.name}
getOptionValue={role => role._id}
/>
</ModalContent>