kbn-interpreter package should not import from ui (#26161) (#26320)

This commit is contained in:
Peter Pisljar 2018-11-28 07:37:20 +01:00 committed by GitHub
parent 88d0c43e3b
commit 24be3c6211
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 8 deletions

View file

@ -17,7 +17,6 @@
* under the License.
*/
import chrome from 'ui/chrome';
import $script from 'scriptjs';
let resolvePromise = null;
@ -31,7 +30,7 @@ export const getBrowserRegistries = () => {
return populatePromise;
};
const loadBrowserRegistries = (registries) => {
const loadBrowserRegistries = (registries, basePath) => {
const remainingTypes = Object.keys(registries);
const populatedTypes = {};
@ -47,7 +46,7 @@ const loadBrowserRegistries = (registries) => {
// Load plugins one at a time because each needs a different loader function
// $script will only load each of these once, we so can call this as many times as we need?
const pluginPath = chrome.addBasePath(`/api/canvas/plugins?type=${type}`);
const pluginPath = `${basePath}/api/canvas/plugins?type=${type}`;
$script(pluginPath, () => {
populatedTypes[type] = registries[type];
loadType();
@ -58,7 +57,7 @@ const loadBrowserRegistries = (registries) => {
});
};
export const populateBrowserRegistries = (registries) => {
export const populateBrowserRegistries = (registries, basePath) => {
if (called) {
const oldPromise = populatePromise;
let newResolve;
@ -66,7 +65,7 @@ export const populateBrowserRegistries = (registries) => {
newResolve = _resolve;
});
oldPromise.then(oldTypes => {
loadBrowserRegistries(registries).then(newTypes => {
loadBrowserRegistries(registries, basePath).then(newTypes => {
newResolve({
...oldTypes,
...newTypes,
@ -76,7 +75,7 @@ export const populateBrowserRegistries = (registries) => {
return populatePromise;
}
called = true;
loadBrowserRegistries(registries).then(registries => {
loadBrowserRegistries(registries, basePath).then(registries => {
resolvePromise(registries);
});
return populatePromise;

View file

@ -17,6 +17,7 @@
* under the License.
*/
import chrome from 'ui/chrome';
import { populateBrowserRegistries } from '@kbn/interpreter/public';
import { typesRegistry, functionsRegistry } from '@kbn/interpreter/common';
@ -26,4 +27,4 @@ const types = {
types: typesRegistry
};
populateBrowserRegistries(types);
populateBrowserRegistries(types, chrome.getBasePath());

View file

@ -53,7 +53,7 @@ const mapDispatchToProps = dispatch => ({
// initialize the socket and interpreter
await createSocket(basePath);
loadPrivateBrowserFunctions();
await populateBrowserRegistries(types);
await populateBrowserRegistries(types, basePath);
await initializeInterpreter();
// set app state to ready