import { Component , OnInit , Input } from '@angular/core' ; import { Observable } from 'rxjs' ; import { Store } from '@ngrx/store' ; import { SelectionState } from '@alfresco/adf-extensions' ; import { AppStore , ShareNodeAction , getAppSelection } from '@alfresco/aca-shared/store' ; @ Component ( { selector : 'app-toggle-shared' , templateUrl : './toggle-shared.component.html' } ) export class ToggleSharedComponent implements OnInit { @ Input ( ) data : { iconButton ? : string ; } ; selection$ : Observable < SelectionState > ; constructor ( private store ) { } ngOnInit ( ) { this . selection$ = this . store . select ( getAppSelection ) ; } isShared ( selection ) { if ( selection . first && selection . first . entry && ( selection . first . entry as any ) . sharedByUser ) { return true ; } return selection . first && selection . first . entry && selection . first . entry . properties && ! ! selection . first . entry . properties [ 'qshare:sharedId' ] ; } editSharedNode ( selection ) { this . store . dispatch ( new ShareNodeAction ( selection . first ) ) ; } getLabel ( selection ) { return this . isShared ( selection ) ? 'APP.ACTIONS.SHARE_EDIT' : 'APP.ACTIONS.SHARE' ; } }