mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-6587] ACA: Viewer does not update after restoring version and the toolbar disappears (#9383)
* [ACS-6587] reload files after update * [ACS-6587] update view after version change * [ACS-6587] update view after version change * [ACS-6587] update tests * AAE-0000 e2e affected were not running on ADF pipeline' (#9409) * AAE-14727 Removed unused css rule (#9408) * [ACS-6587] update tests * [ACS-6587] rearrange tests description --------- Co-authored-by: Vito Albano <vito.albano@alfresco.com> Co-authored-by: Ehsan Rezaei <ehsan.rezaei@hyland.com>
This commit is contained in:
@@ -8,43 +8,49 @@
|
||||
<span class="adf-version-list-item-line adf-version-list-item-version" [id]="'adf-version-list-item-version-' + version.entry.id" >{{version.entry.id}}</span> -
|
||||
<span class="adf-version-list-item-line adf-version-list-item-date" [id]="'adf-version-list-item-date-' + version.entry.id" >{{version.entry.modifiedAt | date}}</span>
|
||||
</p>
|
||||
<p mat-line [id]="'adf-version-list-item-comment-'+ version.entry.id" class="adf-version-list-item-comment"
|
||||
<p mat-line [id]="'adf-version-list-item-comment-' + version.entry.id"
|
||||
class="adf-version-list-item-comment"
|
||||
*ngIf="showComments">{{version.entry.versionComment}}</p>
|
||||
|
||||
<div *ngIf="showActions">
|
||||
<mat-menu [id]="'adf-version-list-action-menu-'+version.entry.id"
|
||||
#versionMenu="matMenu" yPosition="below" xPosition="before">
|
||||
<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"
|
||||
[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"
|
||||
[id]="'adf-version-list-action-restore-' + version.entry.id"
|
||||
[disabled]="!canUpdate() || latestVersion"
|
||||
mat-menu-item
|
||||
(click)="restore(version.entry.id)">
|
||||
{{ 'ADF_VERSION_LIST.ACTIONS.RESTORE' | translate }}
|
||||
</button>
|
||||
<button *ngIf="allowDownload"
|
||||
[id]="'adf-version-list-action-download-'+version.entry.id"
|
||||
[id]="'adf-version-list-action-download-' + version.entry.id"
|
||||
mat-menu-item
|
||||
(click)="downloadVersion(version.entry.id)">
|
||||
{{ 'ADF_VERSION_LIST.ACTIONS.DOWNLOAD' | translate }}
|
||||
</button>
|
||||
<button
|
||||
[disabled]="!canDelete()"
|
||||
[id]="'adf-version-list-action-delete-'+version.entry.id"
|
||||
[id]="'adf-version-list-action-delete-' + version.entry.id"
|
||||
(click)="deleteVersion(version.entry.id)"
|
||||
mat-menu-item>
|
||||
{{ 'ADF_VERSION_LIST.ACTIONS.DELETE' | translate }}
|
||||
</button>
|
||||
</mat-menu>
|
||||
|
||||
<button mat-icon-button [matMenuTriggerFor]="versionMenu" [id]="'adf-version-list-action-menu-button-'+version.entry.id" title="{{ 'ADF_VERSION_LIST.MANAGE_VERSION_OPTIONS' | translate }}">
|
||||
<button mat-icon-button
|
||||
[matMenuTriggerFor]="versionMenu"
|
||||
[id]="'adf-version-list-action-menu-button-' + version.entry.id"
|
||||
title="{{ 'ADF_VERSION_LIST.MANAGE_VERSION_OPTIONS' | translate }}">
|
||||
<mat-icon>more_vert</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
@@ -291,7 +291,6 @@ describe('AlfrescoViewerComponent', () => {
|
||||
|
||||
component.nodeId = 'id1';
|
||||
component.showViewer = true;
|
||||
|
||||
component.versionId = '1.0';
|
||||
component.ngOnChanges();
|
||||
tick();
|
||||
@@ -305,34 +304,6 @@ describe('AlfrescoViewerComponent', () => {
|
||||
expect(component.fileName).toBe('file2');
|
||||
}));
|
||||
|
||||
it('should update node only if node name changed', fakeAsync(() => {
|
||||
spyOn(component['nodesApi'], 'getNode').and.returnValues(
|
||||
Promise.resolve(new NodeEntry({ entry: new Node({ name: 'file1', content: new ContentInfo() }) }))
|
||||
);
|
||||
|
||||
component.showViewer = true;
|
||||
|
||||
component.nodeId = 'id1';
|
||||
fixture.detectChanges();
|
||||
component.ngOnChanges();
|
||||
tick();
|
||||
|
||||
expect(component.fileName).toBe('file1');
|
||||
|
||||
nodesApiService.nodeUpdated.next({ id: 'id1', name: 'file2' } as any);
|
||||
fixture.detectChanges();
|
||||
expect(component.fileName).toBe('file2');
|
||||
|
||||
nodesApiService.nodeUpdated.next({ id: 'id1', name: 'file3' } as any);
|
||||
fixture.detectChanges();
|
||||
expect(component.fileName).toBe('file3');
|
||||
|
||||
nodesApiService.nodeUpdated.next({ id: 'id2', name: 'file4' } as any);
|
||||
fixture.detectChanges();
|
||||
expect(component.fileName).toBe('file3');
|
||||
expect(component.nodeId).toBe('id1');
|
||||
}));
|
||||
|
||||
it('should download file when downloadFile event is emitted', () => {
|
||||
spyOn(nodeActionsService, 'downloadNode');
|
||||
const viewerComponent = fixture.debugElement.query(By.directive(ViewerComponent));
|
||||
@@ -501,12 +472,13 @@ describe('AlfrescoViewerComponent', () => {
|
||||
|
||||
fixture.detectChanges();
|
||||
nodesApiService.nodeUpdated.next({
|
||||
...defaultNode,
|
||||
id: '123',
|
||||
name: 'file2',
|
||||
content: {
|
||||
mimeType: 'application/msWord'
|
||||
}
|
||||
} as any);
|
||||
content: { mimeType: 'application/msWord' },
|
||||
properties: { 'cm:versionLabel': 'mock-version-label2' }
|
||||
} as Node);
|
||||
|
||||
await fixture.whenStable();
|
||||
expect(component.originalMimeType).toEqual('application/msWord');
|
||||
});
|
||||
|
@@ -258,7 +258,7 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
(node) =>
|
||||
node &&
|
||||
node.id === this.nodeId &&
|
||||
(node.name !== this.fileName || this.getNodeVersionProperty(this.nodeEntry.entry) !== this.getNodeVersionProperty(node))
|
||||
this.getNodeVersionProperty(this.nodeEntry.entry) !== this.getNodeVersionProperty(node)
|
||||
),
|
||||
takeUntil(this.onDestroy$)
|
||||
)
|
||||
@@ -323,9 +323,7 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
: encodeURI('1.0');
|
||||
|
||||
urlFileContent = versionData ? this.contentApi.getVersionContentUrl(this.nodeId, versionData.id) : this.contentApi.getContentUrl(this.nodeId);
|
||||
urlFileContent = this.cacheBusterNumber
|
||||
? urlFileContent + '&' + currentFileVersion + '&' + this.cacheBusterNumber
|
||||
: urlFileContent + '&' + currentFileVersion;
|
||||
urlFileContent = urlFileContent + '&' + currentFileVersion;
|
||||
|
||||
const fileExtension = this.viewUtilService.getFileExtension(versionData ? versionData.name : nodeData.name);
|
||||
this.fileName = versionData ? versionData.name : nodeData.name;
|
||||
@@ -348,7 +346,7 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
this.mimeType = mimeType;
|
||||
this.urlFileContent = urlFileContent;
|
||||
this.urlFileContent = urlFileContent + (this.cacheBusterNumber ? '&' + this.cacheBusterNumber : '');
|
||||
this.sidebarRightTemplateContext.node = nodeData;
|
||||
this.sidebarLeftTemplateContext.node = nodeData;
|
||||
}
|
||||
|
Reference in New Issue
Block a user