Skip to content

Commit

Permalink
[ACS-6278] - Permissions manager should not be showed for smart folder
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikiwanekhyland committed Jan 2, 2024
1 parent 5bb7c21 commit c3a6720
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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();
Expand All @@ -79,14 +80,15 @@ 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);
this.nodeId = params.nodeId;
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);
});
Expand All @@ -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':
Expand All @@ -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');
}
}

0 comments on commit c3a6720

Please sign in to comment.