Refactor permissions check code

Directly check permissions and no subscription (uisettings is always initialized on frontend startup)
update permission directive to accept single string
add explicit management permission name
This commit is contained in:
Michael Shamoon
2022-11-11 14:32:18 -08:00
parent 4603813896
commit 59e359ff98
25 changed files with 74 additions and 125 deletions

View File

@@ -553,11 +553,9 @@ export class DocumentDetailComponent
}
get commentsEnabled(): boolean {
// TODO - Is this the only way to allow/disallow from permissions?
var canViewComments = false
this.settings.permissions().subscribe((perm) => {
canViewComments = perm.includes('documents.view_comment')
})
return this.settings.get(SETTINGS_KEYS.COMMENTS_ENABLED) && canViewComments
return (
this.settings.get(SETTINGS_KEYS.COMMENTS_ENABLED) &&
this.settings.currentUserCan('documents.view_comment')
)
}
}