mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACS-8863] Add nodeMimeType to keep proper file icon when renditions are generated (#10508)
* [ACS-8863] Add nodeMimeType to keep proper file icon when renditions are generated * [ACS-8863] Small fix
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
[hideInfoButton]="hideInfoButton"
|
||||
[fileName]="fileName"
|
||||
[mimeType]="mimeType"
|
||||
[nodeMimeType]="nodeMimeType"
|
||||
[urlFile]="urlFileContent"
|
||||
[tracks]="tracks"
|
||||
[readOnly]="readOnly"
|
||||
|
@@ -466,7 +466,7 @@ describe('AlfrescoViewerComponent', () => {
|
||||
});
|
||||
|
||||
describe('mimeType', () => {
|
||||
it('should set mime type based on renditionMimeType rather then nodeData', async () => {
|
||||
it('should set mime type based on renditionMimeType rather then nodeData and keep proper nodeMimeType', async () => {
|
||||
const defaultNode: Node = {
|
||||
id: 'mock-id',
|
||||
name: 'Mock Node',
|
||||
@@ -499,6 +499,7 @@ describe('AlfrescoViewerComponent', () => {
|
||||
|
||||
await fixture.whenStable();
|
||||
expect(component.mimeType).toEqual('application/pdf');
|
||||
expect(component.nodeMimeType).toEqual('application/msWord');
|
||||
});
|
||||
});
|
||||
|
||||
|
@@ -211,6 +211,7 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit {
|
||||
urlFileContent: string;
|
||||
fileName: string;
|
||||
mimeType: string;
|
||||
nodeMimeType: string;
|
||||
nodeEntry: NodeEntry;
|
||||
tracks: Track[] = [];
|
||||
readOnly: boolean = true;
|
||||
@@ -317,6 +318,7 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit {
|
||||
private async setUpNodeFile(nodeData: Node, versionData?: Version): Promise<void> {
|
||||
this.readOnly = !this.contentService.hasAllowableOperations(nodeData, 'update');
|
||||
let mimeType: string;
|
||||
let nodeMimeType: string;
|
||||
let urlFileContent: string;
|
||||
|
||||
if (versionData?.content) {
|
||||
@@ -324,6 +326,7 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit {
|
||||
} else if (nodeData.content) {
|
||||
mimeType = nodeData.content.mimeType;
|
||||
}
|
||||
nodeMimeType = mimeType;
|
||||
|
||||
const currentFileVersion = this.nodeEntry?.entry?.properties?.['cm:versionLabel']
|
||||
? encodeURI(this.nodeEntry?.entry?.properties['cm:versionLabel'])
|
||||
@@ -333,7 +336,6 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit {
|
||||
urlFileContent = urlFileContent + '&' + currentFileVersion;
|
||||
|
||||
const fileExtension = this.viewUtilService.getFileExtension(versionData ? versionData.name : nodeData.name);
|
||||
this.fileName = versionData ? versionData.name : nodeData.name;
|
||||
const viewerType = this.viewUtilService.getViewerType(fileExtension, mimeType);
|
||||
|
||||
if (viewerType === 'unknown') {
|
||||
@@ -346,7 +348,7 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit {
|
||||
if (nodeRendition) {
|
||||
urlFileContent = nodeRendition.url;
|
||||
|
||||
const nodeMimeType = nodeData?.content?.mimeType;
|
||||
nodeMimeType = nodeData?.content?.mimeType;
|
||||
const renditionMimeType = nodeRendition.mimeType;
|
||||
mimeType = renditionMimeType || nodeMimeType;
|
||||
}
|
||||
@@ -355,6 +357,8 @@ export class AlfrescoViewerComponent implements OnChanges, OnInit {
|
||||
}
|
||||
|
||||
this.mimeType = mimeType;
|
||||
this.nodeMimeType = nodeMimeType;
|
||||
this.fileName = versionData ? versionData.name : nodeData.name;
|
||||
this.urlFileContent = urlFileContent + (this.cacheBusterNumber ? '&' + this.cacheBusterNumber : '');
|
||||
this.sidebarRightTemplateContext.node = nodeData;
|
||||
this.sidebarLeftTemplateContext.node = nodeData;
|
||||
|
Reference in New Issue
Block a user