mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[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:
committed by
Denys Vuika
parent
85c0e42047
commit
7a95485a05
@@ -12,6 +12,7 @@
|
||||
"libraries": false,
|
||||
"comments": false,
|
||||
"cardview": false,
|
||||
"permissions": false,
|
||||
"share": false,
|
||||
"extensions": false
|
||||
},
|
||||
|
@@ -81,6 +81,9 @@ import { ExtensionsModule } from './extensions.module';
|
||||
import { ExtensionService } from './extensions/extension.service';
|
||||
import { CoreExtensionsModule } from './extensions/core.extensions';
|
||||
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({
|
||||
imports: [
|
||||
@@ -127,7 +130,10 @@ import { SearchResultsRowComponent } from './components/search/search-results-ro
|
||||
NodePermanentDeleteDirective,
|
||||
NodeUnshareDirective,
|
||||
NodeVersionsDirective,
|
||||
NodePermissionsDirective,
|
||||
NodeVersionsDialogComponent,
|
||||
NodePermissionsDialogComponent,
|
||||
PermissionsManagerComponent,
|
||||
SearchResultsComponent,
|
||||
SettingsComponent,
|
||||
InfoDrawerComponent,
|
||||
@@ -156,7 +162,8 @@ import { SearchResultsRowComponent } from './components/search/search-results-ro
|
||||
ExtensionService
|
||||
],
|
||||
entryComponents: [
|
||||
NodeVersionsDialogComponent
|
||||
NodeVersionsDialogComponent,
|
||||
NodePermissionsDialogComponent
|
||||
],
|
||||
bootstrap: [AppComponent]
|
||||
})
|
||||
|
80
src/app/common/directives/node-permissions.directive.ts
Normal file
80
src/app/common/directives/node-permissions.directive.ts
Normal 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')
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@@ -116,6 +116,16 @@
|
||||
<mat-icon>history</mat-icon>
|
||||
<span>{{ 'APP.ACTIONS.VERSIONS' | translate }}</span>
|
||||
</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>
|
||||
</ng-container>
|
||||
</adf-toolbar>
|
||||
|
@@ -121,6 +121,16 @@
|
||||
<mat-icon>history</mat-icon>
|
||||
<span>{{ 'APP.ACTIONS.VERSIONS' | translate }}</span>
|
||||
</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>
|
||||
</ng-container>
|
||||
</adf-toolbar>
|
||||
|
@@ -54,6 +54,7 @@ export abstract class PageComponent implements OnInit, OnDestroy {
|
||||
sharedPreviewUrl$: Observable<string>;
|
||||
actions: Array<ContentActionExtension> = [];
|
||||
canUpdateFile = false;
|
||||
canUpdateNode = false;
|
||||
canDelete = false;
|
||||
canEditFolder = false;
|
||||
canUpload = false;
|
||||
@@ -84,6 +85,7 @@ export abstract class PageComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
this.actions = this.extensions.getSelectedContentActions(selection, this.node);
|
||||
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.canEditFolder = selection.folder && this.content.canUpdateNode(selection.folder);
|
||||
this.canDeleteShared = !this.selection.isEmpty && this.content.canDeleteSharedNodes(selection.nodes);
|
||||
|
@@ -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>
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -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));
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
@@ -75,6 +75,16 @@
|
||||
<mat-icon>history</mat-icon>
|
||||
<span>{{ 'APP.ACTIONS.VERSIONS' | translate }}</span>
|
||||
</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>
|
||||
</ng-container>
|
||||
|
@@ -109,6 +109,16 @@
|
||||
<mat-icon>history</mat-icon>
|
||||
<span>{{ 'APP.ACTIONS.VERSIONS' | translate }}</span>
|
||||
</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>
|
||||
</ng-container>
|
||||
</adf-toolbar>
|
||||
|
@@ -72,6 +72,16 @@
|
||||
<mat-icon>history</mat-icon>
|
||||
<span>{{ 'APP.ACTIONS.VERSIONS' | translate }}</span>
|
||||
</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>
|
||||
</ng-container>
|
||||
</adf-toolbar>
|
||||
|
@@ -106,6 +106,16 @@
|
||||
<mat-icon>history</mat-icon>
|
||||
<span>{{ 'APP.ACTIONS.VERSIONS' | translate }}</span>
|
||||
</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>
|
||||
</ng-container>
|
||||
</adf-toolbar>
|
||||
|
@@ -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>
|
42
src/app/dialogs/node-permissions/node-permissions.dialog.ts
Normal file
42
src/app/dialogs/node-permissions/node-permissions.dialog.ts
Normal 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;
|
||||
}
|
||||
}
|
@@ -8,6 +8,7 @@
|
||||
@import '../components/settings/settings.component.theme';
|
||||
@import '../components/current-user/current-user.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 './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-search-input-theme($theme);
|
||||
@include aca-generic-error-theme($theme);
|
||||
@include aca-permissions-manager-theme($theme);
|
||||
@include aca-node-versions-dialog-theme($theme);
|
||||
@include aca-settings-theme($theme);
|
||||
@include snackbar-theme($theme);
|
||||
|
@@ -120,6 +120,7 @@
|
||||
"DELETE_PERMANENT": "Permanently delete",
|
||||
"MORE": "More actions",
|
||||
"UNDO": "Undo",
|
||||
"PERMISSIONS": "Permissions",
|
||||
"RESTORE": "Restore",
|
||||
"FAVORITE": "Favorite",
|
||||
"UNSHARE": "Unshare",
|
||||
@@ -250,6 +251,14 @@
|
||||
"MOVE_ITEMS": "Move {{ number }} items to...",
|
||||
"SEARCH": "Search"
|
||||
},
|
||||
"PERMISSIONS": {
|
||||
"DIALOG": {
|
||||
"TITLE": "Manage Permissons",
|
||||
"CLOSE": "Close",
|
||||
"INHERIT_PERMISSIONS_BUTTON": "Inherit Permission",
|
||||
"INHERITED_PERMISSIONS_BUTTON": "Permission Inherited"
|
||||
}
|
||||
},
|
||||
"VERSION": {
|
||||
"DIALOG": {
|
||||
"TITLE": "Manage Versions",
|
||||
|
Reference in New Issue
Block a user