Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move response/request and editor handler registration to uiExports #12766

Merged
merged 2 commits into from
Jul 13, 2017
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
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';

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might be problematic ....
right now someone might import the default editor (or any of the other things registered) into his code, which will register a duplicate with registryProvider ? (not sure does registryProvider allow duplicates ? what will happen in that case?) should either check for this scenario, or not export anything (so importing of this module is not possible, it should only be accessed thru registry

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Importing the module won't cause the code to execute twice. As long as the register call is only in one place it will be fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way, there shouldn't be any reason to import the default editor, ideally consumers will only import the editors register and depend on all editors so that they can be pluggable. If consumers import a specific editor they aren't pluggable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same is true for requestHandlers and responseHandlers

const defaultEditor = function ($rootScope, $compile) {
return class DefaultEditor {
static key = 'default';
Expand Down Expand Up @@ -99,4 +100,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 @@ -48,4 +50,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