A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Fix: hide version delete button without global perms (#13735)
shamoon751299895e4c
diff --git a/src-ui/src/app/components/document-detail/document-version-dropdown/document-version-dropdown.component.html b/src-ui/src/app/components/document-detail/document-version-dropdown/document-version-dropdown.component.htmlindex 9032a2e4a..8f94c0440 100644--- a/src-ui/src/app/components/document-detail/document-version-dropdown/document-version-dropdown.component.html+++ b/src-ui/src/app/components/document-detail/document-version-dropdown/document-version-dropdown.component.html@@ -141,6 +141,7 @@i18n-confirmMessage[disabled]="!userIsOwner || !userCanEdit"(confirm)="deleteVersion(version.id)"+ *pngxIfPermissions="{ action: PermissionAction.Delete, type: PermissionType.Document }"><span class="visually-hidden" i18n>Delete version</span></pngx-confirm-button>diff --git a/src-ui/src/app/components/document-detail/document-version-dropdown/document-version-dropdown.component.spec.ts b/src-ui/src/app/components/document-detail/document-version-dropdown/document-version-dropdown.component.spec.tsindex 23f1ad499..f0e30197f 100644--- a/src-ui/src/app/components/document-detail/document-version-dropdown/document-version-dropdown.component.spec.ts+++ b/src-ui/src/app/components/document-detail/document-version-dropdown/document-version-dropdown.component.spec.ts@@ -1,10 +1,16 @@import { DatePipe } from '@angular/common'import { SimpleChange, signal } from '@angular/core'import { ComponentFixture, TestBed } from '@angular/core/testing'+import { By } from '@angular/platform-browser'import { NgbModal } from '@ng-bootstrap/ng-bootstrap'import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons'import { Subject, of, throwError } from 'rxjs'import { DocumentVersionInfo } from 'src/app/data/document'+import {+ PermissionAction,+ PermissionsService,+ PermissionType,+} from 'src/app/services/permissions.service'import { DocumentService } from 'src/app/services/rest/document.service'import { SettingsService } from 'src/app/services/settings.service'import { ToastService } from 'src/app/services/toast.service'@@ -31,6 +37,9 @@ describe('DocumentVersionDropdownComponent', () => {let finished$: Subject<{ taskId: string }>let failed$: Subject<{ taskId: string; message?: string }>let modalService: jest.Mocked<Pick<NgbModal, 'open'>>+ let permissionsService: jest.Mocked<+ Pick<PermissionsService, 'currentUserCan'>+ >beforeEach(async () => {finished$ = new Subject<{ taskId: string }>()@@ -47,6 +56,9 @@ describe('DocumentVersionDropdownComponent', () => {showError: jest.fn(),showInfo: jest.fn(),}+ permissionsService = {+ currentUserCan: jest.fn().mockReturnValue(true),+ }await TestBed.configureTestingModule({imports: [@@ -73,6 +85,10 @@ describe('DocumentVersionDropdownComponent', () => {provide: NgbModal,useValue: modalService,},+ {+ provide: PermissionsService,+ useValue: permissionsService,+ },{provide: WebsocketStatusService,useValue: {@@ -143,6 +159,31 @@ describe('DocumentVersionDropdownComponent', () => {)})+ it('should not show version delete buttons without document delete permission', () => {+ fixture.destroy()+ permissionsService.currentUserCan.mockReturnValue(false)+ fixture = TestBed.createComponent(DocumentVersionDropdownComponent)+ component = fixture.componentInstance+ component.documentId = 3+ component.selectedVersionId = 3+ component.userIsOwner = true+ component.userCanEdit = true+ component.versions = [+ { id: 3, is_root: true, checksum: 'aaaa' },+ { id: 10, is_root: false, checksum: 'bbbb' },+ ]++ fixture.detectChanges()++ expect(permissionsService.currentUserCan).toHaveBeenCalledWith(+ PermissionAction.Delete,+ PermissionType.Document+ )+ expect(+ fixture.debugElement.queryAll(By.css('pngx-confirm-button'))+ ).toHaveLength(0)+ })+it('beginEditingVersion should set active row and draft label', () => {component.userCanEdit = truecomponent.userIsOwner = truediff --git a/src-ui/src/app/components/document-detail/document-version-dropdown/document-version-dropdown.component.ts b/src-ui/src/app/components/document-detail/document-version-dropdown/document-version-dropdown.component.tsindex f9711fd76..a341cfa16 100644--- a/src-ui/src/app/components/document-detail/document-version-dropdown/document-version-dropdown.component.ts+++ b/src-ui/src/app/components/document-detail/document-version-dropdown/document-version-dropdown.component.ts@@ -25,6 +25,7 @@ import {tap,} from 'rxjs/operators'import { DocumentVersionInfo } from 'src/app/data/document'+import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe'import { DocumentService } from 'src/app/services/rest/document.service'import { ToastService } from 'src/app/services/toast.service'@@ -33,6 +34,7 @@ import {WebsocketStatusService,} from 'src/app/services/websocket-status.service'import { ConfirmButtonComponent } from '../../common/confirm-button/confirm-button.component'+import { ComponentWithPermissions } from '../../with-permissions/with-permissions.component'import { AddExistingDocumentVersionDialogComponent } from './add-existing-document-version-dialog/add-existing-document-version-dialog.component'@Component({@@ -44,11 +46,15 @@ import { AddExistingDocumentVersionDialogComponent } from './add-existing-documeNgbDropdownModule,NgxBootstrapIconsModule,ConfirmButtonComponent,+ IfPermissionsDirective,SlicePipe,CustomDatePipe,],})-export class DocumentVersionDropdownComponent implements OnChanges, OnDestroy {+export class DocumentVersionDropdownComponent+ extends ComponentWithPermissions+ implements OnChanges, OnDestroy+{UploadState = UploadState@Input() documentId: number