From 003ed39b9cdec55ce2c021f98ca54a2c7ac27dae Mon Sep 17 00:00:00 2001 From: Stacey Gammon Date: Tue, 11 Jul 2017 11:37:14 -0400 Subject: [PATCH 1/2] 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. --- src/core_plugins/kibana/public/dashboard/dashboard.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core_plugins/kibana/public/dashboard/dashboard.js b/src/core_plugins/kibana/public/dashboard/dashboard.js index 0ac9fca905886..eb3b3989288a9 100644 --- a/src/core_plugins/kibana/public/dashboard/dashboard.js +++ b/src/core_plugins/kibana/public/dashboard/dashboard.js @@ -6,6 +6,7 @@ import chrome from 'ui/chrome'; import 'plugins/kibana/dashboard/grid'; import 'plugins/kibana/dashboard/panel/panel'; +import 'plugins/kibana/visualize'; import { SavedObjectNotFound } from 'ui/errors'; import { getDashboardTitle, getUnsavedChangesWarningMessage } from './dashboard_strings'; From 4266d01d36c85175d2c2630b8fbedca96f414744 Mon Sep 17 00:00:00 2001 From: Stacey Gammon Date: Tue, 11 Jul 2017 14:02:03 -0400 Subject: [PATCH 2/2] Do it the right way --- src/core_plugins/kibana/index.js | 9 ++++++++ .../kibana/public/dashboard/dashboard.js | 1 - .../kibana/public/dashboard/index.js | 4 ---- .../saved_dashboard_register.js | 6 +++-- .../kibana/public/discover/index.js | 4 ---- .../saved_searches/saved_search_register.js | 6 +++-- .../kibana/public/visualize/index.js | 21 ------------------ .../saved_visualization_register.js | 6 +++-- src/ui/public/vis/editors/default/default.js | 5 ++++- src/ui/public/vis/request_handlers/courier.js | 4 ++++ src/ui/public/vis/request_handlers/none.js | 4 ++++ src/ui/public/vis/response_handlers/basic.js | 3 +++ src/ui/public/vis/response_handlers/none.js | 4 ++++ src/ui/public/vis/response_handlers/tabify.js | 22 ------------------- src/ui/ui_exports.js | 17 +++++++++++++- 15 files changed, 56 insertions(+), 60 deletions(-) delete mode 100644 src/ui/public/vis/response_handlers/tabify.js diff --git a/src/core_plugins/kibana/index.js b/src/core_plugins/kibana/index.js index d9f6205b1b901..d2a15195e29b2 100644 --- a/src/core_plugins/kibana/index.js +++ b/src/core_plugins/kibana/index.js @@ -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', @@ -43,6 +48,10 @@ export default function (kibana) { main: 'plugins/kibana/kibana', uses: [ 'visTypes', + 'visResponseHandlers', + 'visRequestHandlers', + 'visEditorTypes', + 'savedObjectTypes', 'spyModes', 'fieldFormats', 'fieldFormatEditors', diff --git a/src/core_plugins/kibana/public/dashboard/dashboard.js b/src/core_plugins/kibana/public/dashboard/dashboard.js index eb3b3989288a9..0ac9fca905886 100644 --- a/src/core_plugins/kibana/public/dashboard/dashboard.js +++ b/src/core_plugins/kibana/public/dashboard/dashboard.js @@ -6,7 +6,6 @@ import chrome from 'ui/chrome'; import 'plugins/kibana/dashboard/grid'; import 'plugins/kibana/dashboard/panel/panel'; -import 'plugins/kibana/visualize'; import { SavedObjectNotFound } from 'ui/errors'; import { getDashboardTitle, getUnsavedChangesWarningMessage } from './dashboard_strings'; diff --git a/src/core_plugins/kibana/public/dashboard/index.js b/src/core_plugins/kibana/public/dashboard/index.js index 069c32ff02236..d4359db84c00d 100644 --- a/src/core_plugins/kibana/public/dashboard/index.js +++ b/src/core_plugins/kibana/public/dashboard/index.js @@ -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 diff --git a/src/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard_register.js b/src/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard_register.js index 0c1b26f1e4605..86d3bda223f99 100644 --- a/src/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard_register.js +++ b/src/core_plugins/kibana/public/dashboard/saved_dashboard/saved_dashboard_register.js @@ -1,3 +1,5 @@ -export function savedDashboardRegister(savedDashboards) { +import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry'; + +SavedObjectRegistryProvider.register((savedDashboards) => { return savedDashboards; -} +}); diff --git a/src/core_plugins/kibana/public/discover/index.js b/src/core_plugins/kibana/public/discover/index.js index 68a83fc5ae97a..29d7bbd5c311f 100644 --- a/src/core_plugins/kibana/public/discover/index.js +++ b/src/core_plugins/kibana/public/discover/index.js @@ -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); diff --git a/src/core_plugins/kibana/public/discover/saved_searches/saved_search_register.js b/src/core_plugins/kibana/public/discover/saved_searches/saved_search_register.js index 64ca933cbe2cf..59461fe98a7a6 100644 --- a/src/core_plugins/kibana/public/discover/saved_searches/saved_search_register.js +++ b/src/core_plugins/kibana/public/discover/saved_searches/saved_search_register.js @@ -1,3 +1,5 @@ -export function savedSearchProvider(savedSearches) { +import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry'; + +SavedObjectRegistryProvider.register((savedSearches) => { return savedSearches; -} +}); diff --git a/src/core_plugins/kibana/public/visualize/index.js b/src/core_plugins/kibana/public/visualize/index.js index c0bf9caab2145..f28886094d36a 100644 --- a/src/core_plugins/kibana/public/visualize/index.js +++ b/src/core_plugins/kibana/public/visualize/index.js @@ -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/, { @@ -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); - diff --git a/src/core_plugins/kibana/public/visualize/saved_visualizations/saved_visualization_register.js b/src/core_plugins/kibana/public/visualize/saved_visualizations/saved_visualization_register.js index 5d6f3f35a852f..2c7bc8ed10b66 100644 --- a/src/core_plugins/kibana/public/visualize/saved_visualizations/saved_visualization_register.js +++ b/src/core_plugins/kibana/public/visualize/saved_visualizations/saved_visualization_register.js @@ -1,3 +1,5 @@ -export function savedVisualizationProvider(savedVisualizations) { +import { SavedObjectRegistryProvider } from 'ui/saved_objects/saved_object_registry'; + +SavedObjectRegistryProvider.register((savedVisualizations) => { return savedVisualizations; -} +}); diff --git a/src/ui/public/vis/editors/default/default.js b/src/ui/public/vis/editors/default/default.js index b44aa9c896757..47e95489e1fc1 100644 --- a/src/ui/public/vis/editors/default/default.js +++ b/src/ui/public/vis/editors/default/default.js @@ -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'; @@ -99,4 +100,6 @@ const defaultEditor = function ($rootScope, $compile) { }; }; +VisEditorTypesRegistryProvider.register(defaultEditor); + export { defaultEditor }; diff --git a/src/ui/public/vis/request_handlers/courier.js b/src/ui/public/vis/request_handlers/courier.js index 17ceb6c2524d7..65581bba939fb 100644 --- a/src/ui/public/vis/request_handlers/courier.js +++ b/src/ui/public/vis/request_handlers/courier.js @@ -1,5 +1,7 @@ import _ from 'lodash'; +import { VisRequestHandlersRegistryProvider } from 'ui/registry/vis_request_handlers'; + const CourierRequestHandlerProvider = function (Private, courier, timefilter) { return { name: 'courier', @@ -48,4 +50,6 @@ const CourierRequestHandlerProvider = function (Private, courier, timefilter) { }; }; +VisRequestHandlersRegistryProvider.register(CourierRequestHandlerProvider); + export { CourierRequestHandlerProvider }; diff --git a/src/ui/public/vis/request_handlers/none.js b/src/ui/public/vis/request_handlers/none.js index 5bb0444bddb77..a3dac6e07ed5e 100644 --- a/src/ui/public/vis/request_handlers/none.js +++ b/src/ui/public/vis/request_handlers/none.js @@ -1,3 +1,5 @@ +import { VisRequestHandlersRegistryProvider } from 'ui/registry/vis_request_handlers'; + const noneRequestHandlerProvider = function () { return { name: 'none', @@ -9,4 +11,6 @@ const noneRequestHandlerProvider = function () { }; }; +VisRequestHandlersRegistryProvider.register(noneRequestHandlerProvider); + export { noneRequestHandlerProvider }; diff --git a/src/ui/public/vis/response_handlers/basic.js b/src/ui/public/vis/response_handlers/basic.js index 886ebabe336ab..f9f6643ce1a71 100644 --- a/src/ui/public/vis/response_handlers/basic.js +++ b/src/ui/public/vis/response_handlers/basic.js @@ -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); @@ -72,4 +73,6 @@ const BasicResponseHandlerProvider = function (Private) { }; }; +VisResponseHandlersRegistryProvider.register(BasicResponseHandlerProvider); + export { BasicResponseHandlerProvider }; diff --git a/src/ui/public/vis/response_handlers/none.js b/src/ui/public/vis/response_handlers/none.js index ce9874a378f16..2db8eccaec236 100644 --- a/src/ui/public/vis/response_handlers/none.js +++ b/src/ui/public/vis/response_handlers/none.js @@ -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', @@ -14,4 +16,6 @@ const noneResponseHandler = function () { }; }; +VisResponseHandlersRegistryProvider.register(noneResponseHandler); + export { noneResponseHandler }; diff --git a/src/ui/public/vis/response_handlers/tabify.js b/src/ui/public/vis/response_handlers/tabify.js deleted file mode 100644 index 843ee4684616d..0000000000000 --- a/src/ui/public/vis/response_handlers/tabify.js +++ /dev/null @@ -1,22 +0,0 @@ -import { AggResponseIndexProvider } from 'ui/agg_response/index'; - -const TabifyResponseHandlerProvider = function (Private) { - const aggResponse = Private(AggResponseIndexProvider); - - return { - name: 'tabify', - handler: function (vis, response) { - return new Promise((resolve) => { - - const tableGroup = aggResponse.tabify(vis, response, { - canSplit: true, - asAggConfigResults: true - }); - - resolve(tableGroup); - }); - } - }; -}; - -export { TabifyResponseHandlerProvider }; diff --git a/src/ui/ui_exports.js b/src/ui/ui_exports.js index c67eeed86a9a6..02007b74d0b8d 100644 --- a/src/ui/ui_exports.js +++ b/src/ui/ui_exports.js @@ -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); @@ -91,6 +102,10 @@ export default class UiExports { }; case 'visTypes': + case 'visResponseHandlers': + case 'visRequestHandlers': + case 'visEditorTypes': + case 'savedObjectTypes': case 'fieldFormats': case 'fieldFormatEditors': case 'spyModes':