From e15b3ae9deb7c1c43bf3180917944c8625bc2f4e Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Mon, 8 Apr 2024 21:00:06 -0700 Subject: [PATCH] Frontend handle auditlog disabled --- .../document-detail.component.html | 18 ++++++++++-------- .../document-detail.component.ts | 10 ++++++++++ src-ui/src/app/data/ui-settings.ts | 6 ++++++ .../src/app/services/settings.service.spec.ts | 1 + src/documents/tests/test_api_uisettings.py | 1 + src/documents/views.py | 2 ++ 6 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src-ui/src/app/components/document-detail/document-detail.component.html b/src-ui/src/app/components/document-detail/document-detail.component.html index b9796380a..f4a5e44d3 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.html +++ b/src-ui/src/app/components/document-detail/document-detail.component.html @@ -285,14 +285,16 @@ } -
  • - History - -
    - -
    -
    -
  • + @if (auditlogEnabled) { +
  • + History + +
    + +
    +
    +
  • + } @if (showPermissions) {
  • diff --git a/src-ui/src/app/components/document-detail/document-detail.component.ts b/src-ui/src/app/components/document-detail/document-detail.component.ts index f1aa3fc7a..0f391683a 100644 --- a/src-ui/src/app/components/document-detail/document-detail.component.ts +++ b/src-ui/src/app/components/document-detail/document-detail.component.ts @@ -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[]) { this.document.notes = notes this.openDocumentService.refreshDocument(this.documentId) diff --git a/src-ui/src/app/data/ui-settings.ts b/src-ui/src/app/data/ui-settings.ts index e55f25278..41f9ba361 100644 --- a/src-ui/src/app/data/ui-settings.ts +++ b/src-ui/src/app/data/ui-settings.ts @@ -37,6 +37,7 @@ export const SETTINGS_KEYS = { NOTIFICATIONS_CONSUMER_SUPPRESS_ON_DASHBOARD: 'general-settings:notifications:consumer-suppress-on-dashboard', NOTES_ENABLED: 'general-settings:notes-enabled', + AUDITLOG_ENABLED: 'general-settings:auditlog-enabled', SLIM_SIDEBAR: 'general-settings:slim-sidebar', UPDATE_CHECKING_ENABLED: 'general-settings:update-checking:enabled', UPDATE_CHECKING_BACKEND_SETTING: @@ -143,6 +144,11 @@ export const SETTINGS: UiSetting[] = [ type: 'boolean', default: true, }, + { + key: SETTINGS_KEYS.AUDITLOG_ENABLED, + type: 'boolean', + default: true, + }, { key: SETTINGS_KEYS.UPDATE_CHECKING_ENABLED, type: 'boolean', diff --git a/src-ui/src/app/services/settings.service.spec.ts b/src-ui/src/app/services/settings.service.spec.ts index ff0a9837b..71568dc4b 100644 --- a/src-ui/src/app/services/settings.service.spec.ts +++ b/src-ui/src/app/services/settings.service.spec.ts @@ -47,6 +47,7 @@ describe('SettingsService', () => { update_checking: { enabled: false, backend_setting: 'default' }, saved_views: { warn_on_unsaved_change: true }, notes_enabled: true, + auditlog_enabled: true, tour_complete: false, permissions: { default_owner: null, diff --git a/src/documents/tests/test_api_uisettings.py b/src/documents/tests/test_api_uisettings.py index 2cb6af6f2..0a52ea41c 100644 --- a/src/documents/tests/test_api_uisettings.py +++ b/src/documents/tests/test_api_uisettings.py @@ -39,6 +39,7 @@ class TestApiUiSettings(DirectoriesMixin, APITestCase): { "app_title": None, "app_logo": None, + "auditlog_enabled": True, "update_checking": { "backend_setting": "default", }, diff --git a/src/documents/views.py b/src/documents/views.py index 1e5485079..48a745092 100644 --- a/src/documents/views.py +++ b/src/documents/views.py @@ -1300,6 +1300,8 @@ class UiSettingsView(GenericAPIView): 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["auditlog_enabled"] = settings.AUDIT_LOG_ENABLED + user_resp = { "id": user.id, "username": user.username,