update evaluator docs, workspace snippet (#995)

* add missing docs and code hints

* update app evaluator docs and code hints
This commit is contained in:
Denys Vuika 2019-03-06 14:28:57 +00:00 committed by GitHub
parent 32283d7ac4
commit 3641e0168f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 220 additions and 22 deletions

1
.gitignore vendored
View File

@ -23,6 +23,7 @@
!.vscode/tasks.json !.vscode/tasks.json
!.vscode/launch.json !.vscode/launch.json
!.vscode/extensions.json !.vscode/extensions.json
!.vscode/*.code-snippets
.history .history
# misc # misc

19
.vscode/typescript.code-snippets vendored Normal file
View File

@ -0,0 +1,19 @@
{
"ext-evaluator": {
"description": "Generate a new evaluator.",
"scope": "typescript",
"prefix": "ext-evaluator",
"body": [
"/**",
" * Checks if ${2:<description>}.",
" * JSON ref: `app.$1`",
" */",
"export function ${1:name}(",
"\tcontext: AppRuleContext,",
"\t...args: RuleParameter[]",
"): boolean {",
"\treturn ${3:true};${0}",
"}"
]
}
}

View File

@ -140,9 +140,10 @@ The button will be visible only when the linked rule evaluates to `true`.
| app.selection.first.canUpdate | User has permission to update selected node(s). | | app.selection.first.canUpdate | User has permission to update selected node(s). |
| app.selection.file | A single File node is selected. | | app.selection.file | A single File node is selected. |
| app.selection.file.canShare | User is able to share the selected file. | | app.selection.file.canShare | User is able to share the selected file. |
| app.selection.file.isShared | A shared node is selected | | app.selection.file.isShared | A shared node is selected. |
| app.selection.file.isLocked | File is locked for editing | | app.selection.file.isLocked | File is locked for editing. |
| app.selection.file.canUploadVersion | User can update file version | | 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.library | A single Library node is selected. |
| app.selection.isPrivateLibrary | A private 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.hasLibraryRole | The selected Library node has a role property. |
@ -164,25 +165,28 @@ for example mixing `core.every` and `core.not`.
**Tip:** You can also negate any rule by utilizing a `!` prefix: **Tip:** You can also negate any rule by utilizing a `!` prefix:
`!app.navigation.isTrashcan` is the opposite of the `app.navigation.isTrashcan`. `!app.navigation.isTrashcan` is the opposite of the `app.navigation.isTrashcan`.
| Key | Description | | Key | Description |
| --------------------------------- | ------------------------------------------------------- | | --------------------------------- | ---------------------------------------------------------------- |
| app.navigation.folder.canCreate | User can create content in the currently opened folder. | | 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.folder.canUpload | User can upload content to the currently opened folder. |
| app.navigation.isTrashcan | User is using the **Trashcan** page. | | app.navigation.isTrashcan | User is using the **Trashcan** page. |
| app.navigation.isNotTrashcan | Current page is not a **Trashcan**. | | app.navigation.isNotTrashcan | Current page is not a **Trashcan**. |
| app.navigation.isLibraries | User is using a **Libraries** page. | | 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.isNotLibraries | Current page is not a **Libraries** page. |
| app.navigation.isSharedFiles | User is using the **Shared Files** page. | | app.navigation.isSharedFiles | User is using the **Shared Files** page. |
| app.navigation.isNotSharedFiles | Current page is not **Shared Files**. | | app.navigation.isNotSharedFiles | Current page is not **Shared Files**. |
| app.navigation.isFavorites | User is using the **Favorites** page. | | app.navigation.isFavorites | User is using the **Favorites** page. |
| app.navigation.isNotFavorites | Current page is not **Favorites** | | app.navigation.isNotFavorites | Current page is not **Favorites**. |
| app.navigation.isRecentFiles | User is using the **Recent Files** page. | | app.navigation.isRecentFiles | User is using the **Recent Files** page. |
| app.navigation.isNotRecentFiles | Current page is not **Recent Files**. | | app.navigation.isNotRecentFiles | Current page is not **Recent Files**. |
| app.navigation.isSearchResults | User is using the **Search Results** page. | | app.navigation.isSearchResults | User is using the **Search Results** page. |
| app.navigation.isNotSearchResults | Current page is not the **Search Results**. | | app.navigation.isNotSearchResults | Current page is not the **Search Results**. |
| app.navigation.isSharedPreview | Current page is preview **Shared Files** | | app.navigation.isSharedPreview | Current page is preview **Shared Files**. |
| app.navigation.isFavoritesPreview | Current page is preview **Favorites** | | app.navigation.isFavoritesPreview | Current page is preview **Favorites**. |
| app.navigation.isSharedFileViewer | Current page is shared file preview page | | 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**. |
**Tip:** See the [Registration](/extending/registration) section for more details **Tip:** See the [Registration](/extending/registration) section for more details
on how to register your own entries to be re-used at runtime. on how to register your own entries to be re-used at runtime.

View File

@ -123,6 +123,7 @@ export class CoreExtensionsModule {
'app.selection.file.canShare': app.canShareFile, 'app.selection.file.canShare': app.canShareFile,
'app.selection.file.isShared': app.isShared, 'app.selection.file.isShared': app.isShared,
'app.selection.file.isLocked': app.hasLockedFiles, 'app.selection.file.isLocked': app.hasLockedFiles,
'app.selection.file.isLockOwner': app.isUserWriteLockOwner,
'app.selection.file.canUploadVersion': app.canUploadVersion, 'app.selection.file.canUploadVersion': app.canUploadVersion,
'app.selection.library': app.hasLibrarySelected, 'app.selection.library': app.hasLibrarySelected,
'app.selection.isPrivateLibrary': app.isPrivateLibrary, 'app.selection.isPrivateLibrary': app.isPrivateLibrary,

View File

@ -36,6 +36,10 @@ import {
isPreview isPreview
} from './navigation.evaluators'; } from './navigation.evaluators';
/**
* Checks if user can mark selected nodes as **Favorite**.
* JSON ref: `app.selection.canAddFavorite`
*/
export function canAddFavorite( export function canAddFavorite(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -53,6 +57,10 @@ export function canAddFavorite(
return false; return false;
} }
/**
* Checks if user can un-mark selected nodes as **Favorite**.
* JSON ref: `app.selection.canRemoveFavorite`
*/
export function canRemoveFavorite( export function canRemoveFavorite(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -66,6 +74,10 @@ export function canRemoveFavorite(
return false; return false;
} }
/**
* Checks if user can share selected file.
* JSON ref: `app.selection.file.canShare`
*/
export function canShareFile( export function canShareFile(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -76,6 +88,10 @@ export function canShareFile(
return false; return false;
} }
/**
* Checks if the selected file is already shared.
* JSON ref: `app.selection.file.isShared`
*/
export function isShared( export function isShared(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -98,6 +114,10 @@ export function isShared(
return false; return false;
} }
/**
* Checks if user can delete selected nodes.
* JSON ref: `app.selection.canDelete`
*/
export function canDeleteSelection( export function canDeleteSelection(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -133,6 +153,10 @@ export function canDeleteSelection(
return false; return false;
} }
/**
* Checks if user can un-share selected nodes.
* JSON ref: `app.selection.canUnshare`
*/
export function canUnshareNodes( export function canUnshareNodes(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -145,6 +169,10 @@ export function canUnshareNodes(
return false; return false;
} }
/**
* Checks if user selected anything.
* JSON ref: `app.selection.notEmpty`
*/
export function hasSelection( export function hasSelection(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -152,6 +180,10 @@ export function hasSelection(
return !context.selection.isEmpty; return !context.selection.isEmpty;
} }
/**
* Checks if user can create a new folder with current path.
* JSON ref: `app.navigation.folder.canCreate`
*/
export function canCreateFolder( export function canCreateFolder(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -163,6 +195,10 @@ export function canCreateFolder(
return false; return false;
} }
/**
* Checks if user can upload content to current folder.
* JSON ref: `app.navigation.folder.canUpload`
*/
export function canUpload( export function canUpload(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -174,6 +210,10 @@ export function canUpload(
return false; return false;
} }
/**
* Checks if user can download selected nodes (either files or folders).
* JSON ref: `app.selection.canDownload`
*/
export function canDownloadSelection( export function canDownloadSelection(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -189,6 +229,10 @@ export function canDownloadSelection(
return false; return false;
} }
/**
* Checks if user has selected a folder.
* JSON ref: `app.selection.folder`
*/
export function hasFolderSelected( export function hasFolderSelected(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -197,6 +241,10 @@ export function hasFolderSelected(
return folder ? true : false; return folder ? true : false;
} }
/**
* Checks if user has selected a library (site).
* JSON ref: `app.selection.library`
*/
export function hasLibrarySelected( export function hasLibrarySelected(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -205,6 +253,10 @@ export function hasLibrarySelected(
return library ? true : false; return library ? true : false;
} }
/**
* Checks if user has selected a **private** library (site)
* JSON ref: `app.selection.isPrivateLibrary`
*/
export function isPrivateLibrary( export function isPrivateLibrary(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -219,6 +271,10 @@ export function isPrivateLibrary(
: false; : false;
} }
/**
* Checks if the selected library has a **role** property defined.
* JSON ref: `app.selection.hasLibraryRole`
*/
export function hasLibraryRole( export function hasLibraryRole(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -227,6 +283,10 @@ export function hasLibraryRole(
return library ? !!(library.entry && library.entry.role) : false; return library ? !!(library.entry && library.entry.role) : false;
} }
/**
* Checks if the selected library has no **role** property defined.
* JSON ref: `app.selection.hasNoLibraryRole`
*/
export function hasNoLibraryRole( export function hasNoLibraryRole(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -234,6 +294,10 @@ export function hasNoLibraryRole(
return !hasLibraryRole(context, ...args); return !hasLibraryRole(context, ...args);
} }
/**
* Checks if user has selected a file.
* JSON ref: `app.selection.file`
*/
export function hasFileSelected( export function hasFileSelected(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -242,6 +306,10 @@ export function hasFileSelected(
return file ? true : false; return file ? true : false;
} }
/**
* Checks if user can update the first selected node.
* JSON ref: `app.selection.first.canUpdate`
*/
export function canUpdateSelectedNode( export function canUpdateSelectedNode(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -264,6 +332,10 @@ export function canUpdateSelectedNode(
return false; return false;
} }
/**
* Checks if user can update the first selected folder.
* JSON ref: `app.selection.folder.canUpdate`
*/
export function canUpdateSelectedFolder( export function canUpdateSelectedFolder(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -279,6 +351,10 @@ export function canUpdateSelectedFolder(
return false; return false;
} }
/**
* Checks if user has selected a **locked** file node.
* JSON ref: `app.selection.file.isLocked`
*/
export function hasLockedFiles( export function hasLockedFiles(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -300,6 +376,10 @@ export function hasLockedFiles(
return false; return false;
} }
/**
* Checks if the selected file has **write** or **read-only** locks specified.
* JSON ref: `app.selection.file.isLocked`
*/
export function isWriteLocked( export function isWriteLocked(
context: AppRuleContext, context: AppRuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -316,6 +396,11 @@ export function isWriteLocked(
); );
} }
/**
* Checks if the selected file has **write** or **read-only** locks specified,
* and that current user is the owner of the lock.
* JSON ref: `app.selection.file.isLockOwner`
*/
export function isUserWriteLockOwner( export function isUserWriteLockOwner(
context: AppRuleContext, context: AppRuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -328,6 +413,10 @@ export function isUserWriteLockOwner(
); );
} }
/**
* Checks if user can lock selected file.
* JSON ref: `app.selection.file.canLock`
*/
export function canLockFile( export function canLockFile(
context: AppRuleContext, context: AppRuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -337,6 +426,10 @@ export function canLockFile(
); );
} }
/**
* Checks if user can unlock selected file.
* JSON ref: `app.selection.file.canLock`
*/
export function canUnlockFile( export function canUnlockFile(
context: AppRuleContext, context: AppRuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -349,6 +442,10 @@ export function canUnlockFile(
); );
} }
/**
* Checks if user can upload a new version of the file.
* JSON ref: `app.selection.file.canUploadVersion`
*/
export function canUploadVersion( export function canUploadVersion(
context: AppRuleContext, context: AppRuleContext,
...args: RuleParameter[] ...args: RuleParameter[]

View File

@ -25,6 +25,10 @@
import { RuleContext, RuleParameter } from '@alfresco/adf-extensions'; import { RuleContext, RuleParameter } from '@alfresco/adf-extensions';
/**
* Checks if a Preview route is activated.
* JSON ref: `app.navigation.isPreview`
*/
export function isPreview( export function isPreview(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -33,6 +37,10 @@ export function isPreview(
return url && url.includes('/preview/'); return url && url.includes('/preview/');
} }
/**
* Checks if a **Favorites** route is activated.
* JSON ref: `app.navigation.isFavorites`
*/
export function isFavorites( export function isFavorites(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -41,6 +49,10 @@ export function isFavorites(
return url && url.startsWith('/favorites') && !isPreview(context, ...args); return url && url.startsWith('/favorites') && !isPreview(context, ...args);
} }
/**
* Checks if the activated route is not **Favorites**.
* JSON ref: `app.navigation.isNotFavorites`
*/
export function isNotFavorites( export function isNotFavorites(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -48,6 +60,10 @@ export function isNotFavorites(
return !isFavorites(context, ...args); return !isFavorites(context, ...args);
} }
/**
* Checks if a **Shared Files** route is activated.
* JSON ref: `app.navigation.isSharedFiles`
*/
export function isSharedFiles( export function isSharedFiles(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -56,6 +72,10 @@ export function isSharedFiles(
return url && url.startsWith('/shared') && !isPreview(context, ...args); return url && url.startsWith('/shared') && !isPreview(context, ...args);
} }
/**
* Checks if the activated route is not **Shared Files**.
* JSON ref: `app.navigation.isNotSharedFiles`
*/
export function isNotSharedFiles( export function isNotSharedFiles(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -63,6 +83,10 @@ export function isNotSharedFiles(
return !isSharedFiles(context, ...args); return !isSharedFiles(context, ...args);
} }
/**
* Checks if a **Trashcan** route is activated.
* JSON ref: `app.navigation.isTrashcan`
*/
export function isTrashcan( export function isTrashcan(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -71,6 +95,10 @@ export function isTrashcan(
return url && url.startsWith('/trashcan'); return url && url.startsWith('/trashcan');
} }
/**
* Checks if the activated route is not **Trashcan**.
* JSON ref: `app.navigation.isNotTrashcan`
*/
export function isNotTrashcan( export function isNotTrashcan(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -78,6 +106,10 @@ export function isNotTrashcan(
return !isTrashcan(context, ...args); return !isTrashcan(context, ...args);
} }
/**
* Checks if a **Personal Files** route is activated.
* JSON ref: `app.navigation.isPersonalFiles`
*/
export function isPersonalFiles( export function isPersonalFiles(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -86,6 +118,10 @@ export function isPersonalFiles(
return url && url.startsWith('/personal-files'); return url && url.startsWith('/personal-files');
} }
/**
* Checks if a **Library Files** route is activated.
* JSON ref: `app.navigation.isLibraryFiles`
*/
export function isLibraryFiles( export function isLibraryFiles(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -94,6 +130,10 @@ export function isLibraryFiles(
return url && url.startsWith('/libraries'); return url && url.startsWith('/libraries');
} }
/**
* Checks if a **Library Files** or **Library Search Result** route is activated.
* JSON ref: `app.navigation.isLibraryFiles`
*/
export function isLibraries( export function isLibraries(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -104,6 +144,10 @@ export function isLibraries(
); );
} }
/**
* Checks if the activated route is neither **Libraries** nor **Library Search Results**.
* JSON ref: `app.navigation.isNotLibraries`
*/
export function isNotLibraries( export function isNotLibraries(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -111,6 +155,10 @@ export function isNotLibraries(
return !isLibraries(context, ...args); return !isLibraries(context, ...args);
} }
/**
* Checks if a **Recent Files** route is activated.
* JSON ref: `app.navigation.isRecentFiles`
*/
export function isRecentFiles( export function isRecentFiles(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -119,6 +167,10 @@ export function isRecentFiles(
return url && url.startsWith('/recent-files'); return url && url.startsWith('/recent-files');
} }
/**
* Checks if the activated route is not **Recent Files**.
* JSON ref: `app.navigation.isNotRecentFiles`
*/
export function isNotRecentFiles( export function isNotRecentFiles(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -126,6 +178,10 @@ export function isNotRecentFiles(
return !isRecentFiles(context, ...args); return !isRecentFiles(context, ...args);
} }
/**
* Checks if a **Search Results** route is activated.
* JSON ref: `app.navigation.isSearchResults`
*/
export function isSearchResults( export function isSearchResults(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -134,6 +190,10 @@ export function isSearchResults(
return url && url.startsWith('/search'); return url && url.startsWith('/search');
} }
/**
* Checks if the activated route is not **Search Results**.
* JSON ref: `app.navigation.isNotSearchResults`
*/
export function isNotSearchResults( export function isNotSearchResults(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -141,6 +201,10 @@ export function isNotSearchResults(
return !isSearchResults(context, ...args); return !isSearchResults(context, ...args);
} }
/**
* Checks if a **Shared Preview** route is activated.
* JSON ref: `app.navigation.isSharedPreview`
*/
export function isSharedPreview( export function isSharedPreview(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -149,6 +213,10 @@ export function isSharedPreview(
return url && url.startsWith('/shared/preview/'); return url && url.startsWith('/shared/preview/');
} }
/**
* Checks if a **Favorites Preview** route is activated.
* JSON ref: `app.navigation.isFavoritesPreview`
*/
export function isFavoritesPreview( export function isFavoritesPreview(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]
@ -157,6 +225,10 @@ export function isFavoritesPreview(
return url && url.startsWith('/favorites/preview/'); return url && url.startsWith('/favorites/preview/');
} }
/**
* Checks if a **Shared File Preview** route is activated.
* JSON ref: `app.navigation.isFavoritesPreview`
*/
export function isSharedFileViewer( export function isSharedFileViewer(
context: RuleContext, context: RuleContext,
...args: RuleParameter[] ...args: RuleParameter[]

View File

@ -26,6 +26,10 @@
import { RuleParameter } from '@alfresco/adf-extensions'; import { RuleParameter } from '@alfresco/adf-extensions';
import { AppRuleContext } from '../app.interface'; import { AppRuleContext } from '../app.interface';
/**
* Checks if the quick share repository option is enabled or not.
* JSON ref: `repository.isQuickShareEnabled`
*/
export function hasQuickShareEnabled( export function hasQuickShareEnabled(
context: AppRuleContext, context: AppRuleContext,
...args: RuleParameter[] ...args: RuleParameter[]