mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-2560] Empty template for nodes without permissions (#3171)
* No permissions template * Unit test added * custom template * template selector changed * tslint error fix
This commit is contained in:
committed by
Eugenio Romano
parent
06d85aa8d3
commit
cebe0f57f5
@@ -0,0 +1,26 @@
|
||||
/*!
|
||||
* @license
|
||||
* Copyright 2016 Alfresco Software, Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* tslint:disable:no-input-rename */
|
||||
|
||||
import { Component} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-no-permission-template',
|
||||
template: '<ng-content></ng-content>'
|
||||
})
|
||||
export class NoPermissionTemplateComponent {}
|
@@ -1,5 +1,16 @@
|
||||
<div id="adf-permission-display-container" class="adf-display-permission-container">
|
||||
<adf-datatable [rows]="permissionList" class="adf-datatable-permission">
|
||||
|
||||
<div *ngIf="!permissionList || !permissionList.length" id="adf-no-permissions-template">
|
||||
<div #ref>
|
||||
<ng-content select="adf-no-permission-template"></ng-content>
|
||||
</div>
|
||||
|
||||
<p *ngIf="ref.children.length == 0">
|
||||
{{ 'PERMISSION_MANAGER.PERMISSION_DISPLAY.NO_PERMISSIONS' | translate }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<adf-datatable [rows]="permissionList" class="adf-datatable-permission" *ngIf="permissionList && permissionList.length">
|
||||
<data-columns>
|
||||
<data-column key="icon" type="icon" [sortable]="false">
|
||||
</data-column>
|
||||
|
@@ -26,6 +26,7 @@ import { fakeNodeWithPermissions,
|
||||
fakeNodeWithOnlyLocally,
|
||||
fakeSiteNodeResponse,
|
||||
fakeSiteRoles,
|
||||
fakeNodeWithoutPermissions,
|
||||
fakeEmptyResponse } from '../../../mock/permission-list.component.mock';
|
||||
|
||||
describe('PermissionDisplayComponent', () => {
|
||||
@@ -63,6 +64,16 @@ describe('PermissionDisplayComponent', () => {
|
||||
expect(element.querySelector('#adf-permission-display-container')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should render default empty template when no permissions', () => {
|
||||
component.nodeId = 'fake-node-id';
|
||||
spyOn(nodeService, 'getNode').and.returnValue(Observable.of(fakeNodeWithoutPermissions));
|
||||
spyOn(searchApiService, 'searchByQueryBody').and.returnValue(Observable.of(fakeEmptyResponse));
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(element.querySelector('#adf-no-permissions-template')).not.toBeNull();
|
||||
expect(element.querySelector('#adf-permission-display-container .adf-datatable-permission')).toBeNull();
|
||||
});
|
||||
|
||||
it('should show the node permissions', () => {
|
||||
component.nodeId = 'fake-node-id';
|
||||
spyOn(nodeService, 'getNode').and.returnValue(Observable.of(fakeNodeWithPermissions));
|
||||
|
@@ -24,6 +24,7 @@ import { PermissionListComponent } from './components/permission-list/permission
|
||||
import { DataTableModule, DataColumnModule } from '@alfresco/adf-core';
|
||||
import { InheritPermissionDirective } from './components/inherited-button.directive';
|
||||
import { NodePermissionService } from './services/node-permission.service';
|
||||
import { NoPermissionTemplateComponent } from "./components/permission-list/no-permission.component";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
@@ -37,6 +38,7 @@ import { NodePermissionService } from './services/node-permission.service';
|
||||
],
|
||||
declarations: [
|
||||
PermissionListComponent,
|
||||
NoPermissionTemplateComponent,
|
||||
InheritPermissionDirective
|
||||
],
|
||||
providers: [
|
||||
@@ -44,6 +46,7 @@ import { NodePermissionService } from './services/node-permission.service';
|
||||
],
|
||||
exports: [
|
||||
PermissionListComponent,
|
||||
NoPermissionTemplateComponent,
|
||||
InheritPermissionDirective
|
||||
]
|
||||
})
|
||||
|
@@ -16,6 +16,7 @@
|
||||
*/
|
||||
|
||||
export * from './components/permission-list/permission-list.component';
|
||||
export * from './components/permission-list/no-permission.component';
|
||||
export * from './components/inherited-button.directive';
|
||||
export * from './services/node-permission.service';
|
||||
export * from './models/permission.model';
|
||||
|
Reference in New Issue
Block a user