Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into migrate-share-reg…
Browse files Browse the repository at this point in the history
…istry
  • Loading branch information
flash1293 committed Nov 14, 2019
2 parents 6f3f802 + 4f88819 commit af106e0
Show file tree
Hide file tree
Showing 145 changed files with 1,255 additions and 1,197 deletions.
1 change: 0 additions & 1 deletion .sass-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ files:
include:
- 'src/legacy/core_plugins/metrics/**/*.s+(a|c)ss'
- 'src/legacy/core_plugins/timelion/**/*.s+(a|c)ss'
- 'src/legacy/ui/public/query_bar/**/*.s+(a|c)ss'
- 'src/legacy/ui/public/vislib/**/*.s+(a|c)ss'
- 'x-pack/legacy/plugins/rollup/**/*.s+(a|c)ss'
- 'x-pack/legacy/plugins/security/**/*.s+(a|c)ss'
Expand Down
2 changes: 1 addition & 1 deletion src/core/MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,7 @@ import { setup, start } from '../core_plugins/visualizations/public/legacy';
| ------------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `import 'ui/apply_filters'` | `import { ApplyFiltersPopover } from '../data/public'` | `import '../data/public/legacy` should be called to load legacy directives |
| `import 'ui/filter_bar'` | `import { FilterBar } from '../data/public'` | `import '../data/public/legacy` should be called to load legacy directives |
| `import 'ui/query_bar'` | `import { QueryBar, QueryBarInput } from '../data/public'` | Directives are deprecated. |
| `import 'ui/query_bar'` | `import { QueryBarInput } from '../data/public'` | Directives are deprecated. |
| `import 'ui/search_bar'` | `import { SearchBar } from '../data/public'` | Directive is deprecated. |
| `import 'ui/kbn_top_nav'` | `import { TopNavMenu } from '../navigation/public'` | Directive is still available in `ui/kbn_top_nav`. |
| `ui/saved_objects/components/saved_object_finder` | `import { SavedObjectFinder } from '../kibana_react/public'` | |
Expand Down
3 changes: 0 additions & 3 deletions src/legacy/core_plugins/console/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export default function(kibana: any) {
const npSrc = resolve(__dirname, 'np_ready/public');

let defaultVars: any;
const apps: any[] = [];
return new kibana.Plugin({
id: 'console',
require: ['elasticsearch'],
Expand Down Expand Up @@ -181,8 +180,6 @@ export default function(kibana: any) {
},

uiExports: {
apps,
hacks: ['plugins/console/quarantined/hacks/register'],
devTools: [`${npSrc}/legacy`],
styleSheetPaths: resolve(__dirname, 'public/quarantined/index.scss'),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function Main() {
};

return (
<>
<div id="consoleRoot">
<EuiFlexGroup
className="consoleContainer"
gutterSize="none"
Expand Down Expand Up @@ -124,6 +124,6 @@ export function Main() {
{showSettings ? <Settings onClose={() => setShowSettings(false)} /> : null}

{showHelp ? <HelpPanel onClose={() => setShowHelp(false)} /> : null}
</>
</div>
);
}
69 changes: 10 additions & 59 deletions src/legacy/core_plugins/console/np_ready/public/legacy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,80 +24,31 @@ import 'brace/mode/json';
import 'brace/mode/text';

/* eslint-disable @kbn/eslint/no-restricted-paths */
import { toastNotifications as notifications } from 'ui/notify';
import { npSetup, npStart } from 'ui/new_platform';
import uiRoutes from 'ui/routes';
import { DOC_LINK_VERSION } from 'ui/documentation_links';
import { I18nContext } from 'ui/i18n';
import { ResizeChecker } from 'ui/resize_checker';
import 'ui/capabilities/route_setup';
/* eslint-enable @kbn/eslint/no-restricted-paths */

import template from '../../public/quarantined/index.html';
import { App, AppUnmount, NotificationsSetup } from '../../../../../core/public';

export interface XPluginSet {
devTools: DevToolsSetup;
feature_catalogue: FeatureCatalogueSetup;
__LEGACY: {
I18nContext: any;
ResizeChecker: any;
docLinkVersion: string;
};
}

import { plugin } from '.';
import { DevToolsSetup } from '../../../../../plugins/dev_tools/public';
import { FeatureCatalogueSetup } from '../../../../../plugins/feature_catalogue/public';

const pluginInstance = plugin({} as any);

const anyObject = {} as any;

uiRoutes.when('/dev_tools/console', {
requireUICapability: 'dev_tools.show',
controller: function RootController($scope) {
// Stub out this config for now...
$scope.topNavMenu = [];

$scope.initReactApp = () => {
const targetElement = document.querySelector<HTMLDivElement>('#consoleRoot');
if (!targetElement) {
const message = `Could not mount Console App!`;
npSetup.core.fatalErrors.add(message);
throw new Error(message);
}

let unmount: AppUnmount | Promise<AppUnmount>;

const mockedSetupCore = {
...npSetup.core,
notifications: (notifications as unknown) as NotificationsSetup,
application: {
register(app: App): void {
try {
unmount = app.mount(anyObject, { element: targetElement, appBasePath: '' });
} catch (e) {
npSetup.core.fatalErrors.add(e);
}
},
registerMountContext() {},
},
};

pluginInstance.setup(mockedSetupCore, {
...npSetup.plugins,
__LEGACY: {
I18nContext,
ResizeChecker,
docLinkVersion: DOC_LINK_VERSION,
},
});
pluginInstance.start(npStart.core);

$scope.$on('$destroy', async () => {
if (unmount) {
const fn = await unmount;
fn();
}
});
};
pluginInstance.setup(npSetup.core, {
...npSetup.plugins,
__LEGACY: {
I18nContext,
ResizeChecker,
},
template,
});
pluginInstance.start(npStart.core);
43 changes: 36 additions & 7 deletions src/legacy/core_plugins/console/np_ready/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,55 @@
*/

import { render, unmountComponentAtNode } from 'react-dom';
import { i18n } from '@kbn/i18n';

import { FeatureCatalogueCategory } from 'ui/registry/feature_catalogue';
import { PluginInitializerContext, Plugin, CoreStart, CoreSetup } from '../../../../../core/public';
import { XPluginSet } from './legacy';
import { boot } from './application';

export class ConsoleUIPlugin implements Plugin<any, any> {
// @ts-ignore
constructor(private readonly ctx: PluginInitializerContext) {}

async setup({ application, notifications }: CoreSetup, pluginSet: XPluginSet) {
async setup({ notifications }: CoreSetup, pluginSet: XPluginSet) {
const {
__LEGACY: { docLinkVersion, I18nContext, ResizeChecker },
__LEGACY: { I18nContext, ResizeChecker },
devTools,
feature_catalogue,
} = pluginSet;

application.register({
feature_catalogue.register({
id: 'console',
title: i18n.translate('console.devToolsTitle', {
defaultMessage: 'Console',
}),
description: i18n.translate('console.devToolsDescription', {
defaultMessage: 'Skip cURL and use this JSON interface to work with your data directly.',
}),
icon: 'consoleApp',
path: '/app/kibana#/dev_tools/console',
showOnHomePage: true,
category: FeatureCatalogueCategory.ADMIN,
});

devTools.register({
id: 'console',
order: 1,
title: 'Console',
mount(ctx, { element }) {
render(boot({ docLinkVersion, I18nContext, ResizeChecker, notifications }), element);
title: i18n.translate('console.consoleDisplayName', {
defaultMessage: 'Console',
}),
enableRouting: false,
async mount(ctx, { element }) {
const { boot } = await import('./application');
render(
boot({
docLinkVersion: ctx.core.docLinks.DOC_LINK_VERSION,
I18nContext,
ResizeChecker,
notifications,
}),
element
);
return () => {
unmountComponentAtNode(element);
};
Expand Down
3 changes: 0 additions & 3 deletions src/legacy/core_plugins/console/public/quarantined/index.html

This file was deleted.

2 changes: 1 addition & 1 deletion src/legacy/core_plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export {
IndexPatterns,
StaticIndexPattern,
} from './index_patterns';
export { Query, QueryBarInput } from './query';
export { QueryBarInput } from './query';
export { SearchBar, SearchBarProps, SavedQueryAttributes, SavedQuery } from './search';

/** @public static code */
Expand Down
2 changes: 0 additions & 2 deletions src/legacy/core_plugins/data/public/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,10 @@
*/

import { indexPatternsServiceMock } from './index_patterns/index_patterns_service.mock';
import { queryServiceMock } from './query/query_service.mock';

function createDataSetupMock() {
return {
indexPatterns: indexPatternsServiceMock.createSetupContract(),
query: queryServiceMock.createSetupContract(),
};
}

Expand Down
6 changes: 0 additions & 6 deletions src/legacy/core_plugins/data/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import { CoreSetup, CoreStart, Plugin } from 'kibana/public';
import { SearchService, SearchStart, createSearchBar, StatetfulSearchBarProps } from './search';
import { QueryService, QuerySetup } from './query';
import { IndexPatternsService, IndexPatternsSetup, IndexPatternsStart } from './index_patterns';
import { Storage, IStorageWrapper } from '../../../../../src/plugins/kibana_utils/public';
import { DataPublicPluginStart } from '../../../../plugins/data/public';
Expand All @@ -42,7 +41,6 @@ export interface DataPluginStartDependencies {
* @public
*/
export interface DataSetup {
query: QuerySetup;
indexPatterns: IndexPatternsSetup;
}

Expand All @@ -52,7 +50,6 @@ export interface DataSetup {
* @public
*/
export interface DataStart {
query: QuerySetup;
indexPatterns: IndexPatternsStart;
search: SearchStart;
ui: {
Expand All @@ -74,7 +71,6 @@ export interface DataStart {

export class DataPlugin implements Plugin<DataSetup, DataStart, {}, DataPluginStartDependencies> {
private readonly indexPatterns: IndexPatternsService = new IndexPatternsService();
private readonly query: QueryService = new QueryService();
private readonly search: SearchService = new SearchService();

private setupApi!: DataSetup;
Expand All @@ -85,7 +81,6 @@ export class DataPlugin implements Plugin<DataSetup, DataStart, {}, DataPluginSt

this.setupApi = {
indexPatterns: this.indexPatterns.setup(),
query: this.query.setup(),
};

return this.setupApi;
Expand Down Expand Up @@ -132,7 +127,6 @@ export class DataPlugin implements Plugin<DataSetup, DataStart, {}, DataPluginSt

public stop() {
this.indexPatterns.stop();
this.query.stop();
this.search.stop();
}
}
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/data/public/query/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
* under the License.
*/

export * from './query_service';
export * from './query_bar';
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jest.mock('../../../../../../../plugins/data/public/query/persisted_log', () =>
PersistedLog: mockPersistedLogFactory,
}));

jest.mock('../lib/fetch_index_patterns', () => ({
jest.mock('./fetch_index_patterns', () => ({
fetchIndexPatterns: mockFetchIndexPatterns,
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,22 @@ import {
AutocompleteSuggestion,
AutocompleteSuggestionType,
PersistedLog,
toUser,
fromUser,
matchPairs,
getQueryLog,
Query,
} from '../../../../../../../plugins/data/public';
import {
withKibana,
KibanaReactContextValue,
toMountPoint,
} from '../../../../../../../plugins/kibana_react/public';
import { IndexPattern, StaticIndexPattern } from '../../../index_patterns';
import { Query, getQueryLog } from '../index';
import { fromUser, matchPairs, toUser } from '../lib';
import { QueryLanguageSwitcher } from './language_switcher';
import { SuggestionsComponent } from './typeahead/suggestions_component';
import { fetchIndexPatterns } from '../lib/fetch_index_patterns';
import { IDataPluginServices } from '../../../types';
import { fetchIndexPatterns } from './fetch_index_patterns';

interface Props {
kibana: KibanaReactContextValue<IDataPluginServices>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@ import {
import { EuiSuperUpdateButton, OnRefreshProps } from '@elastic/eui';
import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react';
import { Toast } from 'src/core/public';
import { TimeRange, TimeHistoryContract } from 'src/plugins/data/public';
import {
TimeRange,
TimeHistoryContract,
Query,
PersistedLog,
getQueryLog,
} from '../../../../../../../plugins/data/public';
import { useKibana, toMountPoint } from '../../../../../../../plugins/kibana_react/public';
import { PersistedLog } from '../../../../../../../plugins/data/public';

import { IndexPattern } from '../../../index_patterns';
import { QueryBarInput } from './query_bar_input';
import { Query, getQueryLog } from '../index';
import { IDataPluginServices } from '../../../types';

interface Props {
Expand Down
6 changes: 0 additions & 6 deletions src/legacy/core_plugins/data/public/query/query_bar/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,3 @@

export { QueryBarTopRow } from './components/query_bar_top_row';
export { QueryBarInput } from './components/query_bar_input';

export { fromUser } from './lib/from_user';
export { toUser } from './lib/to_user';
export { getQueryLog } from './lib/get_query_log';

export { Query } from '../../../../../../plugins/data/public';
Loading

0 comments on commit af106e0

Please sign in to comment.