Skip to content

Commit

Permalink
Move Lens frontend to Kibana Platform (elastic#62965) (elastic#63562)
Browse files Browse the repository at this point in the history
* Move Lens frontend to Kibana platform

* Fix line breaks

* Fix jest tests

* Fix remaining test

* Remove old Lens plugin entry

* Fix i18n prefix

* Add config schema

* Address review
  • Loading branch information
Tim Roes authored Apr 15, 2020
1 parent 2f12e1d commit df16326
Show file tree
Hide file tree
Showing 212 changed files with 248 additions and 300 deletions.
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ module.exports = {
},
},
{
files: ['x-pack/legacy/plugins/lens/**/*.{js,ts,tsx}'],
files: ['x-pack/plugins/lens/**/*.{js,ts,tsx}'],
rules: {
'react-hooks/exhaustive-deps': 'off',
'react-hooks/rules-of-hooks': 'off',
Expand Down Expand Up @@ -732,7 +732,7 @@ module.exports = {
* Lens overrides
*/
{
files: ['x-pack/legacy/plugins/lens/**/*.{ts,tsx}', 'x-pack/plugins/lens/**/*.{ts,tsx}'],
files: ['x-pack/plugins/lens/**/*.{ts,tsx}'],
rules: {
'@typescript-eslint/no-explicit-any': 'error',
},
Expand Down
2 changes: 1 addition & 1 deletion .sass-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ files:
- 'x-pack/legacy/plugins/security/**/*.s+(a|c)ss'
- 'x-pack/legacy/plugins/canvas/**/*.s+(a|c)ss'
- 'x-pack/plugins/triggers_actions_ui/**/*.s+(a|c)ss'
- 'x-pack/plugins/lens/**/*.s+(a|c)ss'
ignore:
- 'x-pack/legacy/plugins/canvas/shareable_runtime/**/*.s+(a|c)ss'
- 'x-pack/legacy/plugins/lens/**/*.s+(a|c)ss'
- 'x-pack/legacy/plugins/maps/**/*.s+(a|c)ss'
rules:
quotes:
Expand Down
2 changes: 1 addition & 1 deletion x-pack/.i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"xpack.indexLifecycleMgmt": "plugins/index_lifecycle_management",
"xpack.infra": "plugins/infra",
"xpack.ingestManager": "plugins/ingest_manager",
"xpack.lens": "legacy/plugins/lens",
"xpack.lens": "plugins/lens",
"xpack.licenseMgmt": "plugins/license_management",
"xpack.licensing": "plugins/licensing",
"xpack.logstash": ["plugins/logstash", "legacy/plugins/logstash"],
Expand Down
2 changes: 0 additions & 2 deletions x-pack/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { uptime } from './legacy/plugins/uptime';
import { encryptedSavedObjects } from './legacy/plugins/encrypted_saved_objects';
import { actions } from './legacy/plugins/actions';
import { alerting } from './legacy/plugins/alerting';
import { lens } from './legacy/plugins/lens';
import { ingestManager } from './legacy/plugins/ingest_manager';
import { triggersActionsUI } from './legacy/plugins/triggers_actions_ui';

Expand Down Expand Up @@ -58,7 +57,6 @@ module.exports = function(kibana) {
upgradeAssistant(kibana),
uptime(kibana),
encryptedSavedObjects(kibana),
lens(kibana),
actions(kibana),
alerting(kibana),
ingestManager(kibana),
Expand Down
38 changes: 0 additions & 38 deletions x-pack/legacy/plugins/lens/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion x-pack/legacy/plugins/lens/public/app_plugin/_index.scss

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion x-pack/legacy/plugins/lens/public/drag_drop/_index.scss

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

17 changes: 0 additions & 17 deletions x-pack/legacy/plugins/lens/public/legacy.ts

This file was deleted.

19 changes: 0 additions & 19 deletions x-pack/legacy/plugins/lens/public/redirect.ts

This file was deleted.

This file was deleted.

13 changes: 13 additions & 0 deletions x-pack/plugins/lens/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { schema, TypeOf } from '@kbn/config-schema';

export const configSchema = schema.object({
enabled: schema.boolean({ defaultValue: true }),
});

export type ConfigSchema = TypeOf<typeof configSchema>;
12 changes: 10 additions & 2 deletions x-pack/plugins/lens/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
"version": "8.0.0",
"kibanaVersion": "kibana",
"server": true,
"ui": false,
"optionalPlugins": ["usageCollection", "taskManager"],
"ui": true,
"requiredPlugins": [
"data",
"expressions",
"navigation",
"kibanaLegacy",
"uiActions",
"visualizations"
],
"optionalPlugins": ["embeddable", "usageCollection", "taskManager"],
"configPath": ["xpack", "lens"]
}
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions x-pack/plugins/lens/public/app_plugin/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import 'app';
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,32 @@ import { ReactWrapper } from 'enzyme';
import { act } from 'react-dom/test-utils';
import { App } from './app';
import { EditorFrameInstance } from '../types';
import { Storage } from '../../../../../../src/plugins/kibana_utils/public';
import { Storage } from '../../../../../src/plugins/kibana_utils/public';
import { Document, SavedObjectStore } from '../persistence';
import { mount } from 'enzyme';
import {
esFilters,
FilterManager,
IFieldType,
IIndexPattern,
} from '../../../../../../src/plugins/data/public';
import { dataPluginMock } from '../../../../../../src/plugins/data/public/mocks';
} from '../../../../../src/plugins/data/public';
import { dataPluginMock } from '../../../../../src/plugins/data/public/mocks';
const dataStartMock = dataPluginMock.createStartContract();

import { TopNavMenuData } from '../../../../../../src/plugins/navigation/public';
import { navigationPluginMock } from '../../../../../src/plugins/navigation/public/mocks';
import { TopNavMenuData } from '../../../../../src/plugins/navigation/public';
import { coreMock } from 'src/core/public/mocks';

jest.mock('ui/new_platform');
jest.mock('../persistence');
jest.mock('src/core/public');

import { npStart } from 'ui/new_platform';
jest
.spyOn(npStart.plugins.navigation.ui.TopNavMenu.prototype, 'constructor')
.mockImplementation(() => {
return <div className="topNavMenu" />;
});
const navigationStartMock = navigationPluginMock.createStartContract();

jest.spyOn(navigationStartMock.ui.TopNavMenu.prototype, 'constructor').mockImplementation(() => {
return <div className="topNavMenu" />;
});

const { TopNavMenu } = npStart.plugins.navigation.ui;
const { TopNavMenu } = navigationStartMock.ui;

function createMockFrame(): jest.Mocked<EditorFrameInstance> {
return {
Expand Down Expand Up @@ -99,6 +98,7 @@ describe('Lens App', () => {
function makeDefaultArgs(): jest.Mocked<{
editorFrame: EditorFrameInstance;
data: typeof dataStartMock;
navigation: typeof navigationStartMock;
core: typeof core;
storage: Storage;
docId?: string;
Expand All @@ -107,6 +107,7 @@ describe('Lens App', () => {
addToDashboardMode?: boolean;
}> {
return ({
navigation: navigationStartMock,
editorFrame: createMockFrame(),
core: {
...core,
Expand Down Expand Up @@ -140,6 +141,7 @@ describe('Lens App', () => {
},
redirectTo: jest.fn(id => {}),
} as unknown) as jest.Mocked<{
navigation: typeof navigationStartMock;
editorFrame: EditorFrameInstance;
data: typeof dataStartMock;
core: typeof core;
Expand Down Expand Up @@ -338,6 +340,7 @@ describe('Lens App', () => {

let defaultArgs: jest.Mocked<{
editorFrame: EditorFrameInstance;
navigation: typeof navigationStartMock;
data: typeof dataStartMock;
core: typeof core;
storage: Storage;
Expand Down Expand Up @@ -654,6 +657,7 @@ describe('Lens App', () => {
let defaultArgs: jest.Mocked<{
editorFrame: EditorFrameInstance;
data: typeof dataStartMock;
navigation: typeof navigationStartMock;
core: typeof core;
storage: Storage;
docId?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import React, { useState, useEffect, useCallback } from 'react';
import { I18nProvider } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import { Query, DataPublicPluginStart } from 'src/plugins/data/public';
import { AppMountContext, NotificationsStart } from 'src/core/public';
import { NavigationPublicPluginStart } from 'src/plugins/navigation/public';
import { AppMountContext, NotificationsStart } from 'kibana/public';
import { IStorageWrapper } from 'src/plugins/kibana_utils/public';
import { npStart } from 'ui/new_platform';
import { FormattedMessage } from '@kbn/i18n/react';
import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public';
import { SavedObjectSaveModal } from '../../../../../../src/plugins/saved_objects/public';
import { KibanaContextProvider } from '../../../../../src/plugins/kibana_react/public';
import { SavedObjectSaveModal } from '../../../../../src/plugins/saved_objects/public';
import { Document, SavedObjectStore } from '../persistence';
import { EditorFrameInstance } from '../types';
import { NativeRenderer } from '../native_renderer';
Expand All @@ -25,7 +25,7 @@ import {
IndexPattern as IndexPatternInstance,
IndexPatternsContract,
SavedQuery,
} from '../../../../../../src/plugins/data/public';
} from '../../../../../src/plugins/data/public';

interface State {
isLoading: boolean;
Expand Down Expand Up @@ -53,9 +53,11 @@ export function App({
docStorage,
redirectTo,
addToDashboardMode,
navigation,
}: {
editorFrame: EditorFrameInstance;
data: DataPublicPluginStart;
navigation: NavigationPublicPluginStart;
core: AppMountContext['core'];
storage: IStorageWrapper;
docId?: string;
Expand Down Expand Up @@ -188,7 +190,7 @@ export function App({
[]
);

const { TopNavMenu } = npStart.plugins.navigation.ui;
const { TopNavMenu } = navigation.ui;

const confirmButton = addToDashboardMode ? (
<FormattedMessage
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import 'visualization';
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
ExpressionFunctionDefinition,
ExpressionRenderDefinition,
IInterpreterRenderHandlers,
} from '../../../../../../src/plugins/expressions/public';
} from '../../../../../src/plugins/expressions/public';
import { VisualizationContainer } from '../visualization_container';

export interface DatatableColumns {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { CoreSetup } from 'src/core/public';
import { CoreSetup } from 'kibana/public';
import { datatableVisualization } from './visualization';
import { ExpressionsSetup } from '../../../../../../src/plugins/expressions/public';
import { ExpressionsSetup } from '../../../../../src/plugins/expressions/public';
import { datatable, datatableColumns, getDatatableRenderer } from './expression';
import { EditorFrameSetup, FormatFactory } from '../types';

Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/lens/public/drag_drop/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import 'drag_drop';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import 'editor_frame/index';
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
import React, { useMemo, memo, useContext, useState } from 'react';
import { i18n } from '@kbn/i18n';
import { EuiPopover, EuiButtonIcon, EuiContextMenuPanel, EuiContextMenuItem } from '@elastic/eui';
import { DatasourceDataPanelProps, Datasource } from '../../../public';
import { NativeRenderer } from '../../native_renderer';
import { Action } from './state_management';
import { DragContext } from '../../drag_drop';
import { StateSetter, FramePublicAPI } from '../../types';
import { Query, Filter } from '../../../../../../../src/plugins/data/public';
import { StateSetter, FramePublicAPI, DatasourceDataPanelProps, Datasource } from '../../types';
import { Query, Filter } from '../../../../../../src/plugins/data/public';

interface DataPanelWrapperProps {
datasourceState: unknown;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
*/

import React, { useEffect, useReducer } from 'react';
import { CoreSetup, CoreStart } from 'src/core/public';
import { ReactExpressionRendererType } from '../../../../../../../src/plugins/expressions/public';
import { CoreSetup, CoreStart } from 'kibana/public';
import { ReactExpressionRendererType } from '../../../../../../src/plugins/expressions/public';
import {
Datasource,
DatasourcePublicAPI,
Expand All @@ -25,7 +25,7 @@ import { RootDragDropProvider } from '../../drag_drop';
import { getSavedObjectFormat } from './save';
import { WorkspacePanelWrapper } from './workspace_panel_wrapper';
import { generateId } from '../../id_generator';
import { Filter, Query, SavedQuery } from '../../../../../../../src/plugins/data/public';
import { Filter, Query, SavedQuery } from '../../../../../../src/plugins/data/public';

export interface EditorFrameProps {
doc?: Document;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { Ast, fromExpression, ExpressionFunctionAST } from '@kbn/interpreter/common';
import { Visualization, Datasource, FramePublicAPI } from '../../types';
import { Filter, TimeRange, Query } from '../../../../../../../src/plugins/data/public';
import { Filter, TimeRange, Query } from '../../../../../../src/plugins/data/public';

export function prependDatasourceExpression(
visualizationExpression: Ast | string | null,
Expand Down
Loading

0 comments on commit df16326

Please sign in to comment.