From ec2323b038b6f0f87fcfbcad151244c532b92ac0 Mon Sep 17 00:00:00 2001 From: Cilibiu Bogdan Date: Tue, 19 Jun 2018 12:10:21 +0300 Subject: [PATCH] conditional Deleted By column (#435) --- .../components/trashcan/trashcan.component.html | 1 + .../trashcan/trashcan.component.spec.ts | 3 ++- .../components/trashcan/trashcan.component.ts | 17 ++++++++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/app/components/trashcan/trashcan.component.html b/src/app/components/trashcan/trashcan.component.html index c6b1de7e3..711dc36f5 100644 --- a/src/app/components/trashcan/trashcan.component.html +++ b/src/app/components/trashcan/trashcan.component.html @@ -87,6 +87,7 @@ diff --git a/src/app/components/trashcan/trashcan.component.spec.ts b/src/app/components/trashcan/trashcan.component.spec.ts index 2dbc0f1ec..b50695abc 100644 --- a/src/app/components/trashcan/trashcan.component.spec.ts +++ b/src/app/components/trashcan/trashcan.component.spec.ts @@ -32,7 +32,7 @@ import { UserPreferencesService, LogService, AppConfigService, StorageService, CookieService, ThumbnailService, AuthenticationService, TimeAgoPipe, NodeNameTooltipPipe, - NodeFavoriteDirective, DataTableComponent, AppConfigPipe + NodeFavoriteDirective, DataTableComponent, AppConfigPipe, PeopleContentService } from '@alfresco/adf-core'; import { DocumentListComponent, CustomResourcesService } from '@alfresco/adf-content-services'; import { TranslateModule } from '@ngx-translate/core'; @@ -86,6 +86,7 @@ describe('TrashcanComponent', () => { { provide: TranslationService, useClass: TranslationMock }, AuthenticationService, UserPreferencesService, + PeopleContentService, AppConfigService, StorageService, CookieService, AlfrescoApiService, LogService, diff --git a/src/app/components/trashcan/trashcan.component.ts b/src/app/components/trashcan/trashcan.component.ts index a97d316c1..4f817b463 100644 --- a/src/app/components/trashcan/trashcan.component.ts +++ b/src/app/components/trashcan/trashcan.component.ts @@ -26,7 +26,7 @@ import { Component, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { Pagination } from 'alfresco-js-api'; -import { UserPreferencesService } from '@alfresco/adf-core'; +import { UserPreferencesService, PeopleContentService } from '@alfresco/adf-core'; import { ContentManagementService } from '../../common/services/content-management.service'; import { PageComponent } from '../page.component'; import { Store } from '@ngrx/store'; @@ -36,8 +36,10 @@ import { AppStore } from '../../store/states/app.state'; templateUrl: './trashcan.component.html' }) export class TrashcanComponent extends PageComponent implements OnInit { + userIsAdmin: boolean; constructor(private contentManagementService: ContentManagementService, + private peopleApi: PeopleContentService, preferences: UserPreferencesService, store: Store, route: ActivatedRoute) { @@ -50,11 +52,20 @@ export class TrashcanComponent extends PageComponent implements OnInit { this.subscriptions.push( this.contentManagementService.nodesRestored.subscribe(() => this.reload()), this.contentManagementService.nodesPurged.subscribe(() => this.reload()), - this.contentManagementService.nodesRestored.subscribe(() => this.reload()) + this.contentManagementService.nodesRestored.subscribe(() => this.reload()), + this.peopleApi.getCurrentPerson().subscribe((user: any) => this.isUserAdmin(user)) ); } onChangePageSize(event: Pagination): void { this.preferences.paginationSize = event.maxItems; } -} + + private isUserAdmin(user) { + if (user && user.capabilities) { + this.userIsAdmin = user.capabilities.isAdmin; + } else { + this.userIsAdmin = true; + } + } + }