diff --git a/docs/usage.md b/docs/usage.md index e7e1bede4..d019848d2 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -247,6 +247,13 @@ do not have an owner set. Note that superusers have access to all objects. +### Default permissions + +Default permissions for documents can be set using consumption templates. + +For objects created via the web UI (tags, doc types, etc.) the default is to set the current user +as owner and no extra permissions, but you explicitly set these under Settings > Permissions. + ### Users and Groups Paperless-ngx versions after 1.14.0 allow creating and editing users and groups via the 'frontend' UI. diff --git a/src-ui/messages.xlf b/src-ui/messages.xlf index 4f2cf697d..17261149c 100644 --- a/src-ui/messages.xlf +++ b/src-ui/messages.xlf @@ -455,7 +455,7 @@ src/app/components/manage/settings/settings.component.html - 192 + 268 @@ -519,7 +519,7 @@ src/app/components/manage/settings/settings.component.html - 189 + 265 @@ -723,7 +723,7 @@ src/app/components/manage/settings/settings.component.ts - 641 + 691 @@ -906,23 +906,23 @@ src/app/components/manage/settings/settings.component.html - 204 + 280 src/app/components/manage/settings/settings.component.html - 257 + 333 src/app/components/manage/settings/settings.component.html - 294 + 370 src/app/components/manage/settings/settings.component.html - 345 + 421 src/app/components/manage/settings/settings.component.html - 379 + 455 src/app/components/manage/tasks/tasks.component.html @@ -1081,7 +1081,7 @@ src/app/components/manage/settings/settings.component.html - 415 + 491 @@ -1116,14 +1116,14 @@ Create new item src/app/components/common/edit-dialog/edit-dialog.component.ts - 88 + 101 Edit item src/app/components/common/edit-dialog/edit-dialog.component.ts - 92 + 105 @@ -1168,6 +1168,10 @@ src/app/components/manage/management-list/management-list.component.html 10 + + src/app/components/manage/settings/settings.component.html + 135 + Create new user group @@ -1216,7 +1220,7 @@ src/app/components/manage/settings/settings.component.html - 344 + 420 @@ -1299,15 +1303,15 @@ src/app/components/manage/settings/settings.component.html - 230 + 306 src/app/components/manage/settings/settings.component.html - 320 + 396 src/app/components/manage/settings/settings.component.html - 406 + 482 src/app/components/manage/tasks/tasks.component.html @@ -1382,7 +1386,7 @@ src/app/components/manage/settings/settings.component.html - 295 + 371 @@ -1639,23 +1643,23 @@ src/app/components/manage/settings/settings.component.html - 222 + 298 src/app/components/manage/settings/settings.component.html - 270 + 346 src/app/components/manage/settings/settings.component.html - 307 + 383 src/app/components/manage/settings/settings.component.html - 359 + 435 src/app/components/manage/settings/settings.component.html - 394 + 470 @@ -1877,11 +1881,11 @@ src/app/components/manage/settings/settings.component.html - 346 + 422 src/app/components/manage/settings/settings.component.html - 367 + 443 @@ -2017,6 +2021,10 @@ src/app/components/common/input/permissions/permissions-form/permissions-form.component.html 25 + + src/app/components/manage/settings/settings.component.html + 150 + View @@ -2043,6 +2051,14 @@ src/app/components/common/input/permissions/permissions-form/permissions-form.component.html 50 + + src/app/components/manage/settings/settings.component.html + 160 + + + src/app/components/manage/settings/settings.component.html + 187 + Groups: @@ -2054,6 +2070,14 @@ src/app/components/common/input/permissions/permissions-form/permissions-form.component.html 58 + + src/app/components/manage/settings/settings.component.html + 170 + + + src/app/components/manage/settings/settings.component.html + 197 + Edit @@ -2107,19 +2131,19 @@ src/app/components/manage/settings/settings.component.html - 269 + 345 src/app/components/manage/settings/settings.component.html - 306 + 382 src/app/components/manage/settings/settings.component.html - 358 + 434 src/app/components/manage/settings/settings.component.html - 393 + 469 @@ -2128,6 +2152,10 @@ src/app/components/common/input/permissions/permissions-form/permissions-form.component.html 64 + + src/app/components/manage/settings/settings.component.html + 206 + Add item @@ -2213,7 +2241,7 @@ src/app/components/manage/settings/settings.component.html - 332 + 408 @@ -2742,23 +2770,23 @@ src/app/components/manage/settings/settings.component.html - 221 + 297 src/app/components/manage/settings/settings.component.html - 259 + 335 src/app/components/manage/settings/settings.component.html - 296 + 372 src/app/components/manage/settings/settings.component.html - 347 + 423 src/app/components/manage/settings/settings.component.html - 382 + 458 src/app/components/manage/tasks/tasks.component.html @@ -3155,19 +3183,19 @@ src/app/components/manage/settings/settings.component.ts - 746 + 796 src/app/components/manage/settings/settings.component.ts - 798 + 848 src/app/components/manage/settings/settings.component.ts - 857 + 907 src/app/components/manage/settings/settings.component.ts - 915 + 965 @@ -3182,19 +3210,19 @@ src/app/components/manage/settings/settings.component.ts - 748 + 798 src/app/components/manage/settings/settings.component.ts - 800 + 850 src/app/components/manage/settings/settings.component.ts - 859 + 909 src/app/components/manage/settings/settings.component.ts - 917 + 967 @@ -3634,7 +3662,7 @@ src/app/components/manage/settings/settings.component.html - 199 + 275 @@ -3759,7 +3787,7 @@ src/app/components/manage/settings/settings.component.html - 159 + 235 src/app/services/rest/document.service.ts @@ -3999,7 +4027,7 @@ src/app/components/manage/settings/settings.component.html - 216 + 292 @@ -4010,7 +4038,7 @@ src/app/components/manage/settings/settings.component.html - 212 + 288 @@ -4479,480 +4507,508 @@ 130 + + Settings apply to this user account for objects (Tags, Mail Rules, etc.) created via the web UI + + src/app/components/manage/settings/settings.component.html + 139,141 + + + + Default Owner + + src/app/components/manage/settings/settings.component.html + 146 + + + + Default View Permissions + + src/app/components/manage/settings/settings.component.html + 155 + + + + Default Edit Permissions + + src/app/components/manage/settings/settings.component.html + 182 + + Update checking src/app/components/manage/settings/settings.component.html - 135 + 211 Update checking works by pinging the public GitHub API for the latest release to determine whether a new version is available. Actual updating of the app must still be performed manually. src/app/components/manage/settings/settings.component.html - 139,142 + 215,218 No tracking data is collected by the app in any way. src/app/components/manage/settings/settings.component.html - 144,146 + 220,222 Enable update checking src/app/components/manage/settings/settings.component.html - 146 + 222 Note that for users of third-party containers e.g. linuxserver.io this notification may be 'ahead' of the current third-party release. src/app/components/manage/settings/settings.component.html - 146 + 222 Bulk editing src/app/components/manage/settings/settings.component.html - 150 + 226 Show confirmation dialogs src/app/components/manage/settings/settings.component.html - 154 + 230 Deleting documents will always ask for confirmation. src/app/components/manage/settings/settings.component.html - 154 + 230 Apply on close src/app/components/manage/settings/settings.component.html - 155 + 231 Enable notes src/app/components/manage/settings/settings.component.html - 163 + 239 Notifications src/app/components/manage/settings/settings.component.html - 171 + 247 Document processing src/app/components/manage/settings/settings.component.html - 174 + 250 Show notifications when new documents are detected src/app/components/manage/settings/settings.component.html - 178 + 254 Show notifications when document processing completes successfully src/app/components/manage/settings/settings.component.html - 179 + 255 Show notifications when document processing fails src/app/components/manage/settings/settings.component.html - 180 + 256 Suppress notifications on dashboard src/app/components/manage/settings/settings.component.html - 181 + 257 This will suppress all messages about document processing status on the dashboard. src/app/components/manage/settings/settings.component.html - 181 + 257 Show warning when closing saved views with unsaved changes src/app/components/manage/settings/settings.component.html - 195 + 271  Appears on src/app/components/manage/settings/settings.component.html - 209,210 + 285,286 No saved views defined. src/app/components/manage/settings/settings.component.html - 226 + 302 Mail src/app/components/manage/settings/settings.component.html - 239 + 315 Mail accounts src/app/components/manage/settings/settings.component.html - 245 + 321 Add Account src/app/components/manage/settings/settings.component.html - 250 + 326 Server src/app/components/manage/settings/settings.component.html - 258 + 334 No mail accounts defined. src/app/components/manage/settings/settings.component.html - 276 + 352 Mail rules src/app/components/manage/settings/settings.component.html - 282 + 358 Add Rule src/app/components/manage/settings/settings.component.html - 287 + 363 No mail rules defined. src/app/components/manage/settings/settings.component.html - 313 + 389 Users & Groups src/app/components/manage/settings/settings.component.html - 327 + 403 Add User src/app/components/manage/settings/settings.component.html - 337 + 413 Add Group src/app/components/manage/settings/settings.component.html - 372 + 448 Error retrieving groups src/app/components/manage/settings/settings.component.ts - 278 - - - - Error retrieving users - - src/app/components/manage/settings/settings.component.ts - 285 + 299 Error retrieving mail rules src/app/components/manage/settings/settings.component.ts - 309 + 325 Error retrieving mail accounts src/app/components/manage/settings/settings.component.ts - 317 + 333 + + + + Error retrieving users + + src/app/components/manage/settings/settings.component.ts + 350 Saved view "" deleted. src/app/components/manage/settings/settings.component.ts - 523 + 553 Settings saved src/app/components/manage/settings/settings.component.ts - 625 + 675 Settings were saved successfully. src/app/components/manage/settings/settings.component.ts - 626 + 676 Settings were saved successfully. Reload is required to apply some changes. src/app/components/manage/settings/settings.component.ts - 630 + 680 Reload now src/app/components/manage/settings/settings.component.ts - 631 + 681 Use system language src/app/components/manage/settings/settings.component.ts - 649 + 699 Use date format of display language src/app/components/manage/settings/settings.component.ts - 656 + 706 Error while storing settings on server. src/app/components/manage/settings/settings.component.ts - 676 + 726 Password has been changed, you will be logged out momentarily. src/app/components/manage/settings/settings.component.ts - 718 + 768 Saved user "". src/app/components/manage/settings/settings.component.ts - 725 + 775 Error saving user. src/app/components/manage/settings/settings.component.ts - 736 + 786 Confirm delete user account src/app/components/manage/settings/settings.component.ts - 744 + 794 This operation will permanently delete this user account. src/app/components/manage/settings/settings.component.ts - 745 + 795 Deleted user src/app/components/manage/settings/settings.component.ts - 754 + 804 Error deleting user. src/app/components/manage/settings/settings.component.ts - 761 + 811 Saved group "". src/app/components/manage/settings/settings.component.ts - 779 + 829 Error saving group. src/app/components/manage/settings/settings.component.ts - 788 + 838 Confirm delete user group src/app/components/manage/settings/settings.component.ts - 796 + 846 This operation will permanently delete this user group. src/app/components/manage/settings/settings.component.ts - 797 + 847 Deleted group src/app/components/manage/settings/settings.component.ts - 806 + 856 Error deleting group. src/app/components/manage/settings/settings.component.ts - 813 + 863 Saved account "". src/app/components/manage/settings/settings.component.ts - 836 + 886 Error saving account. src/app/components/manage/settings/settings.component.ts - 847 + 897 Confirm delete mail account src/app/components/manage/settings/settings.component.ts - 855 + 905 This operation will permanently delete this mail account. src/app/components/manage/settings/settings.component.ts - 856 + 906 Deleted mail account src/app/components/manage/settings/settings.component.ts - 865 + 915 Error deleting mail account. src/app/components/manage/settings/settings.component.ts - 874 + 924 Saved rule "". src/app/components/manage/settings/settings.component.ts - 894 + 944 Error saving rule. src/app/components/manage/settings/settings.component.ts - 905 + 955 Confirm delete mail rule src/app/components/manage/settings/settings.component.ts - 913 + 963 This operation will permanently delete this mail rule. src/app/components/manage/settings/settings.component.ts - 914 + 964 Deleted mail rule src/app/components/manage/settings/settings.component.ts - 923 + 973 Error deleting mail rule. src/app/components/manage/settings/settings.component.ts - 931 + 981 @@ -5702,21 +5758,21 @@ Successfully completed one-time migratration of settings to the database! src/app/services/settings.service.ts - 446 + 454 Unable to migrate settings to the database, please try saving manually. src/app/services/settings.service.ts - 447 + 455 You can restart the tour from the settings page. src/app/services/settings.service.ts - 521 + 529 diff --git a/src-ui/src/app/components/common/edit-dialog/correspondent-edit-dialog/correspondent-edit-dialog.component.spec.ts b/src-ui/src/app/components/common/edit-dialog/correspondent-edit-dialog/correspondent-edit-dialog.component.spec.ts index 843725ba8..9de47367c 100644 --- a/src-ui/src/app/components/common/edit-dialog/correspondent-edit-dialog/correspondent-edit-dialog.component.spec.ts +++ b/src-ui/src/app/components/common/edit-dialog/correspondent-edit-dialog/correspondent-edit-dialog.component.spec.ts @@ -1,18 +1,20 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing' -import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap' -import { CorrespondentEditDialogComponent } from './correspondent-edit-dialog.component' import { HttpClientTestingModule } from '@angular/common/http/testing' -import { EditDialogMode } from '../edit-dialog.component' +import { ComponentFixture, TestBed } from '@angular/core/testing' +import { FormsModule, ReactiveFormsModule } from '@angular/forms' +import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap' +import { NgSelectModule } from '@ng-select/ng-select' import { IfOwnerDirective } from 'src/app/directives/if-owner.directive' import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' -import { SelectComponent } from '../../input/select/select.component' -import { FormsModule, ReactiveFormsModule } from '@angular/forms' -import { TextComponent } from '../../input/text/text.component' -import { NgSelectModule } from '@ng-select/ng-select' +import { SettingsService } from 'src/app/services/settings.service' import { PermissionsFormComponent } from '../../input/permissions/permissions-form/permissions-form.component' +import { SelectComponent } from '../../input/select/select.component' +import { TextComponent } from '../../input/text/text.component' +import { EditDialogMode } from '../edit-dialog.component' +import { CorrespondentEditDialogComponent } from './correspondent-edit-dialog.component' describe('CorrespondentEditDialogComponent', () => { let component: CorrespondentEditDialogComponent + let settingsService: SettingsService let fixture: ComponentFixture beforeEach(async () => { @@ -36,6 +38,8 @@ describe('CorrespondentEditDialogComponent', () => { }).compileComponents() fixture = TestBed.createComponent(CorrespondentEditDialogComponent) + settingsService = TestBed.inject(SettingsService) + settingsService.currentUser = { id: 99, username: 'user99' } component = fixture.componentInstance fixture.detectChanges() diff --git a/src-ui/src/app/components/common/edit-dialog/document-type-edit-dialog/document-type-edit-dialog.component.spec.ts b/src-ui/src/app/components/common/edit-dialog/document-type-edit-dialog/document-type-edit-dialog.component.spec.ts index 676073acf..021953e31 100644 --- a/src-ui/src/app/components/common/edit-dialog/document-type-edit-dialog/document-type-edit-dialog.component.spec.ts +++ b/src-ui/src/app/components/common/edit-dialog/document-type-edit-dialog/document-type-edit-dialog.component.spec.ts @@ -1,18 +1,20 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing' -import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap' -import { DocumentTypeEditDialogComponent } from './document-type-edit-dialog.component' import { HttpClientTestingModule } from '@angular/common/http/testing' -import { EditDialogMode } from '../edit-dialog.component' +import { ComponentFixture, TestBed } from '@angular/core/testing' +import { FormsModule, ReactiveFormsModule } from '@angular/forms' +import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap' +import { NgSelectModule } from '@ng-select/ng-select' import { IfOwnerDirective } from 'src/app/directives/if-owner.directive' import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' -import { SelectComponent } from '../../input/select/select.component' -import { FormsModule, ReactiveFormsModule } from '@angular/forms' -import { TextComponent } from '../../input/text/text.component' -import { NgSelectModule } from '@ng-select/ng-select' +import { SettingsService } from 'src/app/services/settings.service' import { PermissionsFormComponent } from '../../input/permissions/permissions-form/permissions-form.component' +import { SelectComponent } from '../../input/select/select.component' +import { TextComponent } from '../../input/text/text.component' +import { EditDialogMode } from '../edit-dialog.component' +import { DocumentTypeEditDialogComponent } from './document-type-edit-dialog.component' describe('DocumentTypeEditDialogComponent', () => { let component: DocumentTypeEditDialogComponent + let settingsService: SettingsService let fixture: ComponentFixture beforeEach(async () => { @@ -36,6 +38,8 @@ describe('DocumentTypeEditDialogComponent', () => { }).compileComponents() fixture = TestBed.createComponent(DocumentTypeEditDialogComponent) + settingsService = TestBed.inject(SettingsService) + settingsService.currentUser = { id: 99, username: 'user99' } component = fixture.componentInstance fixture.detectChanges() diff --git a/src-ui/src/app/components/common/edit-dialog/edit-dialog.component.spec.ts b/src-ui/src/app/components/common/edit-dialog/edit-dialog.component.spec.ts index 18816d0d1..e81c7c99c 100644 --- a/src-ui/src/app/components/common/edit-dialog/edit-dialog.component.spec.ts +++ b/src-ui/src/app/components/common/edit-dialog/edit-dialog.component.spec.ts @@ -1,6 +1,6 @@ import { - HttpClientTestingModule, HttpTestingController, + HttpClientTestingModule, } from '@angular/common/http/testing' import { Component } from '@angular/core' import { @@ -16,19 +16,20 @@ import { ReactiveFormsModule, } from '@angular/forms' import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' +import { of } from 'rxjs' +import { + DEFAULT_MATCHING_ALGORITHM, + MATCH_AUTO, + MATCH_NONE, + MATCH_ALL, +} from 'src/app/data/matching-model' import { PaperlessTag } from 'src/app/data/paperless-tag' +import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings' import { TagService } from 'src/app/services/rest/tag.service' import { UserService } from 'src/app/services/rest/user.service' import { SettingsService } from 'src/app/services/settings.service' -import { EditDialogComponent, EditDialogMode } from './edit-dialog.component' -import { - DEFAULT_MATCHING_ALGORITHM, - MATCH_ALL, - MATCH_AUTO, - MATCH_NONE, -} from 'src/app/data/matching-model' -import { of } from 'rxjs' import { environment } from 'src/environments/environment' +import { EditDialogComponent, EditDialogMode } from './edit-dialog.component' @Component({ template: ` @@ -88,6 +89,7 @@ describe('EditDialogComponent', () => { let component: TestComponent let fixture: ComponentFixture let tagService: TagService + let settingsService: SettingsService let activeModal: NgbActiveModal let httpTestingController: HttpTestingController @@ -110,18 +112,15 @@ describe('EditDialogComponent', () => { }), }, }, - { - provide: SettingsService, - useValue: { - currentUser, - }, - }, + SettingsService, TagService, ], imports: [HttpClientTestingModule, FormsModule, ReactiveFormsModule], }).compileComponents() tagService = TestBed.inject(TagService) + settingsService = TestBed.inject(SettingsService) + settingsService.currentUser = currentUser activeModal = TestBed.inject(NgbActiveModal) httpTestingController = TestBed.inject(HttpTestingController) @@ -149,7 +148,7 @@ describe('EditDialogComponent', () => { expect(component.closeEnabled).toBeTruthy() })) - it('should set default owner when in create mode', () => { + it('should set default owner when in create mode if unset', () => { component.dialogMode = EditDialogMode.CREATE component.ngOnInit() expect(component.objectForm.get('permissions_form').value.owner).toEqual( @@ -160,6 +159,32 @@ describe('EditDialogComponent', () => { component.ngOnInit() }) + it('should set default perms when in create mode if set', () => { + component.dialogMode = EditDialogMode.CREATE + settingsService.set(SETTINGS_KEYS.DEFAULT_PERMS_OWNER, 11) + settingsService.set(SETTINGS_KEYS.DEFAULT_PERMS_VIEW_USERS, [1, 2]) + settingsService.set(SETTINGS_KEYS.DEFAULT_PERMS_VIEW_GROUPS, [3]) + settingsService.set(SETTINGS_KEYS.DEFAULT_PERMS_EDIT_USERS, [4]) + settingsService.set(SETTINGS_KEYS.DEFAULT_PERMS_EDIT_GROUPS, [5]) + component.ngOnInit() + expect(component.objectForm.get('permissions_form').value.owner).toEqual(11) + expect( + component.objectForm.get('permissions_form').value.set_permissions + ).toEqual({ + view: { + users: [1, 2], + groups: [3], + }, + change: { + users: [4], + groups: [5], + }, + }) + // cover optional chaining + component.objectForm.removeControl('permissions_form') + component.ngOnInit() + }) + it('should detect if pattern required', () => { expect(component.patternRequired).toBeFalsy() component.objectForm.get('matching_algorithm').setValue(MATCH_AUTO) diff --git a/src-ui/src/app/components/common/edit-dialog/edit-dialog.component.ts b/src-ui/src/app/components/common/edit-dialog/edit-dialog.component.ts index 89bd28100..30384ea31 100644 --- a/src-ui/src/app/components/common/edit-dialog/edit-dialog.component.ts +++ b/src-ui/src/app/components/common/edit-dialog/edit-dialog.component.ts @@ -14,6 +14,7 @@ import { AbstractPaperlessService } from 'src/app/services/rest/abstract-paperle import { UserService } from 'src/app/services/rest/user.service' import { PermissionsFormObject } from '../input/permissions/permissions-form/permissions-form.component' import { SettingsService } from 'src/app/services/settings.service' +import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings' export enum EditDialogMode { CREATE = 0, @@ -67,6 +68,31 @@ export abstract class EditDialogComponent< set_permissions: (this.object as ObjectWithPermissions).permissions, } this.objectForm.patchValue(this.object) + } else { + // defaults from settings + this.objectForm.patchValue({ + permissions_form: { + owner: this.settingsService.get(SETTINGS_KEYS.DEFAULT_PERMS_OWNER), + set_permissions: { + view: { + users: this.settingsService.get( + SETTINGS_KEYS.DEFAULT_PERMS_VIEW_USERS + ), + groups: this.settingsService.get( + SETTINGS_KEYS.DEFAULT_PERMS_VIEW_GROUPS + ), + }, + change: { + users: this.settingsService.get( + SETTINGS_KEYS.DEFAULT_PERMS_EDIT_USERS + ), + groups: this.settingsService.get( + SETTINGS_KEYS.DEFAULT_PERMS_EDIT_GROUPS + ), + }, + }, + }, + }) } // wait to enable close button so it doesnt steal focus from input since its the first clickable element in the DOM @@ -76,11 +102,6 @@ export abstract class EditDialogComponent< this.userService.listAll().subscribe((r) => { this.users = r.results - if (this.dialogMode === EditDialogMode.CREATE) { - this.objectForm.get('permissions_form')?.setValue({ - owner: this.settingsService.currentUser.id, - }) - } }) } diff --git a/src-ui/src/app/components/common/edit-dialog/group-edit-dialog/group-edit-dialog.component.spec.ts b/src-ui/src/app/components/common/edit-dialog/group-edit-dialog/group-edit-dialog.component.spec.ts index e762bbda7..8f0ee46db 100644 --- a/src-ui/src/app/components/common/edit-dialog/group-edit-dialog/group-edit-dialog.component.spec.ts +++ b/src-ui/src/app/components/common/edit-dialog/group-edit-dialog/group-edit-dialog.component.spec.ts @@ -1,19 +1,21 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing' -import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap' import { HttpClientTestingModule } from '@angular/common/http/testing' -import { EditDialogMode } from '../edit-dialog.component' +import { ComponentFixture, TestBed } from '@angular/core/testing' +import { FormsModule, ReactiveFormsModule } from '@angular/forms' +import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap' +import { NgSelectModule } from '@ng-select/ng-select' import { IfOwnerDirective } from 'src/app/directives/if-owner.directive' import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' -import { SelectComponent } from '../../input/select/select.component' -import { FormsModule, ReactiveFormsModule } from '@angular/forms' -import { TextComponent } from '../../input/text/text.component' -import { NgSelectModule } from '@ng-select/ng-select' +import { SettingsService } from 'src/app/services/settings.service' import { PermissionsFormComponent } from '../../input/permissions/permissions-form/permissions-form.component' -import { GroupEditDialogComponent } from './group-edit-dialog.component' +import { SelectComponent } from '../../input/select/select.component' +import { TextComponent } from '../../input/text/text.component' import { PermissionsSelectComponent } from '../../permissions-select/permissions-select.component' +import { EditDialogMode } from '../edit-dialog.component' +import { GroupEditDialogComponent } from './group-edit-dialog.component' describe('GroupEditDialogComponent', () => { let component: GroupEditDialogComponent + let settingsService: SettingsService let fixture: ComponentFixture beforeEach(async () => { @@ -38,6 +40,8 @@ describe('GroupEditDialogComponent', () => { }).compileComponents() fixture = TestBed.createComponent(GroupEditDialogComponent) + settingsService = TestBed.inject(SettingsService) + settingsService.currentUser = { id: 99, username: 'user99' } component = fixture.componentInstance fixture.detectChanges() diff --git a/src-ui/src/app/components/common/edit-dialog/mail-account-edit-dialog/mail-account-edit-dialog.component.spec.ts b/src-ui/src/app/components/common/edit-dialog/mail-account-edit-dialog/mail-account-edit-dialog.component.spec.ts index 1a35fb5ef..69767bd75 100644 --- a/src-ui/src/app/components/common/edit-dialog/mail-account-edit-dialog/mail-account-edit-dialog.component.spec.ts +++ b/src-ui/src/app/components/common/edit-dialog/mail-account-edit-dialog/mail-account-edit-dialog.component.spec.ts @@ -1,30 +1,32 @@ +import { + HttpTestingController, + HttpClientTestingModule, +} from '@angular/common/http/testing' import { ComponentFixture, TestBed, fakeAsync, tick, } from '@angular/core/testing' +import { FormsModule, ReactiveFormsModule } from '@angular/forms' import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap' -import { - HttpClientTestingModule, - HttpTestingController, -} from '@angular/common/http/testing' -import { EditDialogMode } from '../edit-dialog.component' +import { NgSelectModule } from '@ng-select/ng-select' +import { IMAPSecurity } from 'src/app/data/paperless-mail-account' import { IfOwnerDirective } from 'src/app/directives/if-owner.directive' import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' -import { SelectComponent } from '../../input/select/select.component' -import { FormsModule, ReactiveFormsModule } from '@angular/forms' -import { TextComponent } from '../../input/text/text.component' -import { NgSelectModule } from '@ng-select/ng-select' -import { PermissionsFormComponent } from '../../input/permissions/permissions-form/permissions-form.component' -import { MailAccountEditDialogComponent } from './mail-account-edit-dialog.component' -import { PasswordComponent } from '../../input/password/password.component' -import { CheckComponent } from '../../input/check/check.component' -import { IMAPSecurity } from 'src/app/data/paperless-mail-account' +import { SettingsService } from 'src/app/services/settings.service' import { environment } from 'src/environments/environment' +import { CheckComponent } from '../../input/check/check.component' +import { PasswordComponent } from '../../input/password/password.component' +import { PermissionsFormComponent } from '../../input/permissions/permissions-form/permissions-form.component' +import { SelectComponent } from '../../input/select/select.component' +import { TextComponent } from '../../input/text/text.component' +import { EditDialogMode } from '../edit-dialog.component' +import { MailAccountEditDialogComponent } from './mail-account-edit-dialog.component' describe('MailAccountEditDialogComponent', () => { let component: MailAccountEditDialogComponent + let settingsService: SettingsService let fixture: ComponentFixture let httpController: HttpTestingController @@ -53,6 +55,8 @@ describe('MailAccountEditDialogComponent', () => { httpController = TestBed.inject(HttpTestingController) fixture = TestBed.createComponent(MailAccountEditDialogComponent) + settingsService = TestBed.inject(SettingsService) + settingsService.currentUser = { id: 99, username: 'user99' } component = fixture.componentInstance fixture.detectChanges() diff --git a/src-ui/src/app/components/common/edit-dialog/mail-rule-edit-dialog/mail-rule-edit-dialog.component.spec.ts b/src-ui/src/app/components/common/edit-dialog/mail-rule-edit-dialog/mail-rule-edit-dialog.component.spec.ts index 5d089005b..9f5470c8a 100644 --- a/src-ui/src/app/components/common/edit-dialog/mail-rule-edit-dialog/mail-rule-edit-dialog.component.spec.ts +++ b/src-ui/src/app/components/common/edit-dialog/mail-rule-edit-dialog/mail-rule-edit-dialog.component.spec.ts @@ -1,29 +1,31 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing' -import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap' import { HttpClientTestingModule } from '@angular/common/http/testing' -import { EditDialogMode } from '../edit-dialog.component' -import { IfOwnerDirective } from 'src/app/directives/if-owner.directive' -import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' -import { SelectComponent } from '../../input/select/select.component' +import { ComponentFixture, TestBed } from '@angular/core/testing' import { FormsModule, ReactiveFormsModule } from '@angular/forms' -import { TextComponent } from '../../input/text/text.component' +import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap' import { NgSelectModule } from '@ng-select/ng-select' -import { PermissionsFormComponent } from '../../input/permissions/permissions-form/permissions-form.component' -import { MailRuleEditDialogComponent } from './mail-rule-edit-dialog.component' -import { NumberComponent } from '../../input/number/number.component' -import { TagsComponent } from '../../input/tags/tags.component' -import { SafeHtmlPipe } from 'src/app/pipes/safehtml.pipe' -import { MailAccountService } from 'src/app/services/rest/mail-account.service' -import { CorrespondentService } from 'src/app/services/rest/correspondent.service' -import { DocumentTypeService } from 'src/app/services/rest/document-type.service' import { of } from 'rxjs' import { - MailAction, MailMetadataCorrespondentOption, + MailAction, } from 'src/app/data/paperless-mail-rule' +import { IfOwnerDirective } from 'src/app/directives/if-owner.directive' +import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' +import { SafeHtmlPipe } from 'src/app/pipes/safehtml.pipe' +import { CorrespondentService } from 'src/app/services/rest/correspondent.service' +import { DocumentTypeService } from 'src/app/services/rest/document-type.service' +import { MailAccountService } from 'src/app/services/rest/mail-account.service' +import { SettingsService } from 'src/app/services/settings.service' +import { NumberComponent } from '../../input/number/number.component' +import { PermissionsFormComponent } from '../../input/permissions/permissions-form/permissions-form.component' +import { SelectComponent } from '../../input/select/select.component' +import { TagsComponent } from '../../input/tags/tags.component' +import { TextComponent } from '../../input/text/text.component' +import { EditDialogMode } from '../edit-dialog.component' +import { MailRuleEditDialogComponent } from './mail-rule-edit-dialog.component' describe('MailRuleEditDialogComponent', () => { let component: MailRuleEditDialogComponent + let settingsService: SettingsService let fixture: ComponentFixture let accountService: MailAccountService let correspondentService: CorrespondentService @@ -73,6 +75,8 @@ describe('MailRuleEditDialogComponent', () => { }).compileComponents() fixture = TestBed.createComponent(MailRuleEditDialogComponent) + settingsService = TestBed.inject(SettingsService) + settingsService.currentUser = { id: 99, username: 'user99' } component = fixture.componentInstance fixture.detectChanges() diff --git a/src-ui/src/app/components/common/edit-dialog/storage-path-edit-dialog/storage-path-edit-dialog.component.spec.ts b/src-ui/src/app/components/common/edit-dialog/storage-path-edit-dialog/storage-path-edit-dialog.component.spec.ts index f44092765..f76f8996a 100644 --- a/src-ui/src/app/components/common/edit-dialog/storage-path-edit-dialog/storage-path-edit-dialog.component.spec.ts +++ b/src-ui/src/app/components/common/edit-dialog/storage-path-edit-dialog/storage-path-edit-dialog.component.spec.ts @@ -1,19 +1,21 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing' -import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap' import { HttpClientTestingModule } from '@angular/common/http/testing' -import { EditDialogMode } from '../edit-dialog.component' +import { ComponentFixture, TestBed } from '@angular/core/testing' +import { FormsModule, ReactiveFormsModule } from '@angular/forms' +import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap' +import { NgSelectModule } from '@ng-select/ng-select' import { IfOwnerDirective } from 'src/app/directives/if-owner.directive' import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' -import { SelectComponent } from '../../input/select/select.component' -import { FormsModule, ReactiveFormsModule } from '@angular/forms' -import { TextComponent } from '../../input/text/text.component' -import { NgSelectModule } from '@ng-select/ng-select' -import { PermissionsFormComponent } from '../../input/permissions/permissions-form/permissions-form.component' -import { StoragePathEditDialogComponent } from './storage-path-edit-dialog.component' import { SafeHtmlPipe } from 'src/app/pipes/safehtml.pipe' +import { SettingsService } from 'src/app/services/settings.service' +import { PermissionsFormComponent } from '../../input/permissions/permissions-form/permissions-form.component' +import { SelectComponent } from '../../input/select/select.component' +import { TextComponent } from '../../input/text/text.component' +import { EditDialogMode } from '../edit-dialog.component' +import { StoragePathEditDialogComponent } from './storage-path-edit-dialog.component' describe('StoragePathEditDialogComponent', () => { let component: StoragePathEditDialogComponent + let settingsService: SettingsService let fixture: ComponentFixture beforeEach(async () => { @@ -38,6 +40,8 @@ describe('StoragePathEditDialogComponent', () => { }).compileComponents() fixture = TestBed.createComponent(StoragePathEditDialogComponent) + settingsService = TestBed.inject(SettingsService) + settingsService.currentUser = { id: 99, username: 'user99' } component = fixture.componentInstance fixture.detectChanges() diff --git a/src-ui/src/app/components/common/edit-dialog/tag-edit-dialog/tag-edit-dialog.component.spec.ts b/src-ui/src/app/components/common/edit-dialog/tag-edit-dialog/tag-edit-dialog.component.spec.ts index 73f3dd908..e46a0e034 100644 --- a/src-ui/src/app/components/common/edit-dialog/tag-edit-dialog/tag-edit-dialog.component.spec.ts +++ b/src-ui/src/app/components/common/edit-dialog/tag-edit-dialog/tag-edit-dialog.component.spec.ts @@ -1,20 +1,22 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing' -import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap' import { HttpClientTestingModule } from '@angular/common/http/testing' -import { EditDialogMode } from '../edit-dialog.component' +import { ComponentFixture, TestBed } from '@angular/core/testing' +import { FormsModule, ReactiveFormsModule } from '@angular/forms' +import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap' +import { NgSelectModule } from '@ng-select/ng-select' import { IfOwnerDirective } from 'src/app/directives/if-owner.directive' import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' -import { SelectComponent } from '../../input/select/select.component' -import { FormsModule, ReactiveFormsModule } from '@angular/forms' -import { TextComponent } from '../../input/text/text.component' -import { NgSelectModule } from '@ng-select/ng-select' -import { PermissionsFormComponent } from '../../input/permissions/permissions-form/permissions-form.component' -import { TagEditDialogComponent } from './tag-edit-dialog.component' -import { ColorComponent } from '../../input/color/color.component' +import { SettingsService } from 'src/app/services/settings.service' import { CheckComponent } from '../../input/check/check.component' +import { ColorComponent } from '../../input/color/color.component' +import { PermissionsFormComponent } from '../../input/permissions/permissions-form/permissions-form.component' +import { SelectComponent } from '../../input/select/select.component' +import { TextComponent } from '../../input/text/text.component' +import { EditDialogMode } from '../edit-dialog.component' +import { TagEditDialogComponent } from './tag-edit-dialog.component' describe('TagEditDialogComponent', () => { let component: TagEditDialogComponent + let settingsService: SettingsService let fixture: ComponentFixture beforeEach(async () => { @@ -29,7 +31,7 @@ describe('TagEditDialogComponent', () => { ColorComponent, CheckComponent, ], - providers: [NgbActiveModal], + providers: [NgbActiveModal, SettingsService], imports: [ HttpClientTestingModule, FormsModule, @@ -40,6 +42,8 @@ describe('TagEditDialogComponent', () => { }).compileComponents() fixture = TestBed.createComponent(TagEditDialogComponent) + settingsService = TestBed.inject(SettingsService) + settingsService.currentUser = { id: 99, username: 'user99' } component = fixture.componentInstance fixture.detectChanges() diff --git a/src-ui/src/app/components/common/edit-dialog/user-edit-dialog/user-edit-dialog.component.spec.ts b/src-ui/src/app/components/common/edit-dialog/user-edit-dialog/user-edit-dialog.component.spec.ts index 1418c74eb..afac0eabc 100644 --- a/src-ui/src/app/components/common/edit-dialog/user-edit-dialog/user-edit-dialog.component.spec.ts +++ b/src-ui/src/app/components/common/edit-dialog/user-edit-dialog/user-edit-dialog.component.spec.ts @@ -1,26 +1,28 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing' -import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap' import { HttpClientTestingModule } from '@angular/common/http/testing' -import { EditDialogMode } from '../edit-dialog.component' -import { IfOwnerDirective } from 'src/app/directives/if-owner.directive' -import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' -import { SelectComponent } from '../../input/select/select.component' +import { ComponentFixture, TestBed } from '@angular/core/testing' import { - AbstractControl, FormsModule, ReactiveFormsModule, + AbstractControl, } from '@angular/forms' -import { TextComponent } from '../../input/text/text.component' +import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap' import { NgSelectModule } from '@ng-select/ng-select' -import { PermissionsFormComponent } from '../../input/permissions/permissions-form/permissions-form.component' -import { UserEditDialogComponent } from './user-edit-dialog.component' -import { PasswordComponent } from '../../input/password/password.component' -import { PermissionsSelectComponent } from '../../permissions-select/permissions-select.component' -import { GroupService } from 'src/app/services/rest/group.service' import { of } from 'rxjs' +import { IfOwnerDirective } from 'src/app/directives/if-owner.directive' +import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' +import { GroupService } from 'src/app/services/rest/group.service' +import { SettingsService } from 'src/app/services/settings.service' +import { PasswordComponent } from '../../input/password/password.component' +import { PermissionsFormComponent } from '../../input/permissions/permissions-form/permissions-form.component' +import { SelectComponent } from '../../input/select/select.component' +import { TextComponent } from '../../input/text/text.component' +import { PermissionsSelectComponent } from '../../permissions-select/permissions-select.component' +import { EditDialogMode } from '../edit-dialog.component' +import { UserEditDialogComponent } from './user-edit-dialog.component' describe('UserEditDialogComponent', () => { let component: UserEditDialogComponent + let settingsService: SettingsService let fixture: ComponentFixture beforeEach(async () => { @@ -51,6 +53,7 @@ describe('UserEditDialogComponent', () => { }), }, }, + SettingsService, ], imports: [ HttpClientTestingModule, @@ -62,6 +65,8 @@ describe('UserEditDialogComponent', () => { }).compileComponents() fixture = TestBed.createComponent(UserEditDialogComponent) + settingsService = TestBed.inject(SettingsService) + settingsService.currentUser = { id: 99, username: 'user99' } component = fixture.componentInstance fixture.detectChanges() diff --git a/src-ui/src/app/components/manage/settings/settings.component.html b/src-ui/src/app/components/manage/settings/settings.component.html index 9ff2a06d3..cc5e7a15e 100644 --- a/src-ui/src/app/components/manage/settings/settings.component.html +++ b/src-ui/src/app/components/manage/settings/settings.component.html @@ -11,14 +11,14 @@