[ACS-9388] Print button is now disabled in viewer for media files (#4465)

* [ACS-9388] Print button is now disabled in viewer for media files

* [ACS-9388] Added canPrintFile rule to documentation. Code review fixes
This commit is contained in:
swapnil-verma-gl
2025-03-20 14:16:30 +05:30
committed by GitHub
parent ad52115f41
commit 1ef1976a4c
5 changed files with 67 additions and 40 deletions

View File

@@ -1070,7 +1070,8 @@
"click": "PRINT_FILE"
},
"rules": {
"visible": "canViewFile"
"visible": "canViewFile",
"enabled": "canPrintFile"
}
},
{

View File

@@ -168,6 +168,7 @@ export class ContentServiceExtensionModule {
canEditFolder: rules.canEditFolder,
isTrashcanItemSelected: rules.isTrashcanItemSelected,
canViewFile: rules.canViewFile,
canPrintFile: rules.canPrintFile,
canLeaveLibrary: rules.canLeaveLibrary,
canToggleSharedLink: rules.canToggleSharedLink,
canShowInfoDrawer: rules.canShowInfoDrawer,

View File

@@ -1360,6 +1360,18 @@ describe('app.evaluators', () => {
});
});
describe('canPrintFile', () => {
it('should return false for media files', () => {
context.selection.file = { entry: { content: { mimeType: 'video/ogg' } } } as NodeEntry;
expect(app.canPrintFile(context)).toBeFalse();
});
it('should return true for non-media files', () => {
context.selection.file = { entry: { content: { mimeType: 'application/pdf' } } } as NodeEntry;
expect(app.canPrintFile(context)).toBeTrue();
});
});
describe('canLeaveLibrary', () => {
it('should return false when no library is selected', () => {
context.selection.library = null;

View File

@@ -437,6 +437,18 @@ export const isTrashcanItemSelected = (context: RuleContext): boolean => [naviga
*/
export const canViewFile = (context: RuleContext): boolean => [hasFileSelected(context), navigation.isNotTrashcan(context)].every(Boolean);
/**
* Checks if user can print the file.
* JSON ref: `canPrintFile`
*
* @param context Rule execution context
*/
export const canPrintFile = (context: RuleContext): boolean => {
const nodeEntry = context.selection.file.entry;
const mediaMimeTypes = ['video/mp4', 'video/webm', 'video/ogg', 'audio/mpeg', 'audio/mp3', 'audio/ogg', 'audio/wav'];
return !mediaMimeTypes.includes(nodeEntry.content.mimeType);
};
/**
* Checks if user can **Leave** selected library.
* JSON ref: `canLeaveLibrary`