mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2026-07-26 13:54:56 +00:00
Fix: fix frontend permissions display for stats/system perms (#13305)
This commit is contained in:
@@ -108,6 +108,18 @@ describe('PermissionsService', () => {
|
||||
actionKey: 'View', // PermissionAction.View
|
||||
typeKey: 'Document', // PermissionType.Document
|
||||
})
|
||||
expect(
|
||||
permissionsService.getPermissionKeys('view_global_statistics')
|
||||
).toEqual({
|
||||
actionKey: 'View', // PermissionAction.View
|
||||
typeKey: 'GlobalStatistics', // PermissionType.GlobalStatistics
|
||||
})
|
||||
expect(
|
||||
permissionsService.getPermissionKeys('view_system_monitoring')
|
||||
).toEqual({
|
||||
actionKey: 'View', // PermissionAction.View
|
||||
typeKey: 'SystemMonitoring', // PermissionType.SystemMonitoring
|
||||
})
|
||||
})
|
||||
|
||||
it('correctly checks explicit global permissions', () => {
|
||||
|
||||
@@ -110,19 +110,16 @@ export class PermissionsService {
|
||||
actionKey: string
|
||||
typeKey: string
|
||||
} {
|
||||
const matches = permissionStr.match(/(.+)_/)
|
||||
let typeKey
|
||||
let actionKey
|
||||
if (matches?.length > 0) {
|
||||
const action = matches[1]
|
||||
const actionIndex = Object.values(PermissionAction).indexOf(
|
||||
action as PermissionAction
|
||||
)
|
||||
if (actionIndex > -1) {
|
||||
actionKey = Object.keys(PermissionAction)[actionIndex]
|
||||
}
|
||||
const actionIndex = Object.values(PermissionAction).findIndex((action) =>
|
||||
permissionStr.startsWith(`${action}_`)
|
||||
)
|
||||
if (actionIndex > -1) {
|
||||
const action = Object.values(PermissionAction)[actionIndex]
|
||||
actionKey = Object.keys(PermissionAction)[actionIndex]
|
||||
const typeIndex = Object.values(PermissionType).indexOf(
|
||||
permissionStr.replace(action, '%s') as PermissionType
|
||||
permissionStr.replace(`${action}_`, '%s_') as PermissionType
|
||||
)
|
||||
if (typeIndex > -1) {
|
||||
typeKey = Object.keys(PermissionType)[typeIndex]
|
||||
|
||||
Reference in New Issue
Block a user