Skip to content

Commit

Permalink
[lens] Calculate existence of fields in datasource (#44422)
Browse files Browse the repository at this point in the history
* [lens] Calculate existence of fields in datasource

* Fix route registration

* Add page object and use existence in functional test

* Simplify layout of filters for index pattern

* Respond to review feedback

* Update class names

* Use new URL constant

* Fix usage of base path

* Fix lint errors
  • Loading branch information
Wylie Conlon authored Sep 3, 2019
1 parent 3948678 commit 426d9d7
Show file tree
Hide file tree
Showing 39 changed files with 1,214 additions and 239 deletions.
3 changes: 2 additions & 1 deletion src/fixtures/logstash_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ function stubbedLogstashFields() {
['area', 'geo_shape', true, true ],
['hashed', 'murmur3', false, true ],
['geo.coordinates', 'geo_point', true, true ],
['extension', 'keyword', true, true ],
['extension', 'text', true, true],
['extension.keyword', 'keyword', true, true, {}, 'extension', 'multi' ],
['machine.os', 'text', true, true ],
['machine.os.raw', 'keyword', true, true, {}, 'machine.os', 'multi' ],
['geo.src', 'keyword', true, true ],
Expand Down
5 changes: 3 additions & 2 deletions x-pack/legacy/plugins/lens/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

export const PLUGIN_ID = 'lens';

export const BASE_URL = 'app/lens';
export const BASE_APP_URL = '/app/lens';
export const BASE_API_URL = '/api/lens';

export function getEditPath(id: string) {
return `/${BASE_URL}#/edit/${encodeURIComponent(id)}`;
return `${BASE_APP_URL}#/edit/${encodeURIComponent(id)}`;
}
21 changes: 19 additions & 2 deletions x-pack/legacy/plugins/lens/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
*/

import * as Joi from 'joi';
import { Server } from 'hapi';
import { resolve } from 'path';
import { LegacyPluginInitializer } from 'src/legacy/types';
import KbnServer, { Server } from 'src/legacy/server/kbn_server';
import { CoreSetup } from 'src/core/server';
import mappings from './mappings.json';
import { PLUGIN_ID, getEditPath } from './common';
import { PLUGIN_ID, getEditPath, BASE_API_URL } from './common';
import { lensServerPlugin } from './server';

const NOT_INTERNATIONALIZED_PRODUCT_NAME = 'Lens Visualizations';

Expand Down Expand Up @@ -51,6 +53,8 @@ export const lens: LegacyPluginInitializer = kibana => {
},

init(server: Server) {
const kbnServer = (server as unknown) as KbnServer;

server.plugins.xpack_main.registerFeature({
id: PLUGIN_ID,
name: NOT_INTERNATIONALIZED_PRODUCT_NAME,
Expand All @@ -77,6 +81,19 @@ export const lens: LegacyPluginInitializer = kibana => {
},
},
});

// Set up with the new platform plugin lifecycle API.
const plugin = lensServerPlugin();
plugin.setup(({
http: {
...kbnServer.newPlatform.setup.core.http,
createRouter: () => kbnServer.newPlatform.setup.core.http.createRouter(BASE_API_URL),
},
} as unknown) as CoreSetup);

server.events.on('stop', () => {
plugin.stop();
});
},
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,21 @@
import React, { useMemo, memo, useContext, useState } from 'react';
import { i18n } from '@kbn/i18n';
import { EuiPopover, EuiButtonIcon, EuiContextMenuPanel, EuiContextMenuItem } from '@elastic/eui';
import { Query } from 'src/plugins/data/common';
import { DatasourceDataPanelProps, Datasource } from '../../../public';
import { NativeRenderer } from '../../native_renderer';
import { Action } from './state_management';
import { DragContext } from '../../drag_drop';
import { StateSetter } from '../../types';
import { StateSetter, FramePublicAPI } from '../../types';

interface DataPanelWrapperProps {
datasourceState: unknown;
datasourceMap: Record<string, Datasource>;
activeDatasource: string | null;
datasourceIsLoading: boolean;
dispatch: (action: Action) => void;
query: Query;
dateRange: FramePublicAPI['dateRange'];
}

export const DataPanelWrapper = memo((props: DataPanelWrapperProps) => {
Expand All @@ -37,6 +40,8 @@ export const DataPanelWrapper = memo((props: DataPanelWrapperProps) => {
dragDropContext: useContext(DragContext),
state: props.datasourceState,
setState: setDatasourceState,
query: props.query,
dateRange: props.dateRange,
};

const [showDatasourceSwitcher, setDatasourceSwitcher] = useState(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ export function EditorFrame(props: EditorFrameProps) {
: true
}
dispatch={dispatch}
query={props.query}
dateRange={props.dateRange}
/>
}
configPanel={
Expand Down
Loading

0 comments on commit 426d9d7

Please sign in to comment.