mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +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:
parent
06d85aa8d3
commit
cebe0f57f5
@ -17,6 +17,18 @@ Shows node permissions as a table.
|
||||
</adf-permission-list>
|
||||
```
|
||||
|
||||
If permissions list is empty, `No permissions` text is displayed,
|
||||
or custom template can be added:
|
||||
|
||||
```html
|
||||
<adf-permission-list [nodeId]="nodeId">
|
||||
<adf-no-permission-template>
|
||||
Custom no permission template!
|
||||
</adf-no-permission-template>
|
||||
</adf-permission-list>
|
||||
```
|
||||
|
||||
|
||||
### Properties
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
|
@ -235,7 +235,8 @@
|
||||
"INHERITED" : "Inherited",
|
||||
"AUTHORITY_ID" : "Authority ID",
|
||||
"ROLE": "Role",
|
||||
"LOCALLY_SET" : "Locally set"
|
||||
"LOCALLY_SET" : "Locally set",
|
||||
"NO_PERMISSIONS" : "No permissions"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -251,6 +251,67 @@ export const fakeNodeWithOnlyLocally: any = {
|
||||
}
|
||||
};
|
||||
|
||||
export const fakeNodeWithoutPermissions: any = {
|
||||
'aspectNames': [
|
||||
'cm:auditable',
|
||||
'cm:taggable',
|
||||
'cm:author',
|
||||
'cm:titled',
|
||||
'app:uifacets'
|
||||
],
|
||||
'createdAt': '2017-11-16T16:29:38.638+0000',
|
||||
'path': {
|
||||
'name': '/Company Home/Sites/testsite/documentLibrary',
|
||||
'isComplete': true,
|
||||
'elements': [
|
||||
{
|
||||
'id': '2be275a1-b00d-4e45-83d8-66af43ac2252',
|
||||
'name': 'Company Home'
|
||||
},
|
||||
{
|
||||
'id': '1be10a97-6eb9-4b60-b6c6-1673900e9631',
|
||||
'name': 'Sites'
|
||||
},
|
||||
{
|
||||
'id': 'e002c740-b8f9-482a-a554-8fff4e4c9dc0',
|
||||
'name': 'testsite'
|
||||
},
|
||||
{
|
||||
'id': '71626fae-0c04-4d0c-a129-20fa4c178716',
|
||||
'name': 'documentLibrary'
|
||||
}
|
||||
]
|
||||
},
|
||||
'isFolder': true,
|
||||
'isFile': false,
|
||||
'createdByUser': {
|
||||
'id': 'System',
|
||||
'displayName': 'System'
|
||||
},
|
||||
'modifiedAt': '2018-03-21T03:17:58.783+0000',
|
||||
'permissions': {
|
||||
'locallySet': [],
|
||||
'settable': [],
|
||||
'isInheritanceEnabled': false
|
||||
},
|
||||
'modifiedByUser': {
|
||||
'id': 'admin',
|
||||
'displayName': 'PedroH Hernandez'
|
||||
},
|
||||
'name': 'test',
|
||||
'id': 'f472543f-7218-403d-917b-7a5861257244',
|
||||
'nodeType': 'cm:folder',
|
||||
'properties': {
|
||||
'cm:title': 'test',
|
||||
'cm:author': 'yagud',
|
||||
'cm:taggable': [
|
||||
'e8c8fbba-03ba-4fa6-86b1-f7ad7c296409'
|
||||
],
|
||||
'cm:description': 'sleepery',
|
||||
'app:icon': 'space-icon-default'
|
||||
}
|
||||
};
|
||||
|
||||
export const fakeSiteNodeResponse: any = {
|
||||
'list': {
|
||||
'pagination': {
|
||||
|
@ -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';
|
||||
|
Loading…
x
Reference in New Issue
Block a user