[ACS-6278] - Permissions manager should not be showed for smart folder (#3580)

This commit is contained in:
DominikIwanek 2024-01-02 18:31:44 +01:00 committed by GitHub
parent 5bb7c210a5
commit 8a97b3cc49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 5 deletions

View File

@ -9,7 +9,7 @@
<div class="aca-details-title">
<div class="aca-details-breadcrumb" role="heading" aria-level="2" *ngIf="node">
<span class="aca-details-breadcrumb-library">
<img class="aca-details-breadcrumb-icon" alt="{{ 'APP.INFO_DRAWER.ICON' | translate }}" src="{{ nodeIcon }}">
<img class="aca-details-breadcrumb-icon" alt="{{ 'APP.INFO_DRAWER.ICON' | translate }}" src="{{ nodeIcon }}">
{{ node.name }} </span>
</div>
<div class="acs-details-buttons">
@ -36,7 +36,7 @@
<app-comments-tab *ngIf="node && !isLoading; else loading" [node]="node"></app-comments-tab>
</ng-template>
</mat-tab>
<mat-tab label="{{ 'APP.INFO_DRAWER.TABS.PERMISSIONS' | translate }}">
<mat-tab [disabled]="!canManagePermissions" label="{{ 'APP.INFO_DRAWER.TABS.PERMISSIONS' | translate }}">
<ng-template matTabContent>
<adf-permission-list *ngIf="node && !isLoading; else loading" [nodeId]="node.id"></adf-permission-list>
</ng-template>

View File

@ -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);
});
});

View File

@ -22,7 +22,7 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/
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<ContentActionRef> = [];
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');
}
}