extension enhancements (#552)

* default action types

* move context-menu to the correct folder
This commit is contained in:
Denys Vuika
2018-08-06 09:53:26 +01:00
committed by Cilibiu Bogdan
parent 22eac50d27
commit 8f3030760a
17 changed files with 40 additions and 57 deletions

View File

@@ -125,7 +125,7 @@ export class ExtensionService implements RuleContext {
this.routes = this.loadRoutes(config);
this.contentActions = this.loadContentActions(config);
this.viewerActions = this.loadViewerActions(config);
this.contentContextmenuActions = this.loadContentContextmenuActions(config);
this.contentContextmenuActions = this.loadContentContextMenuActions(config);
this.openWithActions = this.loadViewerOpenWith(config);
this.createActions = this.loadCreateActions(config);
this.navbar = this.loadNavBar(config);
@@ -159,26 +159,27 @@ export class ExtensionService implements RuleContext {
protected loadContentActions(config: ExtensionConfig) {
if (config && config.features && config.features.content) {
return (config.features.content.actions || []).sort(
this.sortByOrder
);
return (config.features.content.actions || [])
.sort(this.sortByOrder)
.map(this.setActionDefaults);
}
return [];
}
protected loadViewerActions(config: ExtensionConfig) {
if (config && config.features && config.features.viewer) {
return (config.features.viewer.actions || []).sort(
this.sortByOrder
);
return (config.features.viewer.actions || [])
.sort(this.sortByOrder)
.map(this.setActionDefaults);
}
return [];
}
protected loadContentContextmenuActions(config: ExtensionConfig): Array<ContentActionRef> {
protected loadContentContextMenuActions(config: ExtensionConfig): Array<ContentActionRef> {
if (config && config.features && config.features.content) {
return (config.features.content.contextActions || [])
.sort(this.sortByOrder);
.sort(this.sortByOrder)
.map(this.setActionDefaults);
}
return [];
}
@@ -351,6 +352,14 @@ export class ExtensionService implements RuleContext {
.filter(action => this.filterByRules(action));
}
setActionDefaults(action: ContentActionRef): ContentActionRef {
if (action) {
action.type = action.type || ContentActionType.default;
action.icon = action.icon || 'extension';
}
return action;
}
reduceSeparators(
acc: ContentActionRef[],
el: ContentActionRef,