Skip to content

Commit

Permalink
Consolidate kibana services in NP
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Caldwell committed Apr 14, 2020
1 parent ca40d71 commit 4e3ed3a
Show file tree
Hide file tree
Showing 25 changed files with 136 additions and 167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import _ from 'lodash';
import { KibanaTilemapSource } from '../../../../../plugins/maps/public/layers/sources/kibana_tilemap_source';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { EMSTMSSource } from '../../../../../plugins/maps/public/layers/sources/ems_tms_source';
import { getInjectedVarFunc } from '../kibana_services';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { getInjectedVarFunc } from '../../../../../plugins/maps/public/kibana_services';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { getKibanaTileMap } from '../../../../../plugins/maps/public/meta';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const layerListNotProvided = undefined;

describe('Saved object has layer list', () => {
beforeEach(() => {
require('../kibana_services').getInjectedVarFunc = () => jest.fn();
require('../../../../../plugins/maps/public/kibana_services').getInjectedVarFunc = () =>
jest.fn();
});

it('Should get initial layers from saved object', () => {
Expand Down Expand Up @@ -65,7 +66,7 @@ describe('EMS is enabled', () => {
require('../../../../../plugins/maps/public/meta').getKibanaTileMap = () => {
return null;
};
require('../kibana_services').getInjectedVarFunc = () => key => {
require('../../../../../plugins/maps/public/kibana_services').getInjectedVarFunc = () => key => {
switch (key) {
case 'emsTileLayerId':
return {
Expand Down Expand Up @@ -110,7 +111,7 @@ describe('EMS is not enabled', () => {
return null;
};

require('../kibana_services').getInjectedVarFunc = () => key => {
require('../../../../../plugins/maps/public/kibana_services').getInjectedVarFunc = () => key => {
switch (key) {
case 'isEmsEnabled':
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { getUiSettings } from '../kibana_services';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { getUiSettings } from '../../../../../plugins/maps/public/kibana_services';

export function getInitialQuery({ mapStateJSON, appState = {}, userQueryLanguage }) {
const settings = getUiSettings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { getUiSettings } from '../kibana_services';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { getUiSettings } from '../../../../../plugins/maps/public/kibana_services';

export function getInitialRefreshConfig({ mapStateJSON, globalState = {} }) {
const uiSettings = getUiSettings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { getUiSettings } from '../kibana_services';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { getUiSettings } from '../../../../../plugins/maps/public/kibana_services';

export function getInitialTimeFilters({ mapStateJSON, globalState = {} }) {
if (mapStateJSON) {
Expand Down
11 changes: 4 additions & 7 deletions x-pack/legacy/plugins/maps/public/angular/map_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ import {
getCoreI18n,
getCoreChrome,
getMapsCapabilities,
} from '../kibana_services';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { getToasts } from '../../../../../plugins/maps/public/kibana_services';
import { Provider } from 'react-redux';
getToasts,
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
} from '../../../../../plugins/maps/public/kibana_services';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { createMapStore } from '../../../../../plugins/maps/public/reducers/store';
import { Provider } from 'react-redux';
import { GisMap } from '../connected_components/gis_map';
import { addHelpMenuToAppChrome } from '../help_menu_util';
import {
Expand Down Expand Up @@ -72,7 +72,6 @@ import {
showSaveModal,
} from '../../../../../../src/plugins/saved_objects/public';
import { loadKbnTopNavDirectives } from '../../../../../../src/plugins/kibana_legacy/public';
import { bindSetupCoreAndPlugins, bindStartCoreAndPlugins } from '../plugin';
import {
bindSetupCoreAndPlugins as bindNpSetupCoreAndPlugins,
bindStartCoreAndPlugins as bindNpStartCoreAndPlugins,
Expand All @@ -83,9 +82,7 @@ const REACT_ANCHOR_DOM_ELEMENT_ID = 'react-maps-root';
const app = uiModules.get(MAP_APP_PATH, []);

// Init required services. Necessary while in legacy
bindSetupCoreAndPlugins(npSetup.core, npSetup.plugins);
bindNpSetupCoreAndPlugins(npSetup.core, npSetup.plugins);
bindStartCoreAndPlugins(npStart.core, npStart.plugins);
bindNpStartCoreAndPlugins(npStart.core, npStart.plugins);

loadKbnTopNavDirectives(getNavigation().ui);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
getIndexPatternService,
getCoreOverlays,
getData,
} from '../../kibana_services';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
} from '../../../../../../plugins/maps/public/kibana_services';

export const getMapsSavedObjectLoader = _.once(function() {
const services = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ import {

import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import { getIndexPatternService, getUiSettings, getData } from '../../../kibana_services';
import {
getIndexPatternService,
getUiSettings,
getData,
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
} from '../../../../../../../plugins/maps/public/kibana_services';
import { GlobalFilterCheckbox } from '../../../components/global_filter_checkbox';

export class FilterEditor extends Component {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import { WhereExpression } from './where_expression';
import { GlobalFilterCheckbox } from '../../../../components/global_filter_checkbox';

import { indexPatterns } from '../../../../../../../../../src/plugins/data/public';
import { getIndexPatternService } from '../../../../kibana_services';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { getIndexPatternService } from '../../../../../../../../plugins/maps/public/kibana_services';

export class Join extends Component {
state = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ import { getTermsFields } from '../../../../../../../../plugins/maps/public/inde
import {
getIndexPatternService,
getIndexPatternSelectComponent,
} from '../../../../kibana_services';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
} from '../../../../../../../../plugins/maps/public/kibana_services';

export class JoinExpression extends Component {
state = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import React, { Component } from 'react';
import { i18n } from '@kbn/i18n';
import { EuiButton, EuiPopover, EuiExpression, EuiFormHelpText } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { getUiSettings, getData } from '../../../../kibana_services';
import {
getUiSettings,
getData,
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
} from '../../../../../../../../plugins/maps/public/kibana_services';

export class WhereExpression extends Component {
state = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { KibanaContextProvider } from '../../../../../../../src/plugins/kibana_react/public';
import { Storage } from '../../../../../../../src/plugins/kibana_utils/public';
import { getData, getCore } from '../../kibana_services';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { getData, getCore } from '../../../../../../plugins/maps/public/kibana_services';

const localStorage = new Storage(window.localStorage);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import {
clampToLonBounds,
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
} from '../../../../../../../plugins/maps/public/elasticsearch_geo_utils';
import { getInjectedVarFunc } from '../../../kibana_services';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { getInjectedVarFunc } from '../../../../../../../plugins/maps/public/kibana_services';

mapboxgl.workerUrl = mbWorkerUrl;
mapboxgl.setRTLTextPlugin(mbRtlPlugin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ import { getMapCenter, getMapZoom, getHiddenLayerIds } from '../selectors/map_se
import { MAP_SAVED_OBJECT_TYPE } from '../../common/constants';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { RenderToolTipContent } from '../../../../../plugins/maps/public/layers/tooltips/tooltip_property';
import { getUiActions } from '../kibana_services';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { getUiActions } from '../../../../../plugins/maps/public/kibana_services';

interface MapEmbeddableConfig {
editUrl?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import { npSetup, npStart } from 'ui/new_platform';
import { IIndexPattern } from 'src/plugins/data/public';
import { getMapsSavedObjectLoader } from '../angular/services/gis_map_saved_object_loader';
import { MapEmbeddable, MapEmbeddableInput } from './map_embeddable';
import { getIndexPatternService, getHttp, getMapsCapabilities } from '../kibana_services';
import {
getIndexPatternService,
getHttp,
getMapsCapabilities,
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
} from '../../../../../plugins/maps/public/kibana_services';
import {
EmbeddableFactoryDefinition,
IContainer,
Expand All @@ -24,7 +29,6 @@ import { getQueryableUniqueIndexPatternIds } from '../selectors/map_selectors';
import { getInitialLayers } from '../angular/get_initial_layers';
import { mergeInputWithSavedMap } from './merge_input_with_saved_map';
import '../angular/services/gis_map_saved_object_loader';
import { bindSetupCoreAndPlugins, bindStartCoreAndPlugins } from '../plugin';
// @ts-ignore
import {
bindSetupCoreAndPlugins as bindNpSetupCoreAndPlugins,
Expand All @@ -42,9 +46,7 @@ export class MapEmbeddableFactory implements EmbeddableFactoryDefinition {
};
constructor() {
// Init required services. Necessary while in legacy
bindSetupCoreAndPlugins(npSetup.core, npSetup.plugins);
bindNpSetupCoreAndPlugins(npSetup.core, npSetup.plugins);
bindStartCoreAndPlugins(npStart.core, npStart.plugins);
bindNpStartCoreAndPlugins(npStart.core, npStart.plugins);
}

Expand Down
3 changes: 2 additions & 1 deletion x-pack/legacy/plugins/maps/public/help_menu_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { getDocLinks, getCoreChrome } from './kibana_services';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { getDocLinks, getCoreChrome } from '../../../../plugins/maps/public/kibana_services';

export function addHelpMenuToAppChrome() {
const { ELASTIC_WEBSITE_URL, DOC_LINK_VERSION } = getDocLinks();
Expand Down
3 changes: 2 additions & 1 deletion x-pack/legacy/plugins/maps/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import './kibana_services';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import '../../../../plugins/maps/public/kibana_services';

// import the uiExports that we want to "use"
import 'uiExports/inspectorViews';
Expand Down
83 changes: 0 additions & 83 deletions x-pack/legacy/plugins/maps/public/kibana_services.js

This file was deleted.

Loading

0 comments on commit 4e3ed3a

Please sign in to comment.