diff --git a/src/app/common/common.module.ts b/src/app/common/common.module.ts index c23ad7a14..40cbbb33b 100644 --- a/src/app/common/common.module.ts +++ b/src/app/common/common.module.ts @@ -37,6 +37,7 @@ import { NodeMoveDirective } from './directives/node-move.directive'; import { DownloadFileDirective } from './directives/node-download.directive'; import { NodeRestoreDirective } from './directives/node-restore.directive'; import { NodePermanentDeleteDirective } from './directives/node-permanent-delete.directive'; +import { NodeUnshareDirective } from './directives/node-unshare.directive'; import { ContentManagementService } from './services/content-management.service'; import { BrowsingFilesService } from './services/browsing-files.service'; @@ -59,7 +60,8 @@ export function declarations() { NodeMoveDirective, DownloadFileDirective, NodeRestoreDirective, - NodePermanentDeleteDirective + NodePermanentDeleteDirective, + NodeUnshareDirective  ]; } diff --git a/src/app/common/directives/node-unshare.directive.ts b/src/app/common/directives/node-unshare.directive.ts new file mode 100644 index 000000000..ca1a454ed --- /dev/null +++ b/src/app/common/directives/node-unshare.directive.ts @@ -0,0 +1,62 @@ +/*! + * @license + * Alfresco Example Content Application + * + * Copyright (C) 2005 - 2017 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 . + */ + +import { Directive, HostListener, Input, ElementRef } from '@angular/core'; +import { AlfrescoApiService } from '@alfresco/adf-core'; +import { MinimalNodeEntity } from 'alfresco-js-api'; + +@Directive({ + selector: '[appUnshareNode]' +}) +export class NodeUnshareDirective { + + // tslint:disable-next-line:no-input-rename + @Input('appUnshareNode') + selection: MinimalNodeEntity[]; + + constructor( + private apiService: AlfrescoApiService, + private el: ElementRef) { + } + + @HostListener('click') + onClick() { + if (this.selection.length > 0) { + this.unshareLinks(this.selection); + } + } + + private async unshareLinks(links: MinimalNodeEntity[]) { + const promises = links.map(link => this.apiService.sharedLinksApi.deleteSharedLink(link.entry.id)); + await Promise.all(promises); + this.emitDone(); + } + + private emitDone() { + const e = new CustomEvent('links-unshared', { bubbles: true }); + this.el.nativeElement.dispatchEvent(e); + } + +} diff --git a/src/app/components/shared-files/shared-files.component.html b/src/app/components/shared-files/shared-files.component.html index 2cfc02f49..94c39c37a 100644 --- a/src/app/components/shared-files/shared-files.component.html +++ b/src/app/components/shared-files/shared-files.component.html @@ -56,6 +56,15 @@ {{ 'APP.ACTIONS.MOVE' | translate }} + +