mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
update menu permission (#273)
This commit is contained in:
parent
142b179841
commit
d21d7c5fab
@ -21,25 +21,24 @@
|
||||
<mat-menu #menu="matMenu" [overlapTrigger]="false">
|
||||
<button
|
||||
mat-menu-item
|
||||
[disabled]="!canCreateContent(node)"
|
||||
[disabled]="!permission.check(node, ['create'])"
|
||||
[adf-create-folder]="node?.id"
|
||||
title="{{
|
||||
( canCreateContent(node)
|
||||
[title]="
|
||||
( permission.check(node, ['create'])
|
||||
? 'APP.NEW_MENU.TOOLTIPS.CREATE_FOLDER'
|
||||
: 'APP.NEW_MENU.TOOLTIPS.CREATE_FOLDER_NOT_ALLOWED'
|
||||
) | translate
|
||||
}}">
|
||||
) | translate">
|
||||
<mat-icon>create_new_folder</mat-icon>
|
||||
<span>{{ 'APP.NEW_MENU.MENU_ITEMS.CREATE_FOLDER' | translate }}</span>
|
||||
</button>
|
||||
|
||||
<adf-upload-button
|
||||
tooltip="{{
|
||||
(canCreateContent(node)
|
||||
[tooltip]="
|
||||
(permission.check(node, ['create'])
|
||||
? 'APP.NEW_MENU.TOOLTIPS.UPLOAD_FILES'
|
||||
: 'APP.NEW_MENU.TOOLTIPS.UPLOAD_FILES_NOT_ALLOWED'
|
||||
) | translate }}"
|
||||
[disabled]="!canCreateContent(node)"
|
||||
) | translate"
|
||||
[disabled]="!permission.check(node, ['create'])"
|
||||
[rootFolderId]="node?.id"
|
||||
[multipleFiles]="true"
|
||||
[uploadFolders]="false"
|
||||
@ -47,12 +46,12 @@
|
||||
</adf-upload-button>
|
||||
|
||||
<adf-upload-button
|
||||
tooltip="{{
|
||||
(canCreateContent(node)
|
||||
[tooltip]="
|
||||
(permission.check(node, ['create'])
|
||||
? 'APP.NEW_MENU.TOOLTIPS.UPLOAD_FOLDERS'
|
||||
: 'APP.NEW_MENU.TOOLTIPS.UPLOAD_FOLDERS_NOT_ALLOWED'
|
||||
) | translate }}"
|
||||
[disabled]="!canCreateContent(node)"
|
||||
) | translate"
|
||||
[disabled]="!permission.check(node, ['create'])"
|
||||
[rootFolderId]="node?.id"
|
||||
[multipleFiles]="true"
|
||||
[uploadFolders]="true"
|
||||
|
@ -30,18 +30,18 @@ import { TranslateModule } from '@ngx-translate/core';
|
||||
import { MatMenuModule } from '@angular/material';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import {
|
||||
ContentService, AppConfigService, AuthenticationService,
|
||||
AppConfigService, AuthenticationService,
|
||||
UserPreferencesService, StorageService, AlfrescoApiService,
|
||||
CookieService, LogService
|
||||
} from '@alfresco/adf-core';
|
||||
import { BrowsingFilesService } from '../../common/services/browsing-files.service';
|
||||
import { NodePermissionService } from '../../common/services/node-permission.service';
|
||||
|
||||
import { SidenavComponent } from './sidenav.component';
|
||||
|
||||
describe('SidenavComponent', () => {
|
||||
let fixture;
|
||||
let component: SidenavComponent;
|
||||
let contentService: ContentService;
|
||||
let browsingService: BrowsingFilesService;
|
||||
let appConfig: AppConfigService;
|
||||
let appConfigSpy;
|
||||
@ -71,7 +71,7 @@ describe('SidenavComponent', () => {
|
||||
StorageService,
|
||||
UserPreferencesService,
|
||||
AuthenticationService,
|
||||
ContentService,
|
||||
NodePermissionService,
|
||||
AppConfigService,
|
||||
BrowsingFilesService
|
||||
],
|
||||
@ -79,7 +79,6 @@ describe('SidenavComponent', () => {
|
||||
})
|
||||
.compileComponents()
|
||||
.then(() => {
|
||||
contentService = TestBed.get(ContentService);
|
||||
browsingService = TestBed.get(BrowsingFilesService);
|
||||
appConfig = TestBed.get(AppConfigService);
|
||||
|
||||
@ -99,32 +98,6 @@ describe('SidenavComponent', () => {
|
||||
expect(component.node).toBe(node);
|
||||
});
|
||||
|
||||
it('should have permission to create content', () => {
|
||||
fixture.detectChanges();
|
||||
spyOn(contentService, 'hasPermission').and.returnValue(true);
|
||||
const node: any = {};
|
||||
|
||||
expect(component.canCreateContent(node)).toBe(true);
|
||||
expect(contentService.hasPermission).toHaveBeenCalledWith(node, 'create');
|
||||
});
|
||||
|
||||
it('should not have permission to create content for missing node', () => {
|
||||
fixture.detectChanges();
|
||||
spyOn(contentService, 'hasPermission').and.returnValue(true);
|
||||
|
||||
expect(component.canCreateContent(null)).toBe(false);
|
||||
expect(contentService.hasPermission).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not have permission to create content based on node permission', () => {
|
||||
fixture.detectChanges();
|
||||
spyOn(contentService, 'hasPermission').and.returnValue(false);
|
||||
const node: any = {};
|
||||
|
||||
expect(component.canCreateContent(node)).toBe(false);
|
||||
expect(contentService.hasPermission).toHaveBeenCalledWith(node, 'create');
|
||||
});
|
||||
|
||||
describe('menu', () => {
|
||||
it('should build menu from array', () => {
|
||||
appConfigSpy.and.returnValue([navItem, navItem]);
|
||||
|
@ -26,9 +26,10 @@
|
||||
import { Subscription } from 'rxjs/Rx';
|
||||
import { Component, Input, OnInit, OnDestroy } from '@angular/core';
|
||||
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
|
||||
import { ContentService, AppConfigService } from '@alfresco/adf-core';
|
||||
import { AppConfigService } from '@alfresco/adf-core';
|
||||
|
||||
import { BrowsingFilesService } from '../../common/services/browsing-files.service';
|
||||
import { NodePermissionService } from '../../common/services/node-permission.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-sidenav',
|
||||
@ -45,8 +46,8 @@ export class SidenavComponent implements OnInit, OnDestroy {
|
||||
|
||||
constructor(
|
||||
private browsingFilesService: BrowsingFilesService,
|
||||
private contentService: ContentService,
|
||||
private appConfig: AppConfigService
|
||||
private appConfig: AppConfigService,
|
||||
public permission: NodePermissionService
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
@ -62,13 +63,6 @@ export class SidenavComponent implements OnInit, OnDestroy {
|
||||
this.subscriptions.forEach(s => s.unsubscribe());
|
||||
}
|
||||
|
||||
canCreateContent(parentNode: MinimalNodeEntryEntity): boolean {
|
||||
if (parentNode) {
|
||||
return this.contentService.hasPermission(parentNode, 'create');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private buildMenu() {
|
||||
const schema = this.appConfig.get('navigation');
|
||||
const data = Array.isArray(schema) ? { main: schema } : schema;
|
||||
|
Loading…
x
Reference in New Issue
Block a user