Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions packages/kbn-interpreter/src/public/browser_registries.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
* under the License.
*/

import chrome from 'ui/chrome';
import $script from 'scriptjs';

let resolvePromise = null;
Expand All @@ -31,7 +30,7 @@ export const getBrowserRegistries = () => {
return populatePromise;
};

const loadBrowserRegistries = (registries) => {
const loadBrowserRegistries = (registries, basePath) => {
const remainingTypes = Object.keys(registries);
const populatedTypes = {};

Expand All @@ -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();
Expand All @@ -58,15 +57,15 @@ const loadBrowserRegistries = (registries) => {
});
};

export const populateBrowserRegistries = (registries) => {
export const populateBrowserRegistries = (registries, basePath) => {
if (called) {
const oldPromise = populatePromise;
let newResolve;
populatePromise = new Promise(_resolve => {
newResolve = _resolve;
});
oldPromise.then(oldTypes => {
loadBrowserRegistries(registries).then(newTypes => {
loadBrowserRegistries(registries, basePath).then(newTypes => {
newResolve({
...oldTypes,
...newTypes,
Expand All @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/core_plugins/interpreter/public/load_browser_plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -26,4 +27,4 @@ const types = {
types: typesRegistry
};

populateBrowserRegistries(types);
populateBrowserRegistries(types, chrome.getBasePath());
2 changes: 1 addition & 1 deletion x-pack/plugins/canvas/public/components/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down