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 committed 2022-11-11 15:45:37 -08:00
1 parent 4603813896
commit 59e359ff98
25 files changed
+74 -125

No files matched your search

@@ -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')
)
}
}