mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[uiExports] add replaceInjectedVars() export type
This commit is contained in:
parent
431e803492
commit
7ad237cce1
2 changed files with 14 additions and 3 deletions
|
@ -2,6 +2,7 @@ import { format as formatUrl } from 'url';
|
|||
import { readFileSync as readFile } from 'fs';
|
||||
import { defaults } from 'lodash';
|
||||
import Boom from 'boom';
|
||||
import { reduce as reduceAsync } from 'bluebird';
|
||||
import { resolve } from 'path';
|
||||
import fromRoot from '../utils/from_root';
|
||||
import UiExports from './ui_exports';
|
||||
|
@ -74,7 +75,11 @@ export default async (kbnServer, server, config) => {
|
|||
defaults: await server.uiSettings().getDefaults(),
|
||||
user: {}
|
||||
},
|
||||
vars: defaults(app.getInjectedVars() || {}, uiExports.defaultInjectedVars),
|
||||
vars: await reduceAsync(
|
||||
uiExports.injectedVarsReplacers,
|
||||
(acc, extender) => extender(acc, this.request, server),
|
||||
defaults(await app.getInjectedVars() || {}, uiExports.defaultInjectedVars)
|
||||
)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -89,7 +94,7 @@ export default async (kbnServer, server, config) => {
|
|||
|
||||
async function renderApp(app) {
|
||||
const isElasticsearchPluginRed = server.plugins.elasticsearch.status.state === 'red';
|
||||
const payload = await getPayload(app);
|
||||
const payload = await getPayload.call(this, app);
|
||||
if (!isElasticsearchPluginRed) {
|
||||
payload.uiSettings.user = await server.uiSettings().getUserProvided();
|
||||
}
|
||||
|
@ -97,7 +102,7 @@ export default async (kbnServer, server, config) => {
|
|||
}
|
||||
|
||||
async function renderAppWithDefaultConfig(app) {
|
||||
const payload = await getPayload(app);
|
||||
const payload = await getPayload.call(this, app);
|
||||
return viewAppWithPayload.call(this, app, payload);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ class UiExports {
|
|||
this.consumers = [];
|
||||
this.bundleProviders = [];
|
||||
this.defaultInjectedVars = {};
|
||||
this.injectedVarsReplacers = [];
|
||||
}
|
||||
|
||||
consumePlugin(plugin) {
|
||||
|
@ -107,6 +108,11 @@ class UiExports {
|
|||
_.merge(this.defaultInjectedVars, await injector.call(plugin, server, options));
|
||||
});
|
||||
};
|
||||
|
||||
case 'replaceInjectedVars':
|
||||
return (plugin, extender) => {
|
||||
this.injectedVarsReplacers.push(extender);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue