Skip to content

Commit

Permalink
Add basic NP structure, structural refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
kertal committed Oct 14, 2019
1 parent fd7e81b commit 1cbd678
Show file tree
Hide file tree
Showing 27 changed files with 215 additions and 108 deletions.
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/kibana/public/discover/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@import 'components/fetch_error/index';
@import 'components/field_chooser/index';
@import 'legacy/directives/index';
@import 'angular/directives/index';
@import 'doc_table/index';

@import 'hacks';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,12 @@
*/

import _ from 'lodash';
import { FilterBarQueryFilterProvider, uiRoutes, i18n, subscribeWithScope } from './dependencies';
import { npStart } from 'ui/new_platform';

import { FilterBarQueryFilterProvider } from 'ui/filter_manager/query_filter';
import uiRoutes from 'ui/routes';
import { i18n } from '@kbn/i18n';

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 k7Breadcrumbs = $route => {
const { indexPattern } = $route.current.locals;
Expand All @@ -47,12 +43,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
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,22 @@
*/

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 { callAfterBindingsWorkaround, uiModules, timefilter } from './dependencies';
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';


// load directives
import '../../../../data/public/legacy';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import 'ui/collapsible_sidebar';
import 'ui/directives/listen';
import 'ui/visualize';
import 'ui/fixed_scroll';
import 'ui/index_patterns';
import 'ui/state_management/app_state';
import 'ui/capabilities/route_setup';

import uiRoutes from 'ui/routes';
export { uiRoutes };
// @ts-ignore
export { uiModules } from 'ui/modules';
export { IndexPatterns } from 'ui/index_patterns';
export { wrapInI18nContext } from 'ui/i18n';
export { timefilter } from 'ui/timefilter';
export { FilterBarQueryFilterProvider } from 'ui/filter_manager/query_filter';
export { i18n } from '@kbn/i18n';
export { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
// @ts-ignore
export { callAfterBindingsWorkaround } from 'ui/compat';

import './directives';
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ import { getSortForSearchSource } from '../doc_table/lib/get_sort_for_search_sou
import * as columnActions from '../doc_table/actions/columns';
import * as filterActions from '../doc_table/actions/filter';

import 'ui/directives/listen';
import 'ui/visualize';
import 'ui/fixed_scroll';
import 'ui/index_patterns';
import 'ui/state_management/app_state';
import indexTemplate from './discover.html';
import { showOpenSearchPanel } from '../top_nav/show_open_search_panel';
import { addHelpMenuToAppChrome } from '../components/help_menu/help_menu_util';
import '../components/fetch_error';
import { getPainlessError } from './get_painless_error';

import { npStart } from 'ui/new_platform';
import { timefilter } from 'ui/timefilter';
import { hasSearchStategyForIndexPattern, isDefaultTypeIndexPattern } from 'ui/courier';
import { toastNotifications } from 'ui/notify';
Expand All @@ -49,32 +51,26 @@ import { intervalOptions } from 'ui/agg_types/buckets/_interval_options';
import { stateMonitorFactory } from 'ui/state_management/state_monitor_factory';
import uiRoutes from 'ui/routes';
import { uiModules } from 'ui/modules';
import indexTemplate from '../index.html';
import { StateProvider } from 'ui/state_management/state';
import { migrateLegacyQuery } from 'ui/utils/migrate_legacy_query';
import { subscribeWithScope } from 'ui/utils/subscribe_with_scope';
import { getFilterGenerator } from 'ui/filter_manager';

import { getDocLink } from 'ui/documentation_links';
import '../components/fetch_error';
import { getPainlessError } from './get_painless_error';
import { showShareContextMenu, ShareContextMenuExtensionsRegistryProvider } from 'ui/share';
import { getUnhashableStatesProvider } from 'ui/state_management/state_hashing';
import { Inspector } from 'ui/inspector';
import { RequestAdapter } from 'ui/inspector/adapters';
import { getRequestInspectorStats, getResponseInspectorStats } from 'ui/courier/utils/courier_inspector_utils';
import { showOpenSearchPanel } from '../top_nav/show_open_search_panel';
import { tabifyAggResponse } from 'ui/agg_response/tabify';
import { showSaveModal } from 'ui/saved_objects/show_saved_object_save_modal';
import { SavedObjectSaveModal } from 'ui/saved_objects/components/saved_object_save_modal';
import { getRootBreadcrumbs, getSavedSearchBreadcrumbs } from '../breadcrumbs';
import { buildVislibDimensions } from 'ui/visualize/loader/pipeline_helpers/build_pipeline';
import 'ui/capabilities/route_setup';
import { addHelpMenuToAppChrome } from '../components/help_menu/help_menu_util';


import { extractTimeFilter, changeTimeFilter } from '../../../../data/public';
import { start as data } from '../../../../data/public/legacy';
import { npStart } from 'ui/new_platform';


const { savedQueryService } = data.search.services;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,25 @@
* specific language governing permissions and limitations
* under the License.
*/
import uiRoutes from 'ui/routes';
import { IndexPatterns } from 'ui/index_patterns';
import { timefilter } from 'ui/timefilter';
import { uiRoutes, uiModules, wrapInI18nContext, timefilter, IndexPatterns } from './dependencies';
// @ts-ignore
import { getRootBreadcrumbs } from 'plugins/kibana/discover/breadcrumbs';
// @ts-ignore
import html from './index.html';
import './doc_directive';
import { getRootBreadcrumbs } from '../breadcrumbs';
import html from './doc.html';
import { Doc } from '../doc/doc';

uiModules.get('apps/discover').directive('discoverDoc', function(reactDirective: any) {
return reactDirective(
wrapInI18nContext(Doc),
[
['id', { watchDepth: 'value' }],
['index', { watchDepth: 'value' }],
['indexPatternId', { watchDepth: 'reference' }],
['indexPatternService', { watchDepth: 'reference' }],
['esClient', { watchDepth: 'reference' }],
],
{ restrict: 'E' }
);
});

uiRoutes
// the old, pre 8.0 route, no longer used, keep it to stay compatible
Expand Down
22 changes: 22 additions & 0 deletions src/legacy/core_plugins/kibana/public/discover/angular/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import './dependencies';
import './discover';
import './doc';
import './context';
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ export function getRootBreadcrumbs() {
return [
{
text: i18n.translate('kbn.discover.rootBreadcrumb', {
defaultMessage: 'Discover'
defaultMessage: 'Discover',
}),
href: '#/discover'
}
href: '#/discover',
},
];
}

export function getSavedSearchBreadcrumbs($route) {
export function getSavedSearchBreadcrumbs($route: any) {
return [
...getRootBreadcrumbs(),
{
text: $route.current.locals.savedSearch.id,
}
},
];
}
46 changes: 0 additions & 46 deletions src/legacy/core_plugins/kibana/public/discover/index.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
import { wrapInI18nContext } from 'ui/i18n';
// @ts-ignore
import { uiModules } from 'ui/modules';
import { Doc } from './doc';
import { PluginInitializer, PluginInitializerContext } from 'kibana/public';
import { DiscoverPlugin, DiscoverSetup, DiscoverStart } from './plugin';

uiModules.get('apps/discover').directive('discoverDoc', function(reactDirective: any) {
return reactDirective(
wrapInI18nContext(Doc),
[
['id', { watchDepth: 'value' }],
['index', { watchDepth: 'value' }],
['indexPatternId', { watchDepth: 'reference' }],
['indexPatternService', { watchDepth: 'reference' }],
['esClient', { watchDepth: 'reference' }],
],
{ restrict: 'E' }
);
});
// Core will be looking for this when loading our plugin in the new platform
export const plugin: PluginInitializer<DiscoverSetup, DiscoverStart> = (
initializerContext: PluginInitializerContext
) => {
return new DiscoverPlugin(initializerContext);
};
25 changes: 25 additions & 0 deletions src/legacy/core_plugins/kibana/public/discover/legacy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { npSetup, npStart } from 'ui/new_platform';
import { PluginInitializerContext } from 'kibana/public';
import { plugin } from './index';

const pluginInstance = plugin({} as PluginInitializerContext);
export const setup = pluginInstance.setup(npSetup.core, npSetup.plugins);
export const start = pluginInstance.start(npStart.core, npStart.plugins);
Loading

0 comments on commit 1cbd678

Please sign in to comment.