1
0
Fork 0
mirror of synced 2024-09-30 00:57:16 +13:00

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 fa4efc52e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View file

@ -36,7 +36,8 @@
$: defaultRoleId = $userFetch?.data?.builder?.global ? "ADMIN" : "BASIC" $: defaultRoleId = $userFetch?.data?.builder?.global ? "ADMIN" : "BASIC"
// 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 = Object.keys($apps?.data).map(id => { $: 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 { return {
...$apps?.data?.[id], ...$apps?.data?.[id],
_id: id, _id: id,

View file

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

View file

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