register
When the Dashboard have loaded the index.js successfully it will be executed and the register function from the Plugin API will be call and the plugin will register itself in the Dashboard. For this to be successful an Agent, Application or Widget must be defined in the object passed to Dashboard.register.
The only difference in how these components is registered is that an Agent is also initialized in this stage.
register()
method takes one argument type Object. In order for your plugin to work and be registered in Dashboard you need to initiate your plugin instance with a unique bundle, the same one in manifest.json file, and at least one of Dashboard components Application, Widget, Agent, Settings and Health
example
Registering a plugin with an Application and Settings components.
import DashboardPlugin from 'Dashboard/plugin'
const Plugin = new DashboardPlugin('@plugin_bundle')
const registerPlugin = () => {
const { Settings } = require('@components/Settings')
const { Application } = require('@components/Application')
Plugin.register({
settings: Settings,
application: Application,
})
}
registerPlugin()
You might wondering why do we require the plugin components dynamically inside the register function instead of just importing them in the top level of the file!
Well! as it sounds and looks weird! we need to do that in order to expose the Plugin-API to the other files of the plugin, when you initiate your plugin with new DashboardPlugin('@plugin_bundle')
it will return a class that contains methods and functions and some basses that can be used in your components
What can i register with my plugin?
AgentApplicationWidgetHealthReducersPortalsRequirementsPermissionsDefault configConfig ModifiersLast updated
Was this helpful?