Fixing display of user role in apps in the user management page.

This commit is contained in:
mike12345567 2022-09-23 17:02:32 +01:00
parent b086a4f31f
commit b294fdd495
2 changed files with 16 additions and 7 deletions

View File

@ -68,11 +68,13 @@
})
}
return availableApps.map(app => {
const prodAppId = apps.getProdAppID(app.appId)
console.log(prodAppId)
return {
name: app.name,
devId: app.devId,
icon: app.icon,
role: privileged ? Constants.Roles.ADMIN : roles[app.appId],
role: privileged ? Constants.Roles.ADMIN : roles[prodAppId],
}
})
}

View File

@ -8,14 +8,21 @@ const extractAppId = id => {
}
const getProdAppID = appId => {
if (!appId || !appId.startsWith("app_dev")) {
if (!appId) {
return appId
}
// split to take off the app_dev element, then join it together incase any other app_ exist
const split = appId.split("app_dev")
split.shift()
const rest = split.join("app_dev")
return `${"app"}${rest}`
let rest,
separator = ""
if (appId.startsWith("app_dev")) {
// split to take off the app_dev element, then join it together incase any other app_ exist
const split = appId.split("app_dev")
split.shift()
rest = split.join("app_dev")
} else if (!appId.startsWith("app")) {
rest = appId
separator = "_"
}
return `app${separator}${rest}`
}
export function createAppStore() {