Frontend handle auditlog disabled

This commit is contained in:
shamoon 2024-04-08 21:00:06 -07:00
parent d8be1b2bb5
commit e15b3ae9de
6 changed files with 30 additions and 8 deletions

View File

@ -285,7 +285,8 @@
</li> </li>
} }
<li *pngxIfPermissions="{ action: PermissionAction.View, type: PermissionType.AuditLogEntry }" [ngbNavItem]="DocumentDetailNavIDs.History"> @if (auditlogEnabled) {
<li [ngbNavItem]="DocumentDetailNavIDs.History">
<a ngbNavLink i18n>History</a> <a ngbNavLink i18n>History</a>
<ng-template ngbNavContent> <ng-template ngbNavContent>
<div class="mb-3"> <div class="mb-3">
@ -293,6 +294,7 @@
</div> </div>
</ng-template> </ng-template>
</li> </li>
}
@if (showPermissions) { @if (showPermissions) {
<li [ngbNavItem]="DocumentDetailNavIDs.Permissions"> <li [ngbNavItem]="DocumentDetailNavIDs.Permissions">

View File

@ -903,6 +903,16 @@ export class DocumentDetailComponent
) )
} }
get auditlogEnabled(): boolean {
return (
this.settings.get(SETTINGS_KEYS.AUDITLOG_ENABLED) &&
this.permissionsService.currentUserCan(
PermissionAction.View,
PermissionType.AuditLogEntry
)
)
}
notesUpdated(notes: DocumentNote[]) { notesUpdated(notes: DocumentNote[]) {
this.document.notes = notes this.document.notes = notes
this.openDocumentService.refreshDocument(this.documentId) this.openDocumentService.refreshDocument(this.documentId)

View File

@ -37,6 +37,7 @@ export const SETTINGS_KEYS = {
NOTIFICATIONS_CONSUMER_SUPPRESS_ON_DASHBOARD: NOTIFICATIONS_CONSUMER_SUPPRESS_ON_DASHBOARD:
'general-settings:notifications:consumer-suppress-on-dashboard', 'general-settings:notifications:consumer-suppress-on-dashboard',
NOTES_ENABLED: 'general-settings:notes-enabled', NOTES_ENABLED: 'general-settings:notes-enabled',
AUDITLOG_ENABLED: 'general-settings:auditlog-enabled',
SLIM_SIDEBAR: 'general-settings:slim-sidebar', SLIM_SIDEBAR: 'general-settings:slim-sidebar',
UPDATE_CHECKING_ENABLED: 'general-settings:update-checking:enabled', UPDATE_CHECKING_ENABLED: 'general-settings:update-checking:enabled',
UPDATE_CHECKING_BACKEND_SETTING: UPDATE_CHECKING_BACKEND_SETTING:
@ -143,6 +144,11 @@ export const SETTINGS: UiSetting[] = [
type: 'boolean', type: 'boolean',
default: true, default: true,
}, },
{
key: SETTINGS_KEYS.AUDITLOG_ENABLED,
type: 'boolean',
default: true,
},
{ {
key: SETTINGS_KEYS.UPDATE_CHECKING_ENABLED, key: SETTINGS_KEYS.UPDATE_CHECKING_ENABLED,
type: 'boolean', type: 'boolean',

View File

@ -47,6 +47,7 @@ describe('SettingsService', () => {
update_checking: { enabled: false, backend_setting: 'default' }, update_checking: { enabled: false, backend_setting: 'default' },
saved_views: { warn_on_unsaved_change: true }, saved_views: { warn_on_unsaved_change: true },
notes_enabled: true, notes_enabled: true,
auditlog_enabled: true,
tour_complete: false, tour_complete: false,
permissions: { permissions: {
default_owner: null, default_owner: null,

View File

@ -39,6 +39,7 @@ class TestApiUiSettings(DirectoriesMixin, APITestCase):
{ {
"app_title": None, "app_title": None,
"app_logo": None, "app_logo": None,
"auditlog_enabled": True,
"update_checking": { "update_checking": {
"backend_setting": "default", "backend_setting": "default",
}, },

View File

@ -1300,6 +1300,8 @@ class UiSettingsView(GenericAPIView):
if general_config.app_logo is not None and len(general_config.app_logo) > 0: if general_config.app_logo is not None and len(general_config.app_logo) > 0:
ui_settings["app_logo"] = general_config.app_logo ui_settings["app_logo"] = general_config.app_logo
ui_settings["auditlog_enabled"] = settings.AUDIT_LOG_ENABLED
user_resp = { user_resp = {
"id": user.id, "id": user.id,
"username": user.username, "username": user.username,