mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
[ACA-3669] Incorrect Version Number Displayed (#2281)
* [ACA-3669] Incorrect Version Number Displayed * * fixed lint * * test fixed
This commit is contained in:
parent
8afedd6e1f
commit
65826c27f6
@ -50,7 +50,8 @@ import {
|
|||||||
ContentApi,
|
ContentApi,
|
||||||
SitesApi,
|
SitesApi,
|
||||||
SearchApi,
|
SearchApi,
|
||||||
PeopleApi
|
PeopleApi,
|
||||||
|
VersionsApi
|
||||||
} from '@alfresco/js-api';
|
} from '@alfresco/js-api';
|
||||||
import { map } from 'rxjs/operators';
|
import { map } from 'rxjs/operators';
|
||||||
|
|
||||||
@ -112,6 +113,11 @@ export class ContentApiService {
|
|||||||
return this._peopleApi;
|
return this._peopleApi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_versionsApi: VersionsApi;
|
||||||
|
get versionsApi(): VersionsApi {
|
||||||
|
this._versionsApi = this._versionsApi ?? new VersionsApi(this.api.getInstance());
|
||||||
|
return this._versionsApi;
|
||||||
|
}
|
||||||
constructor(private api: AlfrescoApiService, private preferences: UserPreferencesService) {}
|
constructor(private api: AlfrescoApiService, private preferences: UserPreferencesService) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -341,4 +347,8 @@ export class ContentApiService {
|
|||||||
unlockNode(nodeId: string, opts?: any) {
|
unlockNode(nodeId: string, opts?: any) {
|
||||||
return this.nodesApi.unlockNode(nodeId, opts);
|
return this.nodesApi.unlockNode(nodeId, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getNodeVersions(nodeId: string, opts?: any) {
|
||||||
|
return from(this.versionsApi.listVersionHistory(nodeId, opts));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
<header mat-dialog-title *ngIf="isTypeList">{{ 'VERSION.DIALOG_ADF.TITLE' | translate }}</header>
|
<header mat-dialog-title>{{ data.title | translate }}</header>
|
||||||
<header mat-dialog-title *ngIf="!isTypeList">{{ 'VERSION.DIALOG.TITLE' | translate }}</header>
|
<section mat-dialog-content *ngIf="!data.showVersionsOnly">
|
||||||
<section mat-dialog-content *ngIf="!isTypeList">
|
<adf-version-comparison id="adf-version-comparison" [newFileVersion]="data.file" [node]="data.node"></adf-version-comparison>
|
||||||
<adf-version-comparison id="adf-version-comparison" [newFileVersion]="file" [node]="node"></adf-version-comparison>
|
|
||||||
<adf-version-upload
|
<adf-version-upload
|
||||||
id="adf-version-upload-button"
|
id="adf-version-upload-button"
|
||||||
[node]="node"
|
[node]="data.node"
|
||||||
[newFileVersion]="file"
|
[newFileVersion]="data.file"
|
||||||
|
[currentVersion]="data.currentVersion"
|
||||||
(success)="handleUpload($event)"
|
(success)="handleUpload($event)"
|
||||||
(cancel)="handleCancel()"
|
(cancel)="handleCancel()"
|
||||||
(error)="onUploadError($event)"
|
(error)="onUploadError($event)"
|
||||||
>
|
>
|
||||||
</adf-version-upload>
|
</adf-version-upload>
|
||||||
</section>
|
</section>
|
||||||
<ng-container *ngIf="isTypeList">
|
<ng-container *ngIf="data.showVersionsOnly">
|
||||||
<section mat-dialog-content>
|
<section mat-dialog-content>
|
||||||
<div class="adf-version-list-container">
|
<div class="adf-version-list-container">
|
||||||
<div class="adf-version-list-table">
|
<div class="adf-version-list-table">
|
||||||
<adf-version-list
|
<adf-version-list
|
||||||
[node]="node"
|
[node]="data.node"
|
||||||
[showComments]="'adf-version-manager.allowComments' | adfAppConfig: true"
|
[showComments]="'adf-version-manager.allowComments' | adfAppConfig: true"
|
||||||
[allowDownload]="'adf-version-manager.allowDownload' | adfAppConfig: true"
|
[allowDownload]="'adf-version-manager.allowDownload' | adfAppConfig: true"
|
||||||
(deleted)="refresh($event)"
|
(deleted)="refresh($event)"
|
||||||
|
@ -44,6 +44,31 @@ describe('NodeVersionsDialogComponent', () => {
|
|||||||
let fixture: ComponentFixture<NodeVersionsDialogComponent>;
|
let fixture: ComponentFixture<NodeVersionsDialogComponent>;
|
||||||
let component: NodeVersionsDialogComponent;
|
let component: NodeVersionsDialogComponent;
|
||||||
let store: Store<AppStore>;
|
let store: Store<AppStore>;
|
||||||
|
const node = {
|
||||||
|
id: '1234',
|
||||||
|
name: 'TEST-NODE',
|
||||||
|
isFile: true,
|
||||||
|
nodeType: 'FAKE',
|
||||||
|
isFolder: false,
|
||||||
|
modifiedAt: new Date(),
|
||||||
|
modifiedByUser: null,
|
||||||
|
createdAt: new Date(),
|
||||||
|
createdByUser: null,
|
||||||
|
content: {
|
||||||
|
mimeType: 'text/html',
|
||||||
|
mimeTypeName: 'HTML',
|
||||||
|
sizeInBytes: 13
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const showVersionsOnly = true;
|
||||||
|
const file = {
|
||||||
|
name: 'Fake New file',
|
||||||
|
type: 'application/pdf',
|
||||||
|
lastModified: 13,
|
||||||
|
size: 1351,
|
||||||
|
slice: null
|
||||||
|
} as File;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [CoreModule.forRoot(), TranslateModule.forRoot(), MatDialogModule, RouterTestingModule.withRoutes([]), AppTestingModule],
|
imports: [CoreModule.forRoot(), TranslateModule.forRoot(), MatDialogModule, RouterTestingModule.withRoutes([]), AppTestingModule],
|
||||||
@ -68,55 +93,31 @@ describe('NodeVersionsDialogComponent', () => {
|
|||||||
dispatch: jasmine.createSpy('dispatch')
|
dispatch: jasmine.createSpy('dispatch')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{ provide: MAT_DIALOG_DATA, useValue: {} }
|
{ provide: MAT_DIALOG_DATA, useValue: { node, showVersionsOnly, file } }
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
store = TestBed.inject(Store);
|
store = TestBed.inject(Store);
|
||||||
fixture = TestBed.createComponent(NodeVersionsDialogComponent);
|
fixture = TestBed.createComponent(NodeVersionsDialogComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
component.node = {
|
|
||||||
id: '1234',
|
|
||||||
name: 'TEST-NODE',
|
|
||||||
isFile: true,
|
|
||||||
nodeType: 'FAKE',
|
|
||||||
isFolder: false,
|
|
||||||
modifiedAt: new Date(),
|
|
||||||
modifiedByUser: null,
|
|
||||||
createdAt: new Date(),
|
|
||||||
createdByUser: null,
|
|
||||||
content: {
|
|
||||||
mimeType: 'text/html',
|
|
||||||
mimeTypeName: 'HTML',
|
|
||||||
sizeInBytes: 13
|
|
||||||
}
|
|
||||||
};
|
|
||||||
component.isTypeList = true;
|
|
||||||
component.file = {
|
|
||||||
name: 'Fake New file',
|
|
||||||
type: 'application/pdf',
|
|
||||||
lastModified: 13,
|
|
||||||
size: 1351,
|
|
||||||
slice: null
|
|
||||||
} as File;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display adf upload version if isTypeList is passed as false from parent component', () => {
|
it('should display adf upload version if isTypeList is passed as false from parent component', () => {
|
||||||
component.isTypeList = false;
|
component.data.showVersionsOnly = false;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const adfVersionComponent = document.querySelector('#adf-version-upload-button');
|
const adfVersionComponent = document.querySelector('#adf-version-upload-button');
|
||||||
expect(adfVersionComponent).not.toEqual(null);
|
expect(adfVersionComponent).not.toEqual(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display adf version comparison if isTypeList is passed as false from parent component', () => {
|
it('should display adf version comparison if isTypeList is passed as false from parent component', () => {
|
||||||
component.isTypeList = false;
|
component.data.showVersionsOnly = false;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
const adfVersionComparisonComponent = document.querySelector('#adf-version-comparison');
|
const adfVersionComparisonComponent = document.querySelector('#adf-version-comparison');
|
||||||
expect(adfVersionComparisonComponent).not.toEqual(null);
|
expect(adfVersionComparisonComponent).not.toEqual(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should unlock node if is locked when uploading a file', () => {
|
it('should unlock node if is locked when uploading a file', () => {
|
||||||
component.isTypeList = false;
|
component.data.showVersionsOnly = false;
|
||||||
const nodeEvent: NodeEntityEvent = new NodeEntityEvent({
|
const nodeEvent: NodeEntityEvent = new NodeEntityEvent({
|
||||||
entry: {
|
entry: {
|
||||||
id: 'a8b2caff-a58c-40f1-8c47-0b8e63ceaa0e',
|
id: 'a8b2caff-a58c-40f1-8c47-0b8e63ceaa0e',
|
||||||
@ -138,12 +139,12 @@ describe('NodeVersionsDialogComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should view a previous version of a node', () => {
|
it('should view a previous version of a node', () => {
|
||||||
component.isTypeList = false;
|
component.data.showVersionsOnly = false;
|
||||||
const versionId = '1.0';
|
const versionId = '1.0';
|
||||||
const location: ViewNodeExtras = {
|
const location: ViewNodeExtras = {
|
||||||
location: '/'
|
location: '/'
|
||||||
};
|
};
|
||||||
component.onViewingVersion(versionId);
|
component.onViewingVersion(versionId);
|
||||||
expect(store.dispatch).toHaveBeenCalledWith(new ViewNodeVersionAction(component.node.id, versionId, location));
|
expect(store.dispatch).toHaveBeenCalledWith(new ViewNodeVersionAction(component.data.node.id, versionId, location));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -24,13 +24,21 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { AppStore, SnackbarErrorAction, UnlockWriteAction, ViewNodeVersionAction } from '@alfresco/aca-shared/store';
|
import { AppStore, SnackbarErrorAction, UnlockWriteAction, ViewNodeVersionAction } from '@alfresco/aca-shared/store';
|
||||||
import { MinimalNodeEntryEntity, Node } from '@alfresco/js-api';
|
import { MinimalNodeEntryEntity, Node, Version } from '@alfresco/js-api';
|
||||||
import { Component, EventEmitter, Inject, Output, ViewEncapsulation } from '@angular/core';
|
import { Component, EventEmitter, Inject, Output, ViewEncapsulation } from '@angular/core';
|
||||||
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { NodeEntityEvent } from '@alfresco/adf-content-services';
|
import { NodeEntityEvent } from '@alfresco/adf-content-services';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
|
export interface NodeVersionDialogData {
|
||||||
|
title: string;
|
||||||
|
node: MinimalNodeEntryEntity;
|
||||||
|
file?: File;
|
||||||
|
currentVersion?: Version;
|
||||||
|
showVersionsOnly?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
templateUrl: './node-versions.dialog.html',
|
templateUrl: './node-versions.dialog.html',
|
||||||
styleUrls: ['./node-versions.dialog.scss'],
|
styleUrls: ['./node-versions.dialog.scss'],
|
||||||
@ -38,24 +46,16 @@ import { Router } from '@angular/router';
|
|||||||
host: { class: 'aca-node-versions-dialog' }
|
host: { class: 'aca-node-versions-dialog' }
|
||||||
})
|
})
|
||||||
export class NodeVersionsDialogComponent {
|
export class NodeVersionsDialogComponent {
|
||||||
node: MinimalNodeEntryEntity;
|
|
||||||
file: File;
|
|
||||||
isTypeList = true;
|
|
||||||
|
|
||||||
/** Emitted when a version is restored or deleted. */
|
/** Emitted when a version is restored or deleted. */
|
||||||
@Output()
|
@Output()
|
||||||
refreshEvent = new EventEmitter<Node>();
|
refreshEvent = new EventEmitter<Node>();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(MAT_DIALOG_DATA) data: any,
|
@Inject(MAT_DIALOG_DATA) public data: NodeVersionDialogData,
|
||||||
private store: Store<AppStore>,
|
private store: Store<AppStore>,
|
||||||
private dialogRef: MatDialogRef<NodeVersionsDialogComponent>,
|
private dialogRef: MatDialogRef<NodeVersionsDialogComponent>,
|
||||||
private router: Router
|
private router: Router
|
||||||
) {
|
) {}
|
||||||
this.node = data.node;
|
|
||||||
this.file = data.file;
|
|
||||||
this.isTypeList = data.isTypeList !== undefined ? data.isTypeList : true;
|
|
||||||
}
|
|
||||||
|
|
||||||
onUploadError(errorMessage: any) {
|
onUploadError(errorMessage: any) {
|
||||||
this.store.dispatch(new SnackbarErrorAction(errorMessage));
|
this.store.dispatch(new SnackbarErrorAction(errorMessage));
|
||||||
@ -78,7 +78,7 @@ export class NodeVersionsDialogComponent {
|
|||||||
|
|
||||||
onViewingVersion(versionId: string) {
|
onViewingVersion(versionId: string) {
|
||||||
this.store.dispatch(
|
this.store.dispatch(
|
||||||
new ViewNodeVersionAction(this.node.id, versionId, {
|
new ViewNodeVersionAction(this.data.node.id, versionId, {
|
||||||
location: this.router.url
|
location: this.router.url
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -53,7 +53,7 @@ import { NodeActionsService } from './node-actions.service';
|
|||||||
import { TranslationService, AlfrescoApiService, FileModel } from '@alfresco/adf-core';
|
import { TranslationService, AlfrescoApiService, FileModel } from '@alfresco/adf-core';
|
||||||
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
|
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
|
||||||
import { MatSnackBar, MatSnackBarRef, SimpleSnackBar } from '@angular/material/snack-bar';
|
import { MatSnackBar, MatSnackBarRef, SimpleSnackBar } from '@angular/material/snack-bar';
|
||||||
import { NodeEntry, Node } from '@alfresco/js-api';
|
import { NodeEntry, Node, VersionPaging } from '@alfresco/js-api';
|
||||||
import { NodeAspectService } from '@alfresco/adf-content-services';
|
import { NodeAspectService } from '@alfresco/adf-content-services';
|
||||||
|
|
||||||
describe('ContentManagementService', () => {
|
describe('ContentManagementService', () => {
|
||||||
@ -1462,6 +1462,11 @@ describe('ContentManagementService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('versionUpdateDialog', () => {
|
describe('versionUpdateDialog', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
const fakeVersion = { list: { entries: [{ entry: { id: '1.0' } }] } } as VersionPaging;
|
||||||
|
spyOn(contentApi, 'getNodeVersions').and.returnValue(of(fakeVersion));
|
||||||
|
});
|
||||||
|
|
||||||
it('should open dialog with NodeVersionUploadDialogComponent instance', () => {
|
it('should open dialog with NodeVersionUploadDialogComponent instance', () => {
|
||||||
spyOn(dialog, 'open');
|
spyOn(dialog, 'open');
|
||||||
const fakeNode = {
|
const fakeNode = {
|
||||||
@ -1473,23 +1478,12 @@ describe('ContentManagementService', () => {
|
|||||||
contentManagementService.versionUpdateDialog(fakeNode, fakeFile);
|
contentManagementService.versionUpdateDialog(fakeNode, fakeFile);
|
||||||
|
|
||||||
expect(dialog.open['calls'].argsFor(0)[0].name).toBe('NodeVersionsDialogComponent');
|
expect(dialog.open['calls'].argsFor(0)[0].name).toBe('NodeVersionsDialogComponent');
|
||||||
});
|
expect(dialog.open['calls'].argsFor(0)[1].data).toEqual({
|
||||||
|
node: fakeNode,
|
||||||
it('should return dialog instance reference', () => {
|
file: fakeFile,
|
||||||
const mockDialogInstance: any = {
|
currentVersion: { id: '1.0' },
|
||||||
afterClose: () => {}
|
title: 'VERSION.DIALOG.TITLE'
|
||||||
};
|
});
|
||||||
const fakeNode = {
|
|
||||||
name: 'lights.jpg',
|
|
||||||
id: 'f5e5cb54-200e-41a8-9c21-b5ee77da3992'
|
|
||||||
};
|
|
||||||
const fakeFile = new FileModel({ name: 'file1.png', size: 10 } as File, null, 'file1');
|
|
||||||
|
|
||||||
spyOn(dialog, 'open').and.returnValue(mockDialogInstance);
|
|
||||||
|
|
||||||
const dialogRef = contentManagementService.versionUpdateDialog(fakeNode, fakeFile);
|
|
||||||
|
|
||||||
expect(dialogRef).toBe(mockDialogInstance);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ import { MatSnackBar } from '@angular/material/snack-bar';
|
|||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { forkJoin, Observable, of, zip } from 'rxjs';
|
import { forkJoin, Observable, of, zip } from 'rxjs';
|
||||||
import { catchError, map, mergeMap, take, tap } from 'rxjs/operators';
|
import { catchError, map, mergeMap, take, tap } from 'rxjs/operators';
|
||||||
import { NodeVersionsDialogComponent } from '../dialogs/node-versions/node-versions.dialog';
|
import { NodeVersionsDialogComponent, NodeVersionDialogData } from '../dialogs/node-versions/node-versions.dialog';
|
||||||
import { NodeActionsService } from './node-actions.service';
|
import { NodeActionsService } from './node-actions.service';
|
||||||
|
|
||||||
interface RestoredNode {
|
interface RestoredNode {
|
||||||
@ -139,7 +139,7 @@ export class ContentManagementService {
|
|||||||
// workaround Shared
|
// workaround Shared
|
||||||
if (node.isFile || node.nodeId) {
|
if (node.isFile || node.nodeId) {
|
||||||
const dialogRef = this.dialogRef.open(NodeVersionsDialogComponent, {
|
const dialogRef = this.dialogRef.open(NodeVersionsDialogComponent, {
|
||||||
data: { node },
|
data: { node, showVersionsOnly: true, title: 'VERSION.DIALOG_ADF.TITLE' } as NodeVersionDialogData,
|
||||||
panelClass: 'adf-version-manager-dialog-panel',
|
panelClass: 'adf-version-manager-dialog-panel',
|
||||||
width: '630px'
|
width: '630px'
|
||||||
});
|
});
|
||||||
@ -176,10 +176,12 @@ export class ContentManagementService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
versionUpdateDialog(node, file) {
|
versionUpdateDialog(node, file) {
|
||||||
return this.dialogRef.open(NodeVersionsDialogComponent, {
|
this.contentApi.getNodeVersions(node.id).subscribe(({ list }) => {
|
||||||
data: { node, file, isTypeList: false },
|
this.dialogRef.open(NodeVersionsDialogComponent, {
|
||||||
panelClass: 'adf-version-manager-dialog-panel-upload',
|
data: { node, file, currentVersion: list.entries[0].entry, title: 'VERSION.DIALOG.TITLE' } as NodeVersionDialogData,
|
||||||
width: '600px'
|
panelClass: 'adf-version-manager-dialog-panel-upload',
|
||||||
|
width: '600px'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user