mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-12 17:04:46 +00:00
support "disabled" rules for Viewer extensions
This commit is contained in:
parent
82649955f0
commit
dd02a8ddd6
@ -420,6 +420,22 @@ Every custom component receives the following properties at runtime:
|
|||||||
| url | string | File content URL. |
|
| url | string | File content URL. |
|
||||||
| extension | string | File name extension. |
|
| extension | string | File name extension. |
|
||||||
|
|
||||||
|
#### Rules
|
||||||
|
|
||||||
|
You can also provide a rule for the `disabled` state.
|
||||||
|
That allows to provide conditional availability for Viewer extensions based on external factors.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id": "app.viewer.pdf",
|
||||||
|
"fileExtension": "png",
|
||||||
|
"component": "app.components.tabs.metadata",
|
||||||
|
"rules": {
|
||||||
|
"disabled": "isViewerDisabled"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Toolbar actions
|
### Toolbar actions
|
||||||
|
|
||||||
The default toolbar actions from the ACA viewer can be customized through extensions to be replaced, modified or disabled.
|
The default toolbar actions from the ACA viewer can be customized through extensions to be replaced, modified or disabled.
|
||||||
|
@ -153,10 +153,11 @@ export class AppExtensionService implements AppRuleContext {
|
|||||||
config,
|
config,
|
||||||
'features.viewer.shared.toolbarActions'
|
'features.viewer.shared.toolbarActions'
|
||||||
);
|
);
|
||||||
this.viewerContentExtensions = this.loader.getElements<ViewerExtensionRef>(
|
|
||||||
config,
|
this.viewerContentExtensions = this.loader
|
||||||
'features.viewer.content'
|
.getElements<ViewerExtensionRef>(config, 'features.viewer.content')
|
||||||
);
|
.filter(ref => !this.isViewerExtensionDisabled(ref));
|
||||||
|
|
||||||
this.contextMenuActions = this.loader.getContentActions(
|
this.contextMenuActions = this.loader.getContentActions(
|
||||||
config,
|
config,
|
||||||
'features.contextMenu'
|
'features.contextMenu'
|
||||||
@ -457,6 +458,20 @@ export class AppExtensionService implements AppRuleContext {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isViewerExtensionDisabled(extension: any): boolean {
|
||||||
|
if (extension) {
|
||||||
|
if (extension.disabled) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (extension.rules && extension.rules.disabled) {
|
||||||
|
return this.extensions.evaluateRule(extension.rules.disabled, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
runActionById(id: string) {
|
runActionById(id: string) {
|
||||||
const action = this.extensions.getActionById(id);
|
const action = this.extensions.getActionById(id);
|
||||||
if (action) {
|
if (action) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user