mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-3384] Create automated tests for Version Component (#3631)
* fix version component restore and delete event * version manager actions * fix test * fix unit test * remove fdescribe * fix tslint * fix screenshot rewrite problem * remove fdescribe * multi instance try * remove fdescribe * try uncomment some test * error page * fix user preferences pagiantion * search page test include * fix type tslint e2e * restore code * default lang momentadapter * fix test * [ADF-3384] removed console log from test * [ADF-3384] adding some fixes for tests and code * [ADF-3384] fixed some test and code
This commit is contained in:
committed by
Eugenio Romano
parent
17074478e2
commit
a12662e7e2
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { AlfrescoApiService, ContentService } from '@alfresco/adf-core';
|
||||
import { Component, Input, OnChanges, ViewEncapsulation, ElementRef } from '@angular/core';
|
||||
import { Component, Input, OnChanges, ViewEncapsulation, EventEmitter, Output } from '@angular/core';
|
||||
import { VersionsApi, MinimalNodeEntryEntity, VersionEntry } from 'alfresco-js-api';
|
||||
import { MatDialog } from '@angular/material';
|
||||
import { ConfirmDialogComponent } from '../dialogs/confirm.dialog';
|
||||
@@ -56,10 +56,17 @@ export class VersionListComponent implements OnChanges {
|
||||
@Input()
|
||||
showActions = true;
|
||||
|
||||
/** Emitted when a version is restored */
|
||||
@Output()
|
||||
restored: EventEmitter<MinimalNodeEntryEntity> = new EventEmitter<MinimalNodeEntryEntity>();
|
||||
|
||||
/** Emitted when a version is deleted */
|
||||
@Output()
|
||||
deleted: EventEmitter<MinimalNodeEntryEntity> = new EventEmitter<MinimalNodeEntryEntity>();
|
||||
|
||||
constructor(private alfrescoApi: AlfrescoApiService,
|
||||
private contentService: ContentService,
|
||||
private dialog: MatDialog,
|
||||
private el: ElementRef) {
|
||||
private dialog: MatDialog) {
|
||||
this.versionsApi = this.alfrescoApi.versionsApi;
|
||||
}
|
||||
|
||||
@@ -68,18 +75,18 @@ export class VersionListComponent implements OnChanges {
|
||||
}
|
||||
|
||||
canUpdate(): boolean {
|
||||
return this.contentService.hasPermission(this.node, 'update');
|
||||
return this.contentService.hasPermission(this.node, 'update') && this.versions.length > 1;
|
||||
}
|
||||
|
||||
canDelete(): boolean {
|
||||
return this.contentService.hasPermission(this.node, 'delete');
|
||||
return this.contentService.hasPermission(this.node, 'delete') && this.versions.length > 1;
|
||||
}
|
||||
|
||||
restore(versionId) {
|
||||
if (this.canUpdate()) {
|
||||
this.versionsApi
|
||||
.revertVersion(this.node.id, versionId, { majorVersion: true, comment: '' })
|
||||
.then(() => this.onVersionRestored());
|
||||
.then(() => this.onVersionRestored(this.node));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,24 +121,20 @@ export class VersionListComponent implements OnChanges {
|
||||
if (result === true) {
|
||||
this.alfrescoApi.versionsApi
|
||||
.deleteVersion(this.node.id, versionId)
|
||||
.then(() => this.onVersionDeleted());
|
||||
.then(() => this.onVersionDeleted(this.node));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
onVersionDeleted() {
|
||||
onVersionDeleted(node: any) {
|
||||
this.loadVersionHistory();
|
||||
|
||||
const event = new CustomEvent('version-deleted', { bubbles: true });
|
||||
this.el.nativeElement.dispatchEvent(event);
|
||||
this.deleted.emit(node);
|
||||
}
|
||||
|
||||
onVersionRestored() {
|
||||
onVersionRestored(node: any) {
|
||||
this.loadVersionHistory();
|
||||
|
||||
const event = new CustomEvent('version-restored', { bubbles: true });
|
||||
this.el.nativeElement.dispatchEvent(event);
|
||||
this.restored.emit(node);
|
||||
}
|
||||
|
||||
private getVersionContentUrl(nodeId: string, versionId: string, attachment?: boolean) {
|
||||
|
Reference in New Issue
Block a user