Skip to content

Commit

Permalink
Reintegrate the PluginHelper
Browse files Browse the repository at this point in the history
Reintegrate the PluginHelper and provide it to the plugins via the
plugin loader as requested by @aldipower. For details about this
decision please refer to
https://github.com/mesosphere/marathon-ui/pull/609/files#r52335225
  • Loading branch information
Orlando Hohmeier committed Feb 9, 2016
1 parent 0ceb1fd commit 2771bd1
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/js/plugin/PluginLoader.js
Expand Up @@ -5,6 +5,7 @@ import PluginDispatcher from "./external/PluginDispatcher";
import PluginEvents from "./external/PluginEvents";
import PluginMountPoints from "./external/PluginMountPoints";
import PluginActions from "./external/PluginActions";
import PluginHelper from "./external/PluginHelper";
import PluginDispatcherProxy from "./PluginDispatcherProxy";

const PLUGIN_STARTUP_TIMEOUT = 10000; // in ms
Expand Down Expand Up @@ -39,6 +40,7 @@ const PluginLoader = {
PluginActions: PluginActions,
PluginDispatcher: PluginDispatcherProxy.create(pluginId),
PluginEvents: PluginEvents,
PluginHelper: PluginHelper.create(pluginId),
PluginMountPoints: PluginMountPoints,
pluginId: pluginId,
UIVersion: config.version
Expand Down
41 changes: 41 additions & 0 deletions src/js/plugin/external/PluginHelper.js
@@ -0,0 +1,41 @@
import PluginDispatcher from "./PluginDispatcher";
import PluginEvents from "./PluginEvents";

export default class PluginHelper {

constructor(pluginId) {
this.pluginId = pluginId;
Object.freeze(this);
}

static create(pluginId) {
return new PluginHelper(pluginId);
};

callAction(action, data) {
PluginDispatcher.dispatch({
actionType: action,
pluginId: this.pluginId,
data: data
});
}

injectComponent(component, placeId) {
PluginDispatcher.dispatch({
eventType: PluginEvents.INJECT_COMPONENT,
placeId: placeId,
pluginId: this.pluginId,
component: component
});
}

registerMe() {
PluginDispatcher.dispatch({
pluginId: this.pluginId,
eventType: PluginEvents.STARTUP_COMPLETE
});
}

}

export default PluginHelper;

0 comments on commit 2771bd1

Please sign in to comment.