Skip to content

Commit

Permalink
Merge pull request #21 from georchestra/gn-display
Browse files Browse the repository at this point in the history
Add catalogadmin to keep gn link when viewer or editor
  • Loading branch information
f-necas authored Feb 15, 2024
2 parents 9cd8f6f + 4cd39ca commit 4217e61
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ type KNOWN_ROLES =
| 'ROLE_USER'
| 'ROLE_ADMINISTRATOR'
| 'ROLE_EXTRACTORAPP'
| 'ROLE_GN_REVIEWER'
| 'ROLE_GN_EDITOR'
| 'ROLE_GN_ADMIN'
| 'ROLE_EMAILPROXY'
| 'ROLE_ANONYMOUS'
Expand Down Expand Up @@ -38,6 +40,7 @@ export interface AdminRoles {
admin: boolean
console: boolean
catalog: boolean
catalogAdmin: boolean
viewer: boolean
}

Expand Down Expand Up @@ -71,16 +74,18 @@ export async function getUserDetails(): Promise<User> {
export function getAdminRoles(roles: KNOWN_ROLES[]): AdminRoles | null {
const superUser = roles.indexOf('ROLE_SUPERUSER') > -1
const console = superUser || roles.indexOf('ROLE_ORGADMIN') > -1
const catalog = superUser || roles.indexOf('ROLE_GN_ADMIN') > -1
const catalogAdmin = superUser || roles.indexOf('ROLE_GN_ADMIN') > -1
const catalog = !catalogAdmin && (roles.indexOf('ROLE_GN_EDITOR') > -1 || roles.indexOf('ROLE_GN_REVIEWER') > -1)
const viewer = superUser || roles.indexOf('ROLE_MAPSTORE_ADMIN') > -1
const admin =
superUser || console || catalog || viewer
superUser || console || catalog || viewer || catalogAdmin
if (!admin) return null
return {
superUser,
admin,
console,
catalog,
catalogAdmin,
viewer,
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/header.ce.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,12 @@ onMounted(() => {
<li :class="{ active: props.activeApp === 'geonetwork' }">
<a
class="catalog"
v-if="adminRoles?.catalog"
:href="`/geonetwork/srv/${state.lang3}/admin.console`"
v-if="adminRoles?.catalog || adminRoles?.catalogAdmin"
:href="
adminRoles?.catalogAdmin
? `/geonetwork/srv/${state.lang3}/admin.console`
: `/geonetwork/srv/${state.lang3}/catalog.edit#/board`
"
>
<CatalogIcon class="icon-dropdown"></CatalogIcon>
{{ t('catalogue') }}</a
Expand Down

0 comments on commit 4217e61

Please sign in to comment.