[ACA-2327] rule and evaluator optimisations (#1065)

* reduce imports

* canCopyNode rule

* simplify naming

* improve canShareFile rule

* canToggleJoinLibrary rule

* canEditFolder rule

* improve canUploadVersion rule

* isTrashcanItemSelected rule

* improve canDelete usage

* simplify canDownload usage

* canViewFile rule

* canLeaveLibrary rule

* rule usage improvements

* canToggleSharedLink rule

* canShowInfoDrawer rule

* canManageFileVersions rule

* canManagePermissions rule

* canToggleEditOffline rule

* canToggleFavorite rule

* minor polishing

* fix test

* fix evaluator

* code and test fixes

* fix evaluator
This commit is contained in:
Denys Vuika
2019-04-12 15:26:32 +01:00
committed by GitHub
parent c83f78f801
commit 2001bcd447
6 changed files with 327 additions and 374 deletions

View File

@@ -113,7 +113,6 @@ Below is the list of public actions types you can use in the plugin definitions
| 1.7.0 | UPLOAD_FOLDER | n/a | Invoke "Upload Folder" dialog and upload selected folder to the currently opened one. |
| 1.7.0 | UPLOAD_FILE_VERSION | n/a | Invoke "New File Version" dialog. |
| 1.7.0 | VIEW_FILE | MinimalNodeEntity | Preview the file (or selection) in the Viewer. |
| 1.8.0 | VIEW_NODE | string | Lightweight preview of a node by id. Can be invoked from extensions. |
| 1.7.0 | UNLOCK_WRITE | NodeEntry | Unlock file from read only mode |
| 1.7.0 | PRINT_FILE | MinimalNodeEntity | Print the file opened in the Viewer (or selected). |
| 1.7.0 | FULLSCREEN_VIEWER | n/a | Enters fullscreen mode to view the file opened in the Viewer. |
@@ -122,3 +121,4 @@ Below is the list of public actions types you can use in the plugin definitions
| 1.7.0 | TOGGLE_SEARCH_FILTER | n/a | Toggle Filter component visibility in Search Results. |
| 1.7.0 | SHOW_SEARCH_FILTER | n/a | Show Filter component in Search Results. |
| 1.7.0 | HIDE_SEARCH_FILTER | n/a | Hide Filter component in Search Results |
| 1.8.0 | VIEW_NODE | string | Lightweight preview of a node by id. Can be invoked from extensions. |

View File

@@ -56,11 +56,11 @@ in case you do not need providing extra parameters, or chaining multiple rules t
You can create new rules by chaining other rules and evaluators.
| Key | Description |
| ---------- | ----------------------------------------------------------------------------- |
| core.every | Evaluates to `true` if all chained rules evaluate to `true`. |
| core.some | Evaluates to `true` if at least one of the chained rules evaluates to `true`. |
| core.not | Evaluates to `true` if all chained rules evaluate to `false`. |
| Version | Key | Description |
| ------- | ---------- | ----------------------------------------------------------------------------- |
| 1.7.0 | core.every | Evaluates to `true` if all chained rules evaluate to `true`. |
| 1.7.0 | core.some | Evaluates to `true` if at least one of the chained rules evaluates to `true`. |
| 1.7.0 | core.not | Evaluates to `true` if all chained rules evaluate to `false`. |
Below is an example of the composite rule definition that combines the following conditions:
@@ -129,31 +129,42 @@ The button will be visible only when the linked rule evaluates to `true`.
## Application Evaluators
| Key | Description |
| ----------------------------------- | ------------------------------------------------------------ |
| app.selection.canDelete | User has permission to delete selected node(s). |
| app.selection.canDownload | User can download selected node(s). |
| app.selection.notEmpty | At least one node is selected. |
| app.selection.canUnshare | User is able to remove selected node(s) from public sharing. |
| app.selection.canAddFavorite | User can add selected node(s) to favorites. |
| app.selection.canRemoveFavorite | User can remove selected node(s) from favorites. |
| app.selection.first.canUpdate | User has permission to update selected node(s). |
| app.selection.file | A single File node is selected. |
| app.selection.file.canShare | User is able to share the selected file. |
| app.selection.file.isShared | A shared node is selected. |
| app.selection.file.isLocked | File is locked for editing. |
| app.selection.file.isLockOwner | File is locked and current user is the lock owner. |
| app.selection.file.canUploadVersion | User can update file version. |
| app.selection.library | A single Library node is selected. |
| app.selection.isPrivateLibrary | A private Library node is selected. |
| app.selection.hasLibraryRole | The selected Library node has a role property. |
| app.selection.hasNoLibraryRole | The selected Library node has no role property. |
| app.selection.folder | A single Folder node is selected. |
| app.selection.folder.canUpdate | User has permissions to update the selected folder. |
| app.selection.folder.canUpdate | User has permissions to update the selected folder. |
| app.selection.file.canLock | User has permissions to lock file. |
| app.selection.file.canUnlock | User has permissions to unlock file. |
| repository.isQuickShareEnabled | Whether the quick share repository option is enabled or not. |
| 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. |
## Navigation Evaluators
@@ -165,28 +176,28 @@ for example mixing `core.every` and `core.not`.
**Tip:** You can also negate any rule by utilizing a `!` prefix:
`!app.navigation.isTrashcan` is the opposite of the `app.navigation.isTrashcan`.
| Key | Description |
| --------------------------------- | ---------------------------------------------------------------- |
| app.navigation.folder.canCreate | User can create content in the currently opened folder. |
| app.navigation.folder.canUpload | User can upload content to the currently opened folder. |
| app.navigation.isTrashcan | User is using the **Trashcan** page. |
| app.navigation.isNotTrashcan | Current page is not a **Trashcan**. |
| app.navigation.isLibraries | User is using a **Libraries** or **Library Search Result** page. |
| app.navigation.isNotLibraries | Current page is not a **Libraries** page. |
| app.navigation.isSharedFiles | User is using the **Shared Files** page. |
| app.navigation.isNotSharedFiles | Current page is not **Shared Files**. |
| app.navigation.isFavorites | User is using the **Favorites** page. |
| app.navigation.isNotFavorites | Current page is not **Favorites**. |
| app.navigation.isRecentFiles | User is using the **Recent Files** page. |
| app.navigation.isNotRecentFiles | Current page is not **Recent Files**. |
| app.navigation.isSearchResults | User is using the **Search Results** page. |
| app.navigation.isNotSearchResults | Current page is not the **Search Results**. |
| app.navigation.isSharedPreview | Current page is preview **Shared Files**. |
| app.navigation.isFavoritesPreview | Current page is preview **Favorites**. |
| app.navigation.isSharedFileViewer | Current page is shared file preview page. |
| app.navigation.isPreview | Current page is **Preview**. |
| app.navigation.isPersonalFiles | Current page is **Personal Files**. |
| app.navigation.isLibraryFiles | Current page is **Library Files**. |
| Version | Key | Description |
| ------- | --------------------------------- | ---------------------------------------------------------------- |
| 1.7.0 | app.navigation.folder.canCreate | User can create content in the currently opened folder. |
| 1.7.0 | app.navigation.folder.canUpload | User can upload content to the currently opened folder. |
| 1.7.0 | app.navigation.isTrashcan | User is using the **Trashcan** page. |
| 1.7.0 | app.navigation.isNotTrashcan | Current page is not a **Trashcan**. |
| 1.7.0 | app.navigation.isLibraries | User is using a **Libraries** or **Library Search Result** page. |
| 1.7.0 | app.navigation.isNotLibraries | Current page is not a **Libraries** page. |
| 1.7.0 | app.navigation.isSharedFiles | User is using the **Shared Files** page. |
| 1.7.0 | app.navigation.isNotSharedFiles | Current page is not **Shared Files**. |
| 1.7.0 | app.navigation.isFavorites | User is using the **Favorites** page. |
| 1.7.0 | app.navigation.isNotFavorites | Current page is not **Favorites**. |
| 1.7.0 | app.navigation.isRecentFiles | User is using the **Recent Files** page. |
| 1.7.0 | app.navigation.isNotRecentFiles | Current page is not **Recent Files**. |
| 1.7.0 | app.navigation.isSearchResults | User is using the **Search Results** page. |
| 1.7.0 | app.navigation.isNotSearchResults | Current page is not the **Search Results**. |
| 1.7.0 | app.navigation.isSharedPreview | Current page is preview **Shared Files**. |
| 1.7.0 | app.navigation.isFavoritesPreview | Current page is preview **Favorites**. |
| 1.7.0 | app.navigation.isSharedFileViewer | Current page is shared file preview page. |
| 1.7.0 | app.navigation.isPreview | Current page is **Preview**. |
| 1.7.0 | app.navigation.isPersonalFiles | Current page is **Personal Files**. |
| 1.7.0 | app.navigation.isLibraryFiles | Current page is **Library Files**. |
**Tip:** See the [Registration](/extending/registration) section for more details
on how to register your own entries to be re-used at runtime.