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

[lens] Calculate existence of fields in datasource #44422

Merged
merged 10 commits into from
Sep 3, 2019
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 @@ -50,6 +52,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 Down Expand Up @@ -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