import { AppStore , SnackbarErrorAction , UnlockWriteAction , ViewNodeVersionAction } from '@alfresco/aca-shared/store' ; import { MinimalNodeEntryEntity , Node , Version } from '@alfresco/js-api' ; import { Component , EventEmitter , Inject , Output , ViewEncapsulation } from '@angular/core' ; import { MAT_DIALOG_DATA , MatDialogRef } from '@angular/material/dialog' ; import { Store } from '@ngrx/store' ; import { NodeEntityEvent } from '@alfresco/adf-content-services' ; import { Router } from '@angular/router' ; export interface NodeVersionDialogData { title : string ; node : MinimalNodeEntryEntity ; file ? : File ; currentVersion ? : Version ; showVersionsOnly ? : boolean ; } @ Component ( { templateUrl : './node-versions.dialog.html' , styleUrls : [ './node-versions.dialog.scss' ] , encapsulation : ViewEncapsulation . None , host : { class : 'aca-node-versions-dialog' } } ) export class NodeVersionsDialogComponent { /** Emitted when a version is restored or deleted. */ @ Output ( ) refreshEvent = new EventEmitter < Node > ( ) ; constructor ( @ Inject ( MAT_DIALOG_DATA ) public data , private store , private dialogRef , private router ) { } onUploadError ( errorMessage ) { this . store . dispatch ( new SnackbarErrorAction ( errorMessage ) ) ; } handleUpload ( nodeEvent ) { if ( nodeEvent . value . entry . properties [ 'cm:lockType' ] === 'WRITE_LOCK' ) { this . store . dispatch ( new UnlockWriteAction ( nodeEvent . value ) ) ; } this . dialogRef . close ( ) ; } handleCancel ( ) { this . dialogRef . close ( ) ; } refresh ( node ) { this . refreshEvent . emit ( node ) ; } onViewingVersion ( versionId ) { this . store . dispatch ( new ViewNodeVersionAction ( this . data . node . id , versionId , { location : this . router . url } ) ) ; } }