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

[Discover] Centralize dependencies in kibana_services.ts #48072

Merged
merged 52 commits into from
Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
6046c50
Move doc folder to discover folder
kertal Oct 7, 2019
16a7a6a
Move doc_viewer folder to discover folder
kertal Oct 7, 2019
522db68
Move context folder to discover folder
kertal Oct 7, 2019
6ca152e
Move context scss import to discover folder
kertal Oct 7, 2019
3c762b7
Introduce legacy folder, start migration
kertal Oct 7, 2019
fd7e81b
Merge remote-tracking branch 'upstream/master' into kertal-pr-2019-10…
kertal Oct 13, 2019
1cbd678
Add basic NP structure, structural refactoring
kertal Oct 14, 2019
fdbdde0
Migrate discover imports to dependencies.ts
kertal Oct 15, 2019
9fe6e84
Add context placeholder readme
kertal Oct 15, 2019
9ac64ac
Move doc_viewer directive to angular
kertal Oct 15, 2019
e65ae78
Move doc_table directive to angular directory
kertal Oct 15, 2019
2af2593
Migrate doc_table dependencies to central file
kertal Oct 15, 2019
09e2c22
Migrate chrome usage to new platform
kertal Oct 15, 2019
b5aa43c
fix merge conflixts
kertal Oct 21, 2019
4424545
Refactor dependencies.ts to kibana_services.ts
kertal Oct 21, 2019
7ee29c6
Improve basic plugin structure
kertal Oct 21, 2019
0f6c147
Merge remote-tracking branch 'upstream/master' into kertal-pr-2019-10…
kertal Oct 21, 2019
dbdb5d2
Merge remote-tracking branch 'upstream/master' into kertal-pr-2019-10…
kertal Oct 22, 2019
001fcd5
Merge remote-tracking branch 'upstream/master' into kertal-pr-2019-10…
kertal Oct 22, 2019
b0d0a04
Centralize context deps
kertal Oct 22, 2019
103a8f2
Centralize embeddable deps
kertal Oct 22, 2019
d824612
Migrate context to angular folder
kertal Oct 22, 2019
fa25ee7
Refactor adding getServices to kibana_services.ts
kertal Oct 22, 2019
162d14d
Replace npStart usage by getService usage
kertal Oct 22, 2019
40ed5e4
Cleanup / centralize leftover dependencies
kertal Oct 22, 2019
72bfb43
Merge remote-tracking branch 'upstream/master' into kertal-pr-2019-10…
kertal Oct 22, 2019
ae9ae7e
Fix no_results.test.js
kertal Oct 23, 2019
be9fc5a
Fix SCSS import paths
kertal Oct 23, 2019
46a0cca
Restructure kibana_services.ts
kertal Oct 23, 2019
de9fcbf
Fix no_results.test.js
kertal Oct 23, 2019
2337329
Move field_name directive back to field_chooser
kertal Oct 23, 2019
77ab276
Fix open_search_panel.test.js
kertal Oct 23, 2019
293365e
Skip doc_viewer tests (unskip later)
kertal Oct 23, 2019
6dc3a71
Merge remote-tracking branch 'upstream/master' into kertal-pr-2019-10…
kertal Oct 23, 2019
7e88216
Merge remote-tracking branch 'upstream/master' into kertal-pr-2019-10…
kertal Oct 23, 2019
80351b5
Merge remote-tracking branch 'upstream/master' into kertal-pr-2019-10…
kertal Oct 23, 2019
8ab13d7
Separate services from stateless dependencies
kertal Oct 23, 2019
889b771
Merge remote-tracking branch 'upstream/master' into kertal-pr-2019-10…
kertal Oct 23, 2019
7f324d2
unskip doc_viewer.test.tsx
kertal Oct 23, 2019
ca5cdb7
Restore the initial way embeddables are registered
kertal Oct 23, 2019
0388c48
Remove TODOs from doc_viewer.test.tsx
kertal Oct 23, 2019
9407bbb
Refactor SEARCH_EMBEDDABLE_TYPE to contants.ts
kertal Oct 23, 2019
66a4651
Fix open_search_panel.test.js
kertal Oct 23, 2019
b1e71fe
Change import of SEARCH_EMBEDDABLE_TYPE to fix x-pack test failures
kertal Oct 23, 2019
07287af
Fix doc.test.tsx
kertal Oct 24, 2019
01f815b
Fix doc.test.tsx
kertal Oct 24, 2019
0e8bb19
Add embeddable comments
kertal Oct 24, 2019
c8efbe2
Add addBasePath + getInjector to services
kertal Oct 24, 2019
006dbba
Refactor embeddable registration
kertal Oct 24, 2019
ad9a65a
Merge branch 'master' into kertal-pr-2019-10-10-np-basic-structure
elasticmachine Oct 25, 2019
1716413
Restore original embeddable registration
kertal Oct 25, 2019
eddbedd
Merge branch 'kertal-pr-2019-10-10-np-basic-structure' of github.com:…
kertal Oct 25, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import _ from 'lodash';
import sinon from 'sinon';
import ngMock from 'ng_mock';
import expect from '@kbn/expect';
import 'ui/private';
import '../../components/field_chooser/discover_field';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import _ from 'lodash';
import ngMock from 'ng_mock';
import { fieldCalculator } from '../../components/field_chooser/lib/field_calculator';
import expect from '@kbn/expect';
import 'ui/private';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';

// Load the kibana app dependencies.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import _ from 'lodash';
import sinon from 'sinon';
import expect from '@kbn/expect';
import $ from 'jquery';
import 'ui/private';
import '../../components/field_chooser/field_chooser';
import FixturesHitsProvider from 'fixtures/hits';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
Expand Down
4 changes: 2 additions & 2 deletions src/legacy/core_plugins/kibana/public/discover/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@import 'components/fetch_error/index';
@import 'components/field_chooser/index';
@import 'angular/directives/index';
@import 'doc_table/index';
@import 'angular/doc_table/index';

@import 'hacks';

Expand All @@ -23,4 +23,4 @@
@import 'doc_viewer/index';

// Context styles
@import 'context/index';
@import 'angular/context/index';
Copy link
Member Author

Choose a reason for hiding this comment

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

Dear @elastic/kibana-design , valued owner and ruler of the 7 SCSS code kingdoms
There were just path changes in this PR.
Your humble servant
@kertal

Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@
*/

import _ from 'lodash';

import { FilterBarQueryFilterProvider } from 'ui/filter_manager/query_filter';
import uiRoutes from 'ui/routes';
import { i18n } from '@kbn/i18n';
import { getServices, subscribeWithScope } from './../kibana_services';

import './app';
import contextAppRouteTemplate from './index.html';
import './context_app';
import contextAppRouteTemplate from './context.html';
import { getRootBreadcrumbs } from '../breadcrumbs';
import { npStart } from 'ui/new_platform';
import { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
const { FilterBarQueryFilterProvider, uiRoutes, chrome } = getServices();

const k7Breadcrumbs = $route => {
const { indexPattern } = $route.current.locals;
Expand All @@ -47,12 +44,11 @@ const k7Breadcrumbs = $route => {
];
};


uiRoutes
// deprecated route, kept for compatibility
// should be removed in the future
.when('/context/:indexPatternId/:type/:id*', {
redirectTo: '/context/:indexPatternId/:id'
redirectTo: '/context/:indexPatternId/:id',
})
.when('/context/:indexPatternId/:id*', {
controller: ContextAppRouteController,
Expand Down Expand Up @@ -92,7 +88,7 @@ function ContextAppRouteController($routeParams, $scope, AppState, config, index
});
this.anchorId = $routeParams.id;
this.indexPattern = indexPattern;
this.discoverUrl = npStart.core.chrome.navLinks.get('kibana:discover').url;
this.discoverUrl = chrome.navLinks.get('kibana:discover').url;
this.filters = _.cloneDeep(queryFilter.getFilters());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import sinon from 'sinon';
import moment from 'moment';
import { SearchSource } from 'ui/courier';
import { SearchSource } from '../../../../kibana_services';

export function createIndexPatternsStub() {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
*/

import _ from 'lodash';

import { i18n } from '@kbn/i18n';
import { getServices } from '../../../kibana_services';

import { SearchSource } from 'ui/courier';

const { SearchSource } = getServices();
export function fetchAnchorProvider(indexPatterns) {
return async function fetchAnchor(
indexPatternId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
* under the License.
*/

// @ts-ignore
import { SearchSource } from 'ui/courier';
import { Filter } from '@kbn/es-query';
import { IndexPatterns, IndexPattern } from 'ui/index_patterns';
import { IndexPatterns, IndexPattern, getServices } from '../../../kibana_services';
import { reverseSortDir, SortDirection } from './utils/sorting';
import { extractNanos, convertIsoToMillis } from './utils/date_conversion';
import { fetchHitsInInterval } from './utils/fetch_hits_in_interval';
Expand All @@ -36,6 +34,8 @@ export interface EsHitRecord {
}
export type EsHitRecordList = EsHitRecord[];

const { SearchSource } = getServices();

const DAY_MILLIS = 24 * 60 * 60 * 1000;

// look from 1 day up to 10000 days into the past and future
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { SearchSource } from 'ui/courier';
import { SearchSource } from '../../../../kibana_services';
import { convertTimeValueToIso } from './date_conversion';
import { SortDirection } from './sorting';
import { EsHitRecordList } from '../context';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { IndexPattern } from 'src/legacy/core_plugins/data/public';
import { IndexPattern } from '../../../../kibana_services';

export enum SortDirection {
asc = 'asc',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
* specific language governing permissions and limitations
* under the License.
*/
// @ts-ignore
import { uiModules } from 'ui/modules';
import { wrapInI18nContext } from 'ui/i18n';
import { getServices } from '../../../../kibana_services';
import { ActionBar } from './action_bar';

const { uiModules, wrapInI18nContext } = getServices();

uiModules.get('apps/context').directive('contextActionBar', function(reactDirective: any) {
return reactDirective(wrapInI18nContext(ActionBar));
});
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
import _ from 'lodash';
import { i18n } from '@kbn/i18n';
import React from 'react';
import { toastNotifications } from 'ui/notify';
import { toastNotifications } from '../../../kibana_services';

import { fetchAnchorProvider } from '../api/anchor';
import { fetchContextProvider } from '../api/context';
import { QueryParameterActionsProvider } from '../query_parameters';
import { FAILURE_REASONS, LOADING_STATUS } from './constants';
import { MarkdownSimple } from '../../../../../kibana_react/public';
import { MarkdownSimple } from '../../../../../../kibana_react/public';

export function QueryActionsProvider(Private, Promise) {
const fetchAnchor = Private(fetchAnchorProvider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
import expect from '@kbn/expect';
import ngMock from 'ng_mock';
import sinon from 'sinon';

import { FilterBarQueryFilterProvider } from 'ui/filter_manager/query_filter';

import { getServices } from '../../../../kibana_services';
import { createStateStub } from './_utils';
import { QueryParameterActionsProvider } from '../actions';

Expand All @@ -36,7 +34,7 @@ describe('context app', function () {

beforeEach(ngMock.inject(function createPrivateStubs(Private) {
filterManagerStub = createQueryFilterStub();
Private.stub(FilterBarQueryFilterProvider, filterManagerStub);
Private.stub(getServices().FilterBarQueryFilterProvider, filterManagerStub);

addFilter = Private(QueryParameterActionsProvider).addFilter;
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
*/

import _ from 'lodash';
import { getServices, getFilterGenerator } from '../../../kibana_services';

import { FilterBarQueryFilterProvider } from 'ui/filter_manager/query_filter';
import { getFilterGenerator } from 'ui/filter_manager';
import {
MAX_CONTEXT_SIZE,
MIN_CONTEXT_SIZE,
Expand All @@ -29,7 +28,7 @@ import {


export function QueryParameterActionsProvider(indexPatterns, Private) {
const queryFilter = Private(FilterBarQueryFilterProvider);
const queryFilter = Private(getServices().FilterBarQueryFilterProvider);
const filterGen = getFilterGenerator(queryFilter);

const setPredecessorCount = (state) => (predecessorCount) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,23 @@
*/

import _ from 'lodash';

import { callAfterBindingsWorkaround } from 'ui/compat';
import { uiModules } from 'ui/modules';
import contextAppTemplate from './app.html';
import './components/action_bar';
import { getFirstSortableField } from './api/utils/sorting';
import { getServices, callAfterBindingsWorkaround } from './../kibana_services';
import contextAppTemplate from './context_app.html';
import './context/components/action_bar';
import { getFirstSortableField } from './context/api/utils/sorting';
import {
createInitialQueryParametersState,
QueryParameterActionsProvider,
QUERY_PARAMETER_KEYS,
} from './query_parameters';
} from './context/query_parameters';
import {
createInitialLoadingStatusState,
FAILURE_REASONS,
LOADING_STATUS,
QueryActionsProvider,
} from './query';
import { timefilter } from 'ui/timefilter';
} from './context/query';

const { uiModules, timefilter } = getServices();

// load directives
import '../../../../data/public/legacy';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import lightEuiTheme from '@elastic/eui/dist/eui_theme_light.json';
import darkEuiTheme from '@elastic/eui/dist/eui_theme_dark.json';
import { npStart } from 'ui/new_platform';

import {
AnnotationDomainTypes,
Expand All @@ -44,12 +43,9 @@ import {
} from '@elastic/charts';

import { i18n } from '@kbn/i18n';

import chrome from 'ui/chrome';
// @ts-ignore: path dynamic for kibana
import { timezoneProvider } from 'ui/vis/lib/timezone';
import { EuiChartThemeType } from '@elastic/eui/src/themes/charts/themes';
import { Subscription } from 'rxjs';
import { getServices, timezoneProvider } from '../../kibana_services';

export interface DiscoverHistogramProps {
chartData: any;
Expand All @@ -68,12 +64,12 @@ export class DiscoverHistogram extends Component<DiscoverHistogramProps, Discove

private subscription?: Subscription;
public state = {
chartsTheme: npStart.plugins.eui_utils.getChartsThemeDefault(),
chartsTheme: getServices().eui_utils.getChartsThemeDefault(),
};

componentDidMount() {
this.subscription = npStart.plugins.eui_utils
.getChartsTheme$()
this.subscription = getServices()
.eui_utils.getChartsTheme$()
.subscribe(chartsTheme => this.setState({ chartsTheme }));
}

Expand Down Expand Up @@ -145,7 +141,7 @@ export class DiscoverHistogram extends Component<DiscoverHistogramProps, Discove
};

public render() {
const uiSettings = chrome.getUiSettingsClient();
const uiSettings = getServices().uiSettings;
const timeZone = timezoneProvider(uiSettings)();
const { chartData } = this.props;
const { chartsTheme } = this.state;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@
* under the License.
*/

import 'ngreact';
import { wrapInI18nContext } from 'ui/i18n';
import { uiModules } from 'ui/modules';
import '../../../../../../ui/public/render_complete/directive';

import '../../../../../../ui/public/render_complete/directive';
import { DiscoverNoResults } from './no_results';
import { DiscoverUninitialized } from './uninitialized';
import { DiscoverUnsupportedIndexPattern } from './unsupported_index_pattern';
import { DiscoverHistogram } from './histogram';
import { getServices } from '../../kibana_services';

const { wrapInI18nContext, uiModules } = getServices();
const app = uiModules.get('apps/discover', ['react']);

app.directive('discoverNoResults', reactDirective =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,21 @@ import {
EuiSpacer,
EuiText,
} from '@elastic/eui';
import { getServices } from '../../kibana_services';

// eslint-disable-next-line react/prefer-stateless-function
export class DiscoverNoResults extends Component {
static propTypes = {
shardFailures: PropTypes.array,
timeFieldName: PropTypes.string,
queryLanguage: PropTypes.string,
getDocLink: PropTypes.func.isRequired,
};

render() {
const {
shardFailures,
timeFieldName,
queryLanguage,
getDocLink,
} = this.props;

let shardFailuresMessage;
Expand Down Expand Up @@ -226,7 +225,7 @@ export class DiscoverNoResults extends Component {
queryStringSyntaxLink: (
<EuiLink
target="_blank"
href={getDocLink('query.luceneQuerySyntax')}
href={getServices().docLinks.links.query.luceneQuerySyntax}
>
<FormattedMessage
id="kbn.discover.noResults.searchExamples.queryStringSyntaxLinkText"
Expand Down
Loading