mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
[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:
parent
ad52115f41
commit
1ef1976a4c
@ -198,7 +198,7 @@ The button will be visible only when the linked rule evaluates to `true`.
|
||||
## Application Evaluators
|
||||
|
||||
| Ver. | Key | Description |
|
||||
| ----- | ----------------------------------- | ------------------------------------------------------------------------ |
|
||||
|--------|-------------------------------------|---------------------------------------------------------------------------------------------------|
|
||||
| 1.7.0 | app.selection.canDelete | User has permission to delete selected node(s). |
|
||||
| 1.7.0 | app.selection.canDownload | User can download selected node(s). |
|
||||
| 1.7.0 | app.selection.notEmpty | At least one node is selected. |
|
||||
@ -236,6 +236,7 @@ The button will be visible only when the linked rule evaluates to `true`.
|
||||
| 1.8.0 | user.isAdmin | Checks if user is admin. |
|
||||
| 1.9.0 | app.canShowLogout | Whether logout action should be present or not. |
|
||||
| 1.12.0 | app.isLibraryManager | Checks if user is library manager. |
|
||||
| 6.1.0 | canPrintFile | Checks if current file can be printed or not (media files such as audio/video cannot be printed). |
|
||||
|
||||
## Navigation Evaluators
|
||||
|
||||
|
@ -1070,7 +1070,8 @@
|
||||
"click": "PRINT_FILE"
|
||||
},
|
||||
"rules": {
|
||||
"visible": "canViewFile"
|
||||
"visible": "canViewFile",
|
||||
"enabled": "canPrintFile"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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`
|
||||
|
Loading…
x
Reference in New Issue
Block a user