diff --git a/src-ui/src/app/components/app-frame/app-frame.component.ts b/src-ui/src/app/components/app-frame/app-frame.component.ts index 4d4968ea4..7d6c2531c 100644 --- a/src-ui/src/app/components/app-frame/app-frame.component.ts +++ b/src-ui/src/app/components/app-frame/app-frame.component.ts @@ -35,6 +35,7 @@ import { } from '@angular/cdk/drag-drop' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { ProfileEditDialogComponent } from '../common/profile-edit-dialog/profile-edit-dialog.component' +import { ObjectWithId } from 'src/app/data/object-with-id' @Component({ selector: 'pngx-app-frame', diff --git a/src-ui/src/app/components/app-frame/global-search/global-search.component.html b/src-ui/src/app/components/app-frame/global-search/global-search.component.html index 7ad5a65c3..a434eaf23 100644 --- a/src-ui/src/app/components/app-frame/global-search/global-search.component.html +++ b/src-ui/src/app/components/app-frame/global-search/global-search.component.html @@ -28,6 +28,7 @@
-
+
@if (searchResults?.total === 0) { } @else { diff --git a/src-ui/src/app/components/app-frame/global-search/global-search.component.ts b/src-ui/src/app/components/app-frame/global-search/global-search.component.ts index 7223dcfa9..be008af7e 100644 --- a/src-ui/src/app/components/app-frame/global-search/global-search.component.ts +++ b/src-ui/src/app/components/app-frame/global-search/global-search.component.ts @@ -1,5 +1,4 @@ import { - AfterViewInit, Component, ElementRef, HostListener, @@ -34,6 +33,10 @@ import { FILTER_HAS_DOCUMENT_TYPE_ANY, FILTER_HAS_STORAGE_PATH_ANY, } from 'src/app/data/filter-rule-type' +import { + PermissionAction, + PermissionsService, +} from 'src/app/services/permissions.service' @Component({ selector: 'pngx-global-search', @@ -81,7 +84,7 @@ export class GlobalSearchComponent { this.currentItemIndex = -1 } } else if (event.key === 'ArrowRight') { - this.secondaryButtons.get(this.domIndex).nativeElement.focus() + this.secondaryButtons.get(this.domIndex)?.nativeElement.focus() } else if (event.key === 'ArrowLeft') { this.primaryButtons.get(this.domIndex).nativeElement.focus() } @@ -93,7 +96,8 @@ export class GlobalSearchComponent { private router: Router, private modalService: NgbModal, private documentService: DocumentService, - private documentListViewService: DocumentListViewService + private documentListViewService: DocumentListViewService, + private permissionsService: PermissionsService ) { this.queryDebounce = new Subject() @@ -268,4 +272,26 @@ export class GlobalSearchComponent { this.reset() } } + + public disablePrimaryButton(type: string, object: ObjectWithId): boolean { + if (['workflow', 'customField', 'group', 'user'].includes(type)) { + return !this.permissionsService.currentUserHasObjectPermissions( + PermissionAction.Change, + object + ) + } + + return false + } + + public disableSecondaryButton(type: string, object: ObjectWithId): boolean { + if ('document' === type) { + return false + } + + return !this.permissionsService.currentUserHasObjectPermissions( + PermissionAction.Change, + object + ) + } }