Skip to content

Commit

Permalink
Move response/request and editor handler registration to uiExports (#…
Browse files Browse the repository at this point in the history
…12766)

* Need to import visualize index.js file to fill VisRequestHandlersRegistryProvider appropriately

A bit of a tacky solution but once embeddable handlers PR is checked
in, I can move this visualize specific code over to the visualize
embeddable handler and pull it out of dashboard.

* Do it the right way
  • Loading branch information
stacey-gammon authored and epixa committed Jul 13, 2017
1 parent 3876ff0 commit 18c9ea4
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 59 deletions.
9 changes: 9 additions & 0 deletions src/core_plugins/kibana/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ export default function (kibana) {
uiExports: {
hacks: ['plugins/kibana/dev_tools/hacks/hide_empty_tools'],
fieldFormats: ['plugins/kibana/field_formats/register'],
savedObjectTypes: [
'plugins/kibana/visualize/saved_visualizations/saved_visualization_register',
'plugins/kibana/discover/saved_searches/saved_search_register',
'plugins/kibana/dashboard/saved_dashboard/saved_dashboard_register',
],
app: {
id: 'kibana',
title: 'Kibana',
Expand All @@ -43,6 +48,10 @@ export default function (kibana) {
main: 'plugins/kibana/kibana',
uses: [
'visTypes',
'visResponseHandlers',
'visRequestHandlers',
'visEditorTypes',
'savedObjectTypes',
'spyModes',
'fieldFormats',
'fieldFormatEditors',
Expand Down
4 changes: 0 additions & 4 deletions src/core_plugins/kibana/public/dashboard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@ import 'plugins/kibana/dashboard/styles/index.less';
import 'plugins/kibana/dashboard/dashboard_config';
import uiRoutes from 'ui/routes';
import 'ui/accessibility/kbn_accessible_click';
import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry';
import { savedDashboardRegister } from 'plugins/kibana/dashboard/saved_dashboard/saved_dashboard_register';

import dashboardListingTemplate from './listing/dashboard_listing.html';
import { DashboardListingController } from './listing/dashboard_listing';
import { DashboardConstants } from './dashboard_constants';

SavedObjectRegistryProvider.register(savedDashboardRegister);

uiRoutes
.defaults(/dashboard/, {
requireDefaultIndex: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export function savedDashboardRegister(savedDashboards) {
import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry';

SavedObjectRegistryProvider.register((savedDashboards) => {
return savedDashboards;
}
});
4 changes: 0 additions & 4 deletions src/core_plugins/kibana/public/discover/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,3 @@ import 'plugins/kibana/discover/components/field_chooser/field_chooser';
import 'plugins/kibana/discover/controllers/discover';
import 'plugins/kibana/discover/styles/main.less';
import 'ui/doc_table/components/table_row';
import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry';
import { savedSearchProvider } from 'plugins/kibana/discover/saved_searches/saved_search_register';

SavedObjectRegistryProvider.register(savedSearchProvider);
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export function savedSearchProvider(savedSearches) {
import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry';

SavedObjectRegistryProvider.register((savedSearches) => {
return savedSearches;
}
});
21 changes: 0 additions & 21 deletions src/core_plugins/kibana/public/visualize/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,6 @@ import uiRoutes from 'ui/routes';
import visualizeListingTemplate from './listing/visualize_listing.html';
import { VisualizeListingController } from './listing/visualize_listing';
import { VisualizeConstants } from './visualize_constants';
import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry';
import { savedVisualizationProvider } from 'plugins/kibana/visualize/saved_visualizations/saved_visualization_register';
import { noneRequestHandlerProvider } from 'ui/vis/request_handlers/none';
import { CourierRequestHandlerProvider } from 'ui/vis/request_handlers/courier';
import { noneResponseHandler } from 'ui/vis/response_handlers/none';
import { BasicResponseHandlerProvider } from 'ui/vis/response_handlers/basic';

import { defaultEditor } from 'ui/vis/editors/default/default';


import { VisRequestHandlersRegistryProvider } from 'ui/registry/vis_request_handlers';
import { VisResponseHandlersRegistryProvider } from 'ui/registry/vis_response_handlers';
import { VisEditorTypesRegistryProvider } from 'ui/registry/vis_editor_types';

uiRoutes
.defaults(/visualize/, {
Expand All @@ -37,11 +24,3 @@ uiRoutes
controllerAs: 'listingController',
});

// preloading
SavedObjectRegistryProvider.register(savedVisualizationProvider);
VisRequestHandlersRegistryProvider.register(CourierRequestHandlerProvider);
VisRequestHandlersRegistryProvider.register(noneRequestHandlerProvider);
VisResponseHandlersRegistryProvider.register(noneResponseHandler);
VisResponseHandlersRegistryProvider.register(BasicResponseHandlerProvider);
VisEditorTypesRegistryProvider.register(defaultEditor);

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export function savedVisualizationProvider(savedVisualizations) {
import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry';

SavedObjectRegistryProvider.register((savedVisualizations) => {
return savedVisualizations;
}
});
5 changes: 4 additions & 1 deletion src/ui/public/vis/editors/default/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import './sidebar';
import './vis_options';
import $ from 'jquery';


import _ from 'lodash';
import angular from 'angular';
import defaultEditorTemplate from './default.html';

import { VisEditorTypesRegistryProvider } from 'ui/registry/vis_editor_types';

const defaultEditor = function ($rootScope, $compile) {
return class DefaultEditor {
static key = 'default';
Expand Down Expand Up @@ -98,4 +99,6 @@ const defaultEditor = function ($rootScope, $compile) {
};
};

VisEditorTypesRegistryProvider.register(defaultEditor);

export { defaultEditor };
4 changes: 4 additions & 0 deletions src/ui/public/vis/request_handlers/courier.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import _ from 'lodash';

import { VisRequestHandlersRegistryProvider } from 'ui/registry/vis_request_handlers';

const CourierRequestHandlerProvider = function (Private, courier, timefilter) {
return {
name: 'courier',
Expand Down Expand Up @@ -49,4 +51,6 @@ const CourierRequestHandlerProvider = function (Private, courier, timefilter) {
};
};

VisRequestHandlersRegistryProvider.register(CourierRequestHandlerProvider);

export { CourierRequestHandlerProvider };
4 changes: 4 additions & 0 deletions src/ui/public/vis/request_handlers/none.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { VisRequestHandlersRegistryProvider } from 'ui/registry/vis_request_handlers';

const noneRequestHandlerProvider = function () {
return {
name: 'none',
Expand All @@ -9,4 +11,6 @@ const noneRequestHandlerProvider = function () {
};
};

VisRequestHandlersRegistryProvider.register(noneRequestHandlerProvider);

export { noneRequestHandlerProvider };
3 changes: 3 additions & 0 deletions src/ui/public/vis/response_handlers/basic.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { AggResponseIndexProvider } from 'ui/agg_response/index';
import { AggResponseTabifyTableProvider } from 'ui/agg_response/tabify/_table';

import { VisResponseHandlersRegistryProvider } from 'ui/registry/vis_response_handlers';

const BasicResponseHandlerProvider = function (Private) {
const aggResponse = Private(AggResponseIndexProvider);
Expand Down Expand Up @@ -72,4 +73,6 @@ const BasicResponseHandlerProvider = function (Private) {
};
};

VisResponseHandlersRegistryProvider.register(BasicResponseHandlerProvider);

export { BasicResponseHandlerProvider };
4 changes: 4 additions & 0 deletions src/ui/public/vis/response_handlers/none.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// returns a promise
// promise returns response data when resolved

import { VisResponseHandlersRegistryProvider } from 'ui/registry/vis_response_handlers';

const noneResponseHandler = function () {
return {
name: 'none',
Expand All @@ -14,4 +16,6 @@ const noneResponseHandler = function () {
};
};

VisResponseHandlersRegistryProvider.register(noneResponseHandler);

export { noneResponseHandler };
22 changes: 0 additions & 22 deletions src/ui/public/vis/response_handlers/tabify.js

This file was deleted.

17 changes: 16 additions & 1 deletion src/ui/ui_exports.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,18 @@ export default class UiExports {
this.navLinks = new UiNavLinkCollection(this);
this.apps = new UiAppCollection(this);
this.aliases = {
fieldFormatEditors: ['ui/field_format_editor/register']
fieldFormatEditors: ['ui/field_format_editor/register'],
visRequestHandlers: [
'ui/vis/request_handlers/courier',
'ui/vis/request_handlers/none'
],
visResponseHandlers: [
'ui/vis/response_handlers/basic',
'ui/vis/response_handlers/none'
],
visEditorTypes: [
'ui/vis/editors/default/default',
],
};
this.urlBasePath = urlBasePath;
this.exportConsumer = _.memoize(this.exportConsumer);
Expand Down Expand Up @@ -91,6 +102,10 @@ export default class UiExports {
};

case 'visTypes':
case 'visResponseHandlers':
case 'visRequestHandlers':
case 'visEditorTypes':
case 'savedObjectTypes':
case 'fieldFormats':
case 'fieldFormatEditors':
case 'spyModes':
Expand Down

0 comments on commit 18c9ea4

Please sign in to comment.