[MNT-22418] - disabling action for physical records (#7057)

This commit is contained in:
Vito
2021-05-25 09:15:57 +01:00
committed by GitHub
parent 4c1e462364
commit 65cbd570fb
5 changed files with 44 additions and 8 deletions

View File

@@ -26,21 +26,21 @@
[src]="file.content ? getIcon(file.content.mimeType) : getIcon(file.mimeType)" [alt]="mimeTypeIcon" [src]="file.content ? getIcon(file.content.mimeType) : getIcon(file.mimeType)" [alt]="mimeTypeIcon"
role="button" tabindex="0" /> role="button" tabindex="0" />
<span matLine id="{{'file-'+file?.id}}" role="button" tabindex="0" class="adf-file" (click)="onRowClicked(file)">{{file.name}}</span> <span matLine id="{{'file-'+file?.id}}" role="button" tabindex="0" class="adf-file" (click)="onRowClicked(file)">{{file.name}}</span>
<button id="{{'file-'+file?.id+'-option-menu'}}" mat-icon-button [matMenuTriggerFor]="fileActionMenu"> <button id="{{'file-'+file?.id+'-option-menu'}}" mat-icon-button [matMenuTriggerFor]="fileActionMenu" *ngIf="!!file.content?.mimeType">
<mat-icon>more_vert</mat-icon> <mat-icon>more_vert</mat-icon>
</button> </button>
<mat-menu #fileActionMenu="matMenu" xPosition="before"> <mat-menu #fileActionMenu="matMenu" xPosition="before">
<button *ngIf="displayMenuOption('show')" id="{{'file-'+file?.id+'-show-file'}}" <button *ngIf="displayMenuOption('show') && !!file.content?.mimeType" id="{{'file-'+file?.id+'-show-file'}}"
mat-menu-item (click)="onAttachFileClicked(file)"> mat-menu-item (click)="onAttachFileClicked(file)">
<mat-icon>visibility</mat-icon> <mat-icon>visibility</mat-icon>
<span>{{ 'FORM.FIELD.VIEW_FILE' | translate }}</span> <span>{{ 'FORM.FIELD.VIEW_FILE' | translate }}</span>
</button> </button>
<button *ngIf="displayMenuOption('download')" id="{{'file-'+file?.id+'-download-file'}}" <button *ngIf="displayMenuOption('download') && !!file.content?.mimeType" id="{{'file-'+file?.id+'-download-file'}}"
mat-menu-item (click)="downloadContent(file)"> mat-menu-item (click)="downloadContent(file)">
<mat-icon>file_download</mat-icon> <mat-icon>file_download</mat-icon>
<span>{{ 'FORM.FIELD.DOWNLOAD_FILE' | translate }}</span> <span>{{ 'FORM.FIELD.DOWNLOAD_FILE' | translate }}</span>
</button> </button>
<button *ngIf="displayMenuOption('retrieveMetadata')" id="{{'file-'+file?.id+'-retrieve-file-metadata'}}" <button *ngIf="displayMenuOption('retrieveMetadata') && !!file.content?.mimeType" id="{{'file-'+file?.id+'-retrieve-file-metadata'}}"
mat-menu-item (click)="contentModelFormFileHandler(file)"> mat-menu-item (click)="contentModelFormFileHandler(file)">
<mat-icon class="mat-24">low_priority</mat-icon> <mat-icon class="mat-24">low_priority</mat-icon>
<span>{{ 'ADF_CLOUD_FORM_COMPONENT.RETRIEVE_METADATA' | translate }}</span> <span>{{ 'ADF_CLOUD_FORM_COMPONENT.RETRIEVE_METADATA' | translate }}</span>

View File

@@ -59,7 +59,8 @@ import {
processVariables, processVariables,
mockAllFileSourceWithRenamedFolderVariablePathType, mockAllFileSourceWithRenamedFolderVariablePathType,
allSourceParamsWithWrongRelativePath, allSourceParamsWithWrongRelativePath,
allSourceParamsWithRelativePath allSourceParamsWithRelativePath,
fakeLocalPhysicalRecordResponse
} from '../../../mocks/attach-file-cloud-widget.mock'; } from '../../../mocks/attach-file-cloud-widget.mock';
import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module'; import { ProcessServiceCloudTestingModule } from '../../../../testing/process-service-cloud.testing.module';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
@@ -510,6 +511,14 @@ describe('AttachFileCloudWidgetComponent', () => {
expect(fixture.debugElement.query(By.css('#file-1155-remove'))).toBeNull(); expect(fixture.debugElement.query(By.css('#file-1155-remove'))).toBeNull();
})); }));
it('should not show any action when the attached file is a physical record', async(() => {
createUploadWidgetField(new FormModel(), 'fill-test', [fakeLocalPhysicalRecordResponse], onlyLocalParams, null, null, true);
fixture.detectChanges();
const menuButton = fixture.debugElement.query(By.css('#file-1155-option-menu'));
expect(menuButton).toBeNull();
}));
}); });
describe('when a file is uploaded', () => { describe('when a file is uploaded', () => {

View File

@@ -33,6 +33,33 @@ export const fakeLocalPngResponse = {
contentAvailable: true, contentAvailable: true,
link: false, link: false,
mimeType: 'image/png', mimeType: 'image/png',
content: {
mimeType: 'image/png'
},
simpleType: 'image',
previewStatus: 'queued',
thumbnailStatus: 'queued',
properties: {
'pfx:property_one': 'testValue',
'pfx:property_two': true
}
};
export const fakeLocalPhysicalRecordResponse = {
id: 1155,
nodeId: 1155,
name: 'a_png_file.png',
created: '2017-07-25T17:17:37.099Z',
createdBy: {
id: 1001,
firstName: 'Admin',
lastName: 'admin',
email: 'admin'
},
relatedContent: false,
contentAvailable: true,
link: false,
mimeType: null,
simpleType: 'image', simpleType: 'image',
previewStatus: 'queued', previewStatus: 'queued',
thumbnailStatus: 'queued', thumbnailStatus: 'queued',

View File

@@ -76,13 +76,13 @@
</button> </button>
<mat-menu #fileActionMenu="matMenu" xPosition="before"> <mat-menu #fileActionMenu="matMenu" xPosition="before">
<button id="{{'file-'+file.id+'-show-file'}}" <button id="{{'file-'+file.id+'-show-file'}}"
[disabled]="file.isExternal || !file.contentAvailable" [disabled]="file.isExternal || !file.contentAvailable || !file.mimeType"
mat-menu-item (click)="onAttachFileClicked(file)"> mat-menu-item (click)="onAttachFileClicked(file)">
<mat-icon>visibility</mat-icon> <mat-icon>visibility</mat-icon>
<span>{{ 'FORM.FIELD.VIEW_FILE' | translate }}</span> <span>{{ 'FORM.FIELD.VIEW_FILE' | translate }}</span>
</button> </button>
<button id="{{'file-'+file.id+'-download-file'}}" <button id="{{'file-'+file.id+'-download-file'}}"
[disabled]="file.isExternal" [disabled]="file.isExternal || !file.mimeType"
mat-menu-item (click)="downloadContent(file)"> mat-menu-item (click)="downloadContent(file)">
<mat-icon>file_download</mat-icon> <mat-icon>file_download</mat-icon>
<span>{{ 'FORM.FIELD.DOWNLOAD_FILE' | translate }}</span> <span>{{ 'FORM.FIELD.DOWNLOAD_FILE' | translate }}</span>

View File

@@ -256,7 +256,7 @@ export class AttachFileWidgetComponent extends UploadWidgetComponent implements
from(fileNodeList).pipe( from(fileNodeList).pipe(
mergeMap((node) => mergeMap((node) =>
zip( zip(
of(node.content.mimeType), of(node?.content?.mimeType),
this.activitiContentService.applyAlfrescoNode(node, siteId, accountId), this.activitiContentService.applyAlfrescoNode(node, siteId, accountId),
of(node.isExternal) of(node.isExternal)
) )