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
@ -197,45 +197,46 @@ 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. |
|
||||
| 1.7.0 | app.selection.canUnshare | User is able to remove selected node(s) from public sharing. |
|
||||
| 1.7.0 | app.selection.canAddFavorite | User can add selected node(s) to favorites. |
|
||||
| 1.7.0 | app.selection.canRemoveFavorite | User can remove selected node(s) from favorites. |
|
||||
| 1.7.0 | app.selection.first.canUpdate | User has permission to update selected node(s). |
|
||||
| 1.7.0 | app.selection.file | A single File node is selected. |
|
||||
| 1.7.0 | app.selection.file.canShare | User is able to share the selected file. |
|
||||
| 1.7.0 | app.selection.file.isShared | A shared node is selected. |
|
||||
| 1.7.0 | app.selection.file.isLocked | File is locked for editing. |
|
||||
| 1.7.0 | app.selection.file.isLockOwner | File is locked and current user is the lock owner. |
|
||||
| 1.7.0 | app.selection.file.canUploadVersion | User can update file version. |
|
||||
| 1.7.0 | app.selection.library | A single Library node is selected. |
|
||||
| 1.7.0 | app.selection.isPrivateLibrary | A private Library node is selected. |
|
||||
| 1.7.0 | app.selection.hasLibraryRole | The selected Library node has a role property. |
|
||||
| 1.7.0 | app.selection.hasNoLibraryRole | The selected Library node has no role property. |
|
||||
| 1.7.0 | app.selection.folder | A single Folder node is selected. |
|
||||
| 1.7.0 | app.selection.folder.canUpdate | User has permissions to update the selected folder. |
|
||||
| 1.7.0 | app.selection.folder.canUpdate | User has permissions to update the selected folder. |
|
||||
| 1.7.0 | app.selection.file.canLock | User has permissions to lock file. |
|
||||
| 1.7.0 | app.selection.file.canUnlock | User has permissions to unlock file. |
|
||||
| 1.7.0 | repository.isQuickShareEnabled | Whether the quick share repository option is enabled or not. |
|
||||
| 1.8.0 | canCopyNode | Checks if user can copy selected node. |
|
||||
| 1.8.0 | canToggleJoinLibrary | Checks if user can perform "Join" or "Cancel Join Request" on a library. |
|
||||
| 1.8.0 | canEditFolder | Checks if user can edit the selected folder. |
|
||||
| 1.8.0 | isTrashcanItemSelected | Checks if user has trashcan item selected. |
|
||||
| 1.8.0 | canViewFile | Checks if user can view the file. |
|
||||
| 1.8.0 | canLeaveLibrary | Checks if user can **Leave** selected library. |
|
||||
| 1.8.0 | canToggleSharedLink | Checks if user can toggle shared link mode. |
|
||||
| 1.8.0 | canShowInfoDrawer | Checks if user can show **Info Drawer** for the selected node. |
|
||||
| 1.8.0 | canManageFileVersions | Checks if user can manage file versions for the selected node. |
|
||||
| 1.8.0 | canManagePermissions | Checks if user can manage permissions for the selected node. |
|
||||
| 1.8.0 | canToggleEditOffline | Checks if user can toggle **Edit Offline** mode for selected node. |
|
||||
| 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. |
|
||||
| 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. |
|
||||
| 1.7.0 | app.selection.canUnshare | User is able to remove selected node(s) from public sharing. |
|
||||
| 1.7.0 | app.selection.canAddFavorite | User can add selected node(s) to favorites. |
|
||||
| 1.7.0 | app.selection.canRemoveFavorite | User can remove selected node(s) from favorites. |
|
||||
| 1.7.0 | app.selection.first.canUpdate | User has permission to update selected node(s). |
|
||||
| 1.7.0 | app.selection.file | A single File node is selected. |
|
||||
| 1.7.0 | app.selection.file.canShare | User is able to share the selected file. |
|
||||
| 1.7.0 | app.selection.file.isShared | A shared node is selected. |
|
||||
| 1.7.0 | app.selection.file.isLocked | File is locked for editing. |
|
||||
| 1.7.0 | app.selection.file.isLockOwner | File is locked and current user is the lock owner. |
|
||||
| 1.7.0 | app.selection.file.canUploadVersion | User can update file version. |
|
||||
| 1.7.0 | app.selection.library | A single Library node is selected. |
|
||||
| 1.7.0 | app.selection.isPrivateLibrary | A private Library node is selected. |
|
||||
| 1.7.0 | app.selection.hasLibraryRole | The selected Library node has a role property. |
|
||||
| 1.7.0 | app.selection.hasNoLibraryRole | The selected Library node has no role property. |
|
||||
| 1.7.0 | app.selection.folder | A single Folder node is selected. |
|
||||
| 1.7.0 | app.selection.folder.canUpdate | User has permissions to update the selected folder. |
|
||||
| 1.7.0 | app.selection.folder.canUpdate | User has permissions to update the selected folder. |
|
||||
| 1.7.0 | app.selection.file.canLock | User has permissions to lock file. |
|
||||
| 1.7.0 | app.selection.file.canUnlock | User has permissions to unlock file. |
|
||||
| 1.7.0 | repository.isQuickShareEnabled | Whether the quick share repository option is enabled or not. |
|
||||
| 1.8.0 | canCopyNode | Checks if user can copy selected node. |
|
||||
| 1.8.0 | canToggleJoinLibrary | Checks if user can perform "Join" or "Cancel Join Request" on a library. |
|
||||
| 1.8.0 | canEditFolder | Checks if user can edit the selected folder. |
|
||||
| 1.8.0 | isTrashcanItemSelected | Checks if user has trashcan item selected. |
|
||||
| 1.8.0 | canViewFile | Checks if user can view the file. |
|
||||
| 1.8.0 | canLeaveLibrary | Checks if user can **Leave** selected library. |
|
||||
| 1.8.0 | canToggleSharedLink | Checks if user can toggle shared link mode. |
|
||||
| 1.8.0 | canShowInfoDrawer | Checks if user can show **Info Drawer** for the selected node. |
|
||||
| 1.8.0 | canManageFileVersions | Checks if user can manage file versions for the selected node. |
|
||||
| 1.8.0 | canManagePermissions | Checks if user can manage permissions for the selected node. |
|
||||
| 1.8.0 | canToggleEditOffline | Checks if user can toggle **Edit Offline** mode for selected node. |
|
||||
| 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