diff --git a/projects/aca-content/src/lib/components/details/details.component.html b/projects/aca-content/src/lib/components/details/details.component.html index fcc9101aa7..d0c1bc6d56 100644 --- a/projects/aca-content/src/lib/components/details/details.component.html +++ b/projects/aca-content/src/lib/components/details/details.component.html @@ -9,7 +9,7 @@
- {{ 'APP.INFO_DRAWER.ICON' | translate }} + {{ 'APP.INFO_DRAWER.ICON' | translate }} {{ node.name }}
@@ -36,7 +36,7 @@ - + diff --git a/projects/aca-content/src/lib/components/details/details.component.spec.ts b/projects/aca-content/src/lib/components/details/details.component.spec.ts index 3856abecc9..591fd64b09 100644 --- a/projects/aca-content/src/lib/components/details/details.component.spec.ts +++ b/projects/aca-content/src/lib/components/details/details.component.spec.ts @@ -30,7 +30,7 @@ import { BehaviorSubject, of, Subject } from 'rxjs'; import { NO_ERRORS_SCHEMA } from '@angular/core'; import { Store } from '@ngrx/store'; import { ContentApiService } from '@alfresco/aca-shared'; -import { STORE_INITIAL_APP_DATA, SetSelectedNodesAction, NavigateToFolder } from '@alfresco/aca-shared/store'; +import { NavigateToFolder, SetSelectedNodesAction, STORE_INITIAL_APP_DATA } from '@alfresco/aca-shared/store'; import { NodeEntry, PathElement } from '@alfresco/js-api'; import { RouterTestingModule } from '@angular/router/testing'; import { AuthenticationService, PageTitleService } from '@alfresco/adf-core'; @@ -201,4 +201,45 @@ describe('DetailsComponent', () => { fail(`An error occurred: ${error}`); }); }); + + it('should disable the permissions tab for smart folders based on aspects', () => { + node.entry.isFolder = true; + node.entry.aspectNames = ['smf:customConfigSmartFolder']; + fixture.detectChanges(); + component.ngOnInit(); + expect(component.canManagePermissions).toBeFalse(); + expect(component.activeTab).not.toBe(2); + }); + + it('should enable the permissions tab for regular folders based on aspects', () => { + node.entry.isFolder = true; + node.entry.aspectNames = []; + fixture.detectChanges(); + component.ngOnInit(); + + expect(component.canManagePermissions).toBeTrue(); + }); + + it('should change active tab based on canManagePermissions and tabName', () => { + component.nodeId = 'someNodeId'; + component.activeTab = 0; + + node.entry.isFolder = true; + node.entry.aspectNames = []; + + fixture.detectChanges(); + component.ngOnInit(); + + component.setActiveTab('permissions'); + expect(component.activeTab).toBe(2); + + node.entry.isFolder = true; + node.entry.aspectNames = ['smf:customConfigSmartFolder']; + + fixture.detectChanges(); + component.ngOnInit(); + + component.setActiveTab('permissions'); + expect(component.activeTab).not.toBe(2); + }); }); diff --git a/projects/aca-content/src/lib/components/details/details.component.ts b/projects/aca-content/src/lib/components/details/details.component.ts index 95ebbb1c19..245cf3b122 100644 --- a/projects/aca-content/src/lib/components/details/details.component.ts +++ b/projects/aca-content/src/lib/components/details/details.component.ts @@ -22,7 +22,7 @@ * from Hyland Software. If not, see . */ -import { Component, OnInit, ViewEncapsulation, OnDestroy } from '@angular/core'; +import { Component, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { ContentApiService, PageComponent, PageLayoutComponent, ToolbarComponent } from '@alfresco/aca-shared'; import { NavigateToFolder, NavigateToPreviousPage, SetSelectedNodesAction } from '@alfresco/aca-shared/store'; @@ -68,6 +68,7 @@ export class DetailsComponent extends PageComponent implements OnInit, OnDestroy activeTab = 1; aspectActions: Array = []; nodeIcon: string; + canManagePermissions = true; constructor(private route: ActivatedRoute, private contentApi: ContentApiService, private contentService: ContentService) { super(); @@ -79,7 +80,6 @@ export class DetailsComponent extends PageComponent implements OnInit, OnDestroy const { route } = this; const { data } = route.snapshot; this.title = data.title; - this.route.params.subscribe((params) => { this.isLoading = true; this.setActiveTab(params.activeTab); @@ -87,6 +87,8 @@ export class DetailsComponent extends PageComponent implements OnInit, OnDestroy this.contentApi.getNode(this.nodeId).subscribe((node) => { this.node = node.entry; this.isLoading = false; + this.canManagePermissions = !this.isSmartFolder(); + this.setActiveTab(params.activeTab); this.store.dispatch(new SetSelectedNodesAction([{ entry: this.node }])); this.nodeIcon = this.contentService.getNodeIcon(this.node); }); @@ -105,6 +107,10 @@ export class DetailsComponent extends PageComponent implements OnInit, OnDestroy this.activeTab = 1; break; case 'permissions': + if (!this.canManagePermissions) { + this.activeTab = 0; + break; + } this.activeTab = 2; break; case 'metadata': @@ -126,4 +132,12 @@ export class DetailsComponent extends PageComponent implements OnInit, OnDestroy this.onDestroy$.next(); this.onDestroy$.complete(); } + + private isSmartFolder(): boolean { + if (!this.node?.isFolder) { + return false; + } + const nodeAspects = this.node.aspectNames ?? []; + return nodeAspects.includes('smf:customConfigSmartFolder') || nodeAspects.includes('smf:systemConfigSmartFolder'); + } }