added functionality to view a previous version (#5913)

This commit is contained in:
Urse Daniel
2020-07-27 11:29:29 +03:00
committed by GitHub
parent 8d43155c14
commit 7c09fb1fb9
26 changed files with 337 additions and 111 deletions

View File

@@ -4,6 +4,7 @@
"RESTORE": "Restore",
"DELETE": "Delete",
"DOWNLOAD": "Download",
"VIEW": "View",
"UPLOAD": {
"TITLE": "Upload new version",
"TOOLTIP": "Restriction: you must upload a file with the same name to create a new version of it",

View File

@@ -12,6 +12,14 @@
<div *ngIf="showActions">
<mat-menu [id]="'adf-version-list-action-menu-'+version.entry.id"
#versionMenu="matMenu" yPosition="below" xPosition="before">
<ng-container *adf-acs-version="'7'">
<button *ngIf="allowViewVersions"
[id]="'adf-version-list-action-view-'+version.entry.id"
mat-menu-item
(click)="onViewVersion(version.entry.id)">
{{ 'ADF_VERSION_LIST.ACTIONS.VIEW' | translate }}
</button>
</ng-container>
<button
[id]="'adf-version-list-action-restore-'+version.entry.id"
[disabled]="!canUpdate()"

View File

@@ -228,6 +228,13 @@ describe('VersionListComponent', () => {
expect(alfrescoApiService.contentApi.getContentUrl).toHaveBeenCalledWith(nodeId, true);
});
it('should be able to view a version', () => {
spyOn(component.viewVersion, 'emit');
component.onViewVersion('1.0');
fixture.detectChanges();
expect(component.viewVersion.emit).toHaveBeenCalledWith('1.0');
});
it('should NOT be able to download a version if configured so', () => {
const versionEntry = {
entry: {

View File

@@ -48,6 +48,10 @@ export class VersionListComponent implements OnChanges {
@Input()
allowDownload = true;
/** Enable/disable viewing a version of the current node. */
@Input()
allowViewVersions = true;
/** Toggles showing/hiding of version actions */
@Input()
showActions = true;
@@ -60,6 +64,10 @@ export class VersionListComponent implements OnChanges {
@Output()
deleted: EventEmitter<Node> = new EventEmitter<Node>();
/** Emitted when viewing a version */
@Output()
viewVersion: EventEmitter<string> = new EventEmitter<string>();
constructor(private alfrescoApi: AlfrescoApiService,
private contentService: ContentService,
private dialog: MatDialog) {
@@ -92,6 +100,10 @@ export class VersionListComponent implements OnChanges {
}
}
onViewVersion(versionId) {
this.viewVersion.emit(versionId);
}
loadVersionHistory() {
this.isLoading = true;
this.versionsApi.listVersionHistory(this.node.id).then((versionPaging: VersionPaging) => {

View File

@@ -38,7 +38,8 @@
[allowDownload]="allowDownload"
[showComments]="showComments"
(deleted)="refresh($event)"
(restored)="refresh($event)">
(restored)="refresh($event)"
(viewVersion)="onViewVersion($event)">
</adf-version-list>
</div>
</div>

View File

@@ -73,6 +73,13 @@ describe('VersionManagerComponent', () => {
expect(component.uploadState).toBe('open');
});
it('should be able to view a version', () => {
spyOn(component.viewVersion, 'emit');
component.onViewVersion('1.0');
fixture.detectChanges();
expect(component.viewVersion.emit).toHaveBeenCalledWith('1.0');
});
it('should display comments for versions when not configured otherwise', async(() => {
fixture.detectChanges();
fixture.whenStable().then(() => {

View File

@@ -75,6 +75,10 @@ export class VersionManagerComponent implements OnInit {
@Output()
uploadCancel: EventEmitter<boolean> = new EventEmitter<boolean>();
/** Emitted when viewing a version. */
@Output()
viewVersion: EventEmitter<string> = new EventEmitter<string>();
@ViewChild('versionList', { static: true })
versionListComponent: VersionListComponent;
@@ -117,6 +121,10 @@ export class VersionManagerComponent implements OnInit {
this.uploadCancel.emit(true);
}
onViewVersion(versionId: string) {
this.viewVersion.emit(versionId);
}
toggleNewVersion() {
this.uploadState = this.uploadState === 'open' ? 'close' : 'open';
}