[ACA-1113] Node Permissions - experimental (#501)

* [ACA-1113] Integrate permissions

* [ACA-1113] experimental flag for permissions

* [ACA-1113] permissions shown only on write permission

* [ACA-1113] remove console.logs
This commit is contained in:
Suzana Dirla
2018-07-09 17:20:54 +03:00
committed by Denys Vuika
parent 85c0e42047
commit 7a95485a05
17 changed files with 371 additions and 1 deletions

View File

@@ -12,6 +12,7 @@
"libraries": false, "libraries": false,
"comments": false, "comments": false,
"cardview": false, "cardview": false,
"permissions": false,
"share": false, "share": false,
"extensions": false "extensions": false
}, },

View File

@@ -81,6 +81,9 @@ import { ExtensionsModule } from './extensions.module';
import { ExtensionService } from './extensions/extension.service'; import { ExtensionService } from './extensions/extension.service';
import { CoreExtensionsModule } from './extensions/core.extensions'; import { CoreExtensionsModule } from './extensions/core.extensions';
import { SearchResultsRowComponent } from './components/search/search-results-row/search-results-row.component'; import { SearchResultsRowComponent } from './components/search/search-results-row/search-results-row.component';
import { NodePermissionsDialogComponent } from './dialogs/node-permissions/node-permissions.dialog';
import { NodePermissionsDirective } from './common/directives/node-permissions.directive';
import { PermissionsManagerComponent } from './components/permission-manager/permissions-manager.component';
@NgModule({ @NgModule({
imports: [ imports: [
@@ -127,7 +130,10 @@ import { SearchResultsRowComponent } from './components/search/search-results-ro
NodePermanentDeleteDirective, NodePermanentDeleteDirective,
NodeUnshareDirective, NodeUnshareDirective,
NodeVersionsDirective, NodeVersionsDirective,
NodePermissionsDirective,
NodeVersionsDialogComponent, NodeVersionsDialogComponent,
NodePermissionsDialogComponent,
PermissionsManagerComponent,
SearchResultsComponent, SearchResultsComponent,
SettingsComponent, SettingsComponent,
InfoDrawerComponent, InfoDrawerComponent,
@@ -156,7 +162,8 @@ import { SearchResultsRowComponent } from './components/search/search-results-ro
ExtensionService ExtensionService
], ],
entryComponents: [ entryComponents: [
NodeVersionsDialogComponent NodeVersionsDialogComponent,
NodePermissionsDialogComponent
], ],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })

View File

@@ -0,0 +1,80 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Directive, HostListener, Input } from '@angular/core';
import { MinimalNodeEntity } from 'alfresco-js-api';
import { MatDialog } from '@angular/material';
import { Store } from '@ngrx/store';
import { AppStore } from '../../store/states/app.state';
import { SnackbarErrorAction } from '../../store/actions';
import { NodePermissionsDialogComponent } from '../../dialogs/node-permissions/node-permissions.dialog';
@Directive({
selector: '[acaNodePermissions]'
})
export class NodePermissionsDirective {
// tslint:disable-next-line:no-input-rename
@Input('acaNodePermissions') node: MinimalNodeEntity;
@HostListener('click')
onClick() {
this.showPermissions();
}
constructor(
private store: Store<AppStore>,
private dialog: MatDialog
) {}
showPermissions() {
if (this.node) {
let entry;
if (this.node.entry) {
entry = this.node.entry;
} else {
entry = this.node;
}
const entryId = entry.nodeId || (<any>entry).guid || entry.id;
this.openPermissionsDialog(entryId);
}
}
openPermissionsDialog(nodeId: string) {
// workaround Shared
if (nodeId) {
this.dialog.open(NodePermissionsDialogComponent, {
data: { nodeId },
panelClass: 'aca-permissions-dialog-panel',
width: '730px'
});
} else {
this.store.dispatch(
new SnackbarErrorAction('APP.MESSAGES.ERRORS.PERMISSION')
);
}
}
}

View File

@@ -116,6 +116,16 @@
<mat-icon>history</mat-icon> <mat-icon>history</mat-icon>
<span>{{ 'APP.ACTIONS.VERSIONS' | translate }}</span> <span>{{ 'APP.ACTIONS.VERSIONS' | translate }}</span>
</button> </button>
<ng-container *ifExperimental="'permissions'">
<button
mat-menu-item
*ngIf="selection.count === 1"
[acaNodePermissions]="selection.first">
<mat-icon>settings_input_component</mat-icon>
<span>{{ 'APP.ACTIONS.PERMISSIONS' | translate }}</span>
</button>
</ng-container>
</mat-menu> </mat-menu>
</ng-container> </ng-container>
</adf-toolbar> </adf-toolbar>

View File

@@ -121,6 +121,16 @@
<mat-icon>history</mat-icon> <mat-icon>history</mat-icon>
<span>{{ 'APP.ACTIONS.VERSIONS' | translate }}</span> <span>{{ 'APP.ACTIONS.VERSIONS' | translate }}</span>
</button> </button>
<ng-container *ifExperimental="'permissions'">
<button
mat-menu-item
*ngIf="canUpdateNode"
[acaNodePermissions]="selection.first">
<mat-icon>settings_input_component</mat-icon>
<span>{{ 'APP.ACTIONS.PERMISSIONS' | translate }}</span>
</button>
</ng-container>
</mat-menu> </mat-menu>
</ng-container> </ng-container>
</adf-toolbar> </adf-toolbar>

View File

@@ -54,6 +54,7 @@ export abstract class PageComponent implements OnInit, OnDestroy {
sharedPreviewUrl$: Observable<string>; sharedPreviewUrl$: Observable<string>;
actions: Array<ContentActionExtension> = []; actions: Array<ContentActionExtension> = [];
canUpdateFile = false; canUpdateFile = false;
canUpdateNode = false;
canDelete = false; canDelete = false;
canEditFolder = false; canEditFolder = false;
canUpload = false; canUpload = false;
@@ -84,6 +85,7 @@ export abstract class PageComponent implements OnInit, OnDestroy {
} }
this.actions = this.extensions.getSelectedContentActions(selection, this.node); this.actions = this.extensions.getSelectedContentActions(selection, this.node);
this.canUpdateFile = this.selection.file && this.content.canUpdateNode(selection.file); this.canUpdateFile = this.selection.file && this.content.canUpdateNode(selection.file);
this.canUpdateNode = this.selection.count === 1 && this.content.canUpdateNode(selection.first);
this.canDelete = !this.selection.isEmpty && this.content.canDeleteNodes(selection.nodes); this.canDelete = !this.selection.isEmpty && this.content.canDeleteNodes(selection.nodes);
this.canEditFolder = selection.folder && this.content.canUpdateNode(selection.folder); this.canEditFolder = selection.folder && this.content.canUpdateNode(selection.folder);
this.canDeleteShared = !this.selection.isEmpty && this.content.canDeleteSharedNodes(selection.nodes); this.canDeleteShared = !this.selection.isEmpty && this.content.canDeleteSharedNodes(selection.nodes);

View File

@@ -0,0 +1,20 @@
<div class="inherit_permission_button">
<button mat-raised-button
adf-inherit-permission
[nodeId]="nodeId"
[color]="toggleStatus?'accent':'primary'"
(error)="onError($event)"
(updated)="onUpdatedPermissions($event)">
{{ (toggleStatus?'PERMISSIONS.DIALOG.INHERITED_PERMISSIONS_BUTTON':'PERMISSIONS.DIALOG.INHERIT_PERMISSIONS_BUTTON') | translate}}</button>
<button mat-button (click)="openAddPermissionDialog($event)">Add User or Group</button>
</div>
<div>
<adf-permission-list
#permissionList
[nodeId]="nodeId"
(error)="onError($event)"
(update)="onUpdate($event)">
</adf-permission-list>
</div>

View File

@@ -0,0 +1,49 @@
@mixin aca-permissions-manager-theme($theme) {
$foreground: map-get($theme, foreground);
$accent: map-get($theme, accent);
aca-permissions-dialog-panel {
height: 400px;
}
.aca-node-permissions-dialog {
.mat-dialog-title {
font-size: 20px;
font-weight: 600;
font-style: normal;
font-stretch: normal;
line-height: 1.6;
margin: 0;
letter-spacing: -0.5px;
color: mat-color($foreground, text, 0.87);
}
.mat-dialog-content {
flex: 1 1 auto;
position: relative;
overflow: auto;
adf-permission-list {
display: flex;
}
}
.mat-dialog-actions {
flex: 0 0 auto;
padding: 8px 8px 24px 8px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: end;
-ms-flex-pack: end;
justify-content: flex-end;
color: mat-color($foreground, text, 0.54);
button {
text-transform: uppercase;
font-weight: normal;
}
}
}
}

View File

@@ -0,0 +1,91 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { NodePermissionDialogService, PermissionListComponent } from '@alfresco/adf-content-services';
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
import { Store } from '@ngrx/store';
import { AppStore } from '../../store/states/app.state';
import { SnackbarErrorAction } from '../../store/actions/snackbar.actions';
import { NodePermissionsDialogComponent } from '../../dialogs/node-permissions/node-permissions.dialog';
import { MatDialog } from '@angular/material';
import { ContentApiService } from '../../services/content-api.service';
@Component({
selector: 'aca-permissions-manager',
templateUrl: './permissions-manager.component.html'
})
export class PermissionsManagerComponent implements OnInit {
@ViewChild('permissionList')
permissionList: PermissionListComponent;
@Input()
nodeId: string;
toggleStatus = false;
constructor(
private store: Store<AppStore>,
private dialog: MatDialog,
private contentApi: ContentApiService,
private nodePermissionDialogService: NodePermissionDialogService
) {
}
ngOnInit() {
this.contentApi.getNodeInfo(this.nodeId, {include: ['permissions'] }).subscribe( (currentNode: MinimalNodeEntryEntity) => {
this.toggleStatus = currentNode.permissions.isInheritanceEnabled;
});
}
onError(errorMessage: string) {
this.store.dispatch(new SnackbarErrorAction(errorMessage));
}
onUpdate(event) {
this.permissionList.reload();
}
onUpdatedPermissions(node: MinimalNodeEntryEntity) {
this.toggleStatus = node.permissions.isInheritanceEnabled;
this.permissionList.reload();
}
openAddPermissionDialog(event: Event) {
this.nodePermissionDialogService.updateNodePermissionByDialog(this.nodeId)
.subscribe(() => {
this.dialog.open(NodePermissionsDialogComponent, {
data: { nodeId: this.nodeId },
panelClass: 'aca-permissions-dialog-panel',
width: '800px'
}
);
},
(error) => {
this.store.dispatch(new SnackbarErrorAction(error));
}
);
}
}

View File

@@ -75,6 +75,16 @@
<mat-icon>history</mat-icon> <mat-icon>history</mat-icon>
<span>{{ 'APP.ACTIONS.VERSIONS' | translate }}</span> <span>{{ 'APP.ACTIONS.VERSIONS' | translate }}</span>
</button> </button>
<ng-container *ifExperimental="'permissions'">
<button
mat-menu-item
*ngIf="canUpdateNode"
[acaNodePermissions]="selection.first">
<mat-icon>settings_input_component</mat-icon>
<span>{{ 'APP.ACTIONS.PERMISSIONS' | translate }}</span>
</button>
</ng-container>
</adf-viewer-more-actions> </adf-viewer-more-actions>
</adf-viewer> </adf-viewer>
</ng-container> </ng-container>

View File

@@ -109,6 +109,16 @@
<mat-icon>history</mat-icon> <mat-icon>history</mat-icon>
<span>{{ 'APP.ACTIONS.VERSIONS' | translate }}</span> <span>{{ 'APP.ACTIONS.VERSIONS' | translate }}</span>
</button> </button>
<ng-container *ifExperimental="'permissions'">
<button
mat-menu-item
*ngIf="canUpdateNode"
[acaNodePermissions]="selection.first">
<mat-icon>settings_input_component</mat-icon>
<span>{{ 'APP.ACTIONS.PERMISSIONS' | translate }}</span>
</button>
</ng-container>
</mat-menu> </mat-menu>
</ng-container> </ng-container>
</adf-toolbar> </adf-toolbar>

View File

@@ -72,6 +72,16 @@
<mat-icon>history</mat-icon> <mat-icon>history</mat-icon>
<span>{{ 'APP.ACTIONS.VERSIONS' | translate }}</span> <span>{{ 'APP.ACTIONS.VERSIONS' | translate }}</span>
</button> </button>
<ng-container *ifExperimental="'permissions'">
<button
mat-menu-item
*ngIf="canUpdateNode"
[acaNodePermissions]="selection.first">
<mat-icon>settings_input_component</mat-icon>
<span>{{ 'APP.ACTIONS.PERMISSIONS' | translate }}</span>
</button>
</ng-container>
</mat-menu> </mat-menu>
</ng-container> </ng-container>
</adf-toolbar> </adf-toolbar>

View File

@@ -106,6 +106,16 @@
<mat-icon>history</mat-icon> <mat-icon>history</mat-icon>
<span>{{ 'APP.ACTIONS.VERSIONS' | translate }}</span> <span>{{ 'APP.ACTIONS.VERSIONS' | translate }}</span>
</button> </button>
<ng-container *ifExperimental="'permissions'">
<button
mat-menu-item
*ngIf="canUpdateShared"
[acaNodePermissions]="selection.first">
<mat-icon>settings_input_component</mat-icon>
<span>{{ 'APP.ACTIONS.PERMISSIONS' | translate }}</span>
</button>
</ng-container>
</mat-menu> </mat-menu>
</ng-container> </ng-container>
</adf-toolbar> </adf-toolbar>

View File

@@ -0,0 +1,7 @@
<header mat-dialog-title>{{'PERMISSIONS.DIALOG.TITLE' | translate}}</header>
<section mat-dialog-content>
<aca-permissions-manager [nodeId]="nodeId"></aca-permissions-manager>
</section>
<footer mat-dialog-actions>
<button mat-button color="primary" [mat-dialog-close]="true" cdkFocusInitial>{{'PERMISSIONS.DIALOG.CLOSE' | translate}}</button>
</footer>

View File

@@ -0,0 +1,42 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Component, Inject, ViewEncapsulation } from '@angular/core';
import { MAT_DIALOG_DATA } from '@angular/material';
@Component({
templateUrl: './node-permissions.dialog.html',
encapsulation: ViewEncapsulation.None,
host: { class: 'aca-node-permissions-dialog' }
})
export class NodePermissionsDialogComponent {
nodeId: string;
constructor(
@Inject(MAT_DIALOG_DATA) data: any,
) {
this.nodeId = data.nodeId;
}
}

View File

@@ -8,6 +8,7 @@
@import '../components/settings/settings.component.theme'; @import '../components/settings/settings.component.theme';
@import '../components/current-user/current-user.component.theme'; @import '../components/current-user/current-user.component.theme';
@import '../components/header/header.component.theme'; @import '../components/header/header.component.theme';
@import '../components/permission-manager/permissions-manager.component.theme';
@import '../dialogs/node-versions/node-versions.dialog.theme'; @import '../dialogs/node-versions/node-versions.dialog.theme';
@import './overrides/adf-toolbar.theme'; @import './overrides/adf-toolbar.theme';
@@ -83,6 +84,7 @@ $custom-theme: mat-light-theme($custom-theme-primary, $custom-theme-accent);
@include aca-header-theme($theme); @include aca-header-theme($theme);
@include aca-search-input-theme($theme); @include aca-search-input-theme($theme);
@include aca-generic-error-theme($theme); @include aca-generic-error-theme($theme);
@include aca-permissions-manager-theme($theme);
@include aca-node-versions-dialog-theme($theme); @include aca-node-versions-dialog-theme($theme);
@include aca-settings-theme($theme); @include aca-settings-theme($theme);
@include snackbar-theme($theme); @include snackbar-theme($theme);

View File

@@ -120,6 +120,7 @@
"DELETE_PERMANENT": "Permanently delete", "DELETE_PERMANENT": "Permanently delete",
"MORE": "More actions", "MORE": "More actions",
"UNDO": "Undo", "UNDO": "Undo",
"PERMISSIONS": "Permissions",
"RESTORE": "Restore", "RESTORE": "Restore",
"FAVORITE": "Favorite", "FAVORITE": "Favorite",
"UNSHARE": "Unshare", "UNSHARE": "Unshare",
@@ -250,6 +251,14 @@
"MOVE_ITEMS": "Move {{ number }} items to...", "MOVE_ITEMS": "Move {{ number }} items to...",
"SEARCH": "Search" "SEARCH": "Search"
}, },
"PERMISSIONS": {
"DIALOG": {
"TITLE": "Manage Permissons",
"CLOSE": "Close",
"INHERIT_PERMISSIONS_BUTTON": "Inherit Permission",
"INHERITED_PERMISSIONS_BUTTON": "Permission Inherited"
}
},
"VERSION": { "VERSION": {
"DIALOG": { "DIALOG": {
"TITLE": "Manage Versions", "TITLE": "Manage Versions",