-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[uiExports] add uiExport type "injectDefaultVars" #6546
[uiExports] add uiExport type "injectDefaultVars" #6546
Conversation
In order for plugins to inject default injected vars, they should define an "injectVars" uiExport that will be called once in order to build the default injected vars. This function should return an object with the injectedVars it wishes to add. Plugins are run in a non-deterministic order, so they should not be written to override each other. injectedVars should all have unique names. The injectedVars for the app will override any values provided by "default" injectedVars functions.
Looks like the expectation is that injectedVars is synchronous, and just returns an object of vars to inject. I actually need this to be an async thing, so I'd love to be able to return a Promise that resolves to said object... EDIT: Or, I could set it after the fact, since |
Are the injectVars from all plugins going to be used? Or is there a way to indicate which "apps" the injectVars should go to? Say I have a plugin that only messes with the kibana app and not the sense/console app. Can I just injectVars for kibana and not for sense/console? |
@trevan that isn't the plan right now, the plan is for the injectedVars to be the defaults for every app. That said, I'm not opposed to this idea I'm just not sure of a good api for it. For now, you should be able to monkey-patch kibana's UiApp like so (untested code): import { wrap } from 'lodash'
export default kibana => new kibana.Plugin({
requires: ['kibana'],
init(server, options) {
const uiApp = kibana.uiExports.apps.byName.kibana
const original = uiApp.getInjectedVars
uiApp.getInjectedVars = (server, opts) => {
const injectedVars = original.call(uiApp, server, opts)
// make modifications
return injectedVars
})
}
}) |
this also makes renderStatusPage async, by extension.
This reverts commit 2671cdb.
732fcdb
to
e120e44
Compare
Functionally, this looks good, Promises and all! 👯 |
ea8194e
to
f267ab1
Compare
LGTM, waiting for the build to pass |
[uiExports] add uiExport type "injectDefaultVars"
In order for plugins to inject default injected vars, they should define an "injectVars" uiExport that will be called once in order to build the default injected vars. This function should return an object with the injectedVars it wishes to add. Plugins are run in a non-deterministic order, so they should not be written to override each other. injectedVars should all have unique names. The injectedVars for the app will override any values provided by "default" injectedVars functions.