mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
update permission (#275)
This commit is contained in:
parent
9840e29531
commit
b970caa56d
@ -1,7 +1,7 @@
|
||||
<div class="layout">
|
||||
<adf-upload-drag-area
|
||||
[parentId]="node?.id"
|
||||
[disabled]="!canCreateContent(node)">
|
||||
[disabled]="!permission.check(node, ['create'])">
|
||||
|
||||
<adf-sidenav-layout
|
||||
[sidenavMin]="70"
|
||||
|
@ -30,7 +30,7 @@ import { MinimalNodeEntryEntity } from 'alfresco-js-api';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import {
|
||||
ContentService, PeopleContentService, AppConfigService,
|
||||
PeopleContentService, AppConfigService,
|
||||
AuthenticationService, UserPreferencesService, TranslationService,
|
||||
TranslationMock, StorageService, AlfrescoApiService, CookieService,
|
||||
LogService
|
||||
@ -38,14 +38,13 @@ import {
|
||||
import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import { BrowsingFilesService } from '../../common/services/browsing-files.service';
|
||||
import { NodePermissionService } from '../../common/services/node-permission.service';
|
||||
import { LayoutComponent } from './layout.component';
|
||||
|
||||
describe('LayoutComponent', () => {
|
||||
let fixture: ComponentFixture<LayoutComponent>;
|
||||
let component: LayoutComponent;
|
||||
let browsingFilesService: BrowsingFilesService;
|
||||
let contentService: ContentService;
|
||||
let node;
|
||||
const navItem = {
|
||||
label: 'some-label',
|
||||
route: {
|
||||
@ -54,8 +53,6 @@ describe('LayoutComponent', () => {
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
node = { id: 'node-id' };
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
HttpClientModule,
|
||||
@ -73,8 +70,8 @@ describe('LayoutComponent', () => {
|
||||
LogService,
|
||||
UserPreferencesService,
|
||||
AuthenticationService,
|
||||
ContentService,
|
||||
AppConfigService,
|
||||
NodePermissionService,
|
||||
BrowsingFilesService,
|
||||
{
|
||||
provide: PeopleContentService,
|
||||
@ -89,7 +86,6 @@ describe('LayoutComponent', () => {
|
||||
fixture = TestBed.createComponent(LayoutComponent);
|
||||
component = fixture.componentInstance;
|
||||
browsingFilesService = TestBed.get(BrowsingFilesService);
|
||||
contentService = TestBed.get(ContentService);
|
||||
|
||||
const appConfig = TestBed.get(AppConfigService);
|
||||
spyOn(appConfig, 'get').and.returnValue([navItem]);
|
||||
@ -104,28 +100,4 @@ describe('LayoutComponent', () => {
|
||||
|
||||
expect(component.node).toEqual(currentNode);
|
||||
});
|
||||
|
||||
describe('canCreateContent()', () => {
|
||||
it('returns true if node has permission', () => {
|
||||
spyOn(contentService, 'hasPermission').and.returnValue(true);
|
||||
|
||||
const permission = component.canCreateContent(<any>{});
|
||||
|
||||
expect(permission).toBe(true);
|
||||
});
|
||||
|
||||
it('returns false if node does not have permission', () => {
|
||||
spyOn(contentService, 'hasPermission').and.returnValue(false);
|
||||
|
||||
const permission = component.canCreateContent(<any>{});
|
||||
|
||||
expect(permission).toBe(false);
|
||||
});
|
||||
|
||||
it('returns false if node is null', () => {
|
||||
const permission = component.canCreateContent(null);
|
||||
|
||||
expect(permission).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -27,8 +27,8 @@ import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||
import { Router, NavigationEnd } from '@angular/router';
|
||||
import { Subscription } from 'rxjs/Rx';
|
||||
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
|
||||
import { ContentService } from '@alfresco/adf-core';
|
||||
import { BrowsingFilesService } from '../../common/services/browsing-files.service';
|
||||
import { NodePermissionService } from '../../common/services/node-permission.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-layout',
|
||||
@ -43,8 +43,8 @@ export class LayoutComponent implements OnInit, OnDestroy {
|
||||
|
||||
constructor(
|
||||
private router: Router,
|
||||
private contentService: ContentService,
|
||||
private browsingFilesService: BrowsingFilesService) {
|
||||
private browsingFilesService: BrowsingFilesService,
|
||||
public permission: NodePermissionService) {
|
||||
this.router.events
|
||||
.filter(event => event instanceof NavigationEnd)
|
||||
.subscribe( (event: any ) => {
|
||||
@ -61,11 +61,4 @@ export class LayoutComponent implements OnInit, OnDestroy {
|
||||
ngOnDestroy() {
|
||||
this.subscriptions.forEach(s => s.unsubscribe());
|
||||
}
|
||||
|
||||
canCreateContent(node: MinimalNodeEntryEntity): boolean {
|
||||
if (node) {
|
||||
return this.contentService.hasPermission(node, 'create');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user