diff --git a/docs/extending/rules.md b/docs/extending/rules.md index 7d614dadc..06d77f1ca 100644 --- a/docs/extending/rules.md +++ b/docs/extending/rules.md @@ -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 diff --git a/projects/aca-content/assets/app.extensions.json b/projects/aca-content/assets/app.extensions.json index 9463f570f..a9bbf2f78 100644 --- a/projects/aca-content/assets/app.extensions.json +++ b/projects/aca-content/assets/app.extensions.json @@ -1070,7 +1070,8 @@ "click": "PRINT_FILE" }, "rules": { - "visible": "canViewFile" + "visible": "canViewFile", + "enabled": "canPrintFile" } }, { diff --git a/projects/aca-content/src/lib/aca-content.module.ts b/projects/aca-content/src/lib/aca-content.module.ts index 47e93d37f..bb20d2df2 100644 --- a/projects/aca-content/src/lib/aca-content.module.ts +++ b/projects/aca-content/src/lib/aca-content.module.ts @@ -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, diff --git a/projects/aca-shared/rules/src/app.rules.spec.ts b/projects/aca-shared/rules/src/app.rules.spec.ts index 08abd82d4..5962f16c2 100644 --- a/projects/aca-shared/rules/src/app.rules.spec.ts +++ b/projects/aca-shared/rules/src/app.rules.spec.ts @@ -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; diff --git a/projects/aca-shared/rules/src/app.rules.ts b/projects/aca-shared/rules/src/app.rules.ts index 6e87d8ef0..96e6f6e49 100644 --- a/projects/aca-shared/rules/src/app.rules.ts +++ b/projects/aca-shared/rules/src/app.rules.ts @@ -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`