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

Add inspector for VEGA #70941

Merged
merged 42 commits into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
009fdcc
[WIP] Add inspector for VEGA
alexwizp Jun 29, 2020
2d17852
view -> dataset
alexwizp Jul 8, 2020
61be91c
cleanup
alexwizp Jul 8, 2020
ed8372f
add spec viewer
alexwizp Jul 9, 2020
2fe11b4
cleanup code
alexwizp Jul 9, 2020
766a81e
Merge remote-tracking branch 'upstream/master' into 31189
alexwizp Jul 9, 2020
963520c
Merge remote-tracking branch 'upstream/master' into 31189
alexwizp Jul 10, 2020
2c9b170
use rx to retrieve data from adapters
alexwizp Jul 10, 2020
11354b6
Merge remote-tracking branch 'upstream/master' into 31189
alexwizp Jul 10, 2020
18b20b2
Merge branch 'master' into 31189
elasticmachine Jul 13, 2020
7bb13aa
Merge branch 'master' into 31189
elasticmachine Jul 14, 2020
5adff6a
Make custom inspector adapters registerable from the visType
alexwizp Jul 14, 2020
b1d4abf
Merge remote-tracking branch 'upstream/master' into 31189
alexwizp Jul 14, 2020
b08fc76
fix flex-box size
alexwizp Jul 14, 2020
24c71ac
Merge remote-tracking branch 'upstream/master' into 31189
alexwizp Jul 14, 2020
cb926dc
cleanup
alexwizp Jul 14, 2020
9792707
Merge remote-tracking branch 'upstream/master' into 31189
alexwizp Jul 14, 2020
3733281
Merge branch 'master' into 31189
elasticmachine Jul 15, 2020
da0f816
remove visTypesWithoutInspector from visualize_embeddable
alexwizp Jul 15, 2020
adefdb1
Merge remote-tracking branch 'upstream/master' into 31189
alexwizp Jul 15, 2020
9649cc4
fix PR comments
alexwizp Jul 15, 2020
2f06b4e
Merge remote-tracking branch 'upstream/master' into 31189
alexwizp Jul 15, 2020
c912a1b
add vega folder to sass-lint
alexwizp Jul 15, 2020
9f210b7
fix jest
alexwizp Jul 15, 2020
8d68db8
Merge remote-tracking branch 'upstream/master' into 31189
alexwizp Jul 15, 2020
a2c2e25
Update src/plugins/vis_type_vega/public/vega_inspector/components/dat…
alexwizp Jul 16, 2020
acd9e06
use addSignalListener
alexwizp Jul 16, 2020
8537c9c
Merge remote-tracking branch 'upstream/master' into 31189
alexwizp Jul 16, 2020
850c8f7
cleanup
alexwizp Jul 16, 2020
83ead53
add onColumnResize handler
alexwizp Jul 16, 2020
fb9fa05
EuiCodeEditor -> CodeEditor
alexwizp Jul 17, 2020
0443586
Merge remote-tracking branch 'upstream/master' into 31189
alexwizp Jul 17, 2020
fd847b8
fix type_check
alexwizp Jul 17, 2020
fe8b932
fix issue with pagination
alexwizp Jul 17, 2020
30d9093
fix extra vertical scroll
alexwizp Jul 17, 2020
7293468
add area-label for EuiButtonIcon
alexwizp Jul 17, 2020
4362483
add area-label for EuiComboBox
alexwizp Jul 17, 2020
4868834
Merge branch 'master' into 31189
elasticmachine Jul 19, 2020
f94bc22
Design Commit
Jul 20, 2020
9badea8
Wrapper around signal viewer table
Jul 20, 2020
7d1d1fb
Merge remote-tracking branch 'upstream/master' into 31189
alexwizp Jul 21, 2020
dc06a5a
fix Jest snapshot
alexwizp Jul 21, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .sass-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ files:
- 'src/legacy/core_plugins/metrics/**/*.s+(a|c)ss'
- 'src/plugins/timelion/**/*.s+(a|c)ss'
- 'src/plugins/vis_type_vislib/**/*.s+(a|c)ss'
- 'src/plugins/vis_type_vega/**/*.s+(a|c)ss'
- 'src/plugins/vis_type_xy/**/*.s+(a|c)ss'
- 'x-pack/plugins/canvas/**/*.s+(a|c)ss'
- 'x-pack/plugins/triggers_actions_ui/**/*.s+(a|c)ss'
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ import { EuiButtonEmptyProps } from '@elastic/eui';
import { EuiComboBoxProps } from '@elastic/eui';
import { EuiConfirmModalProps } from '@elastic/eui';
import { EuiGlobalToastListToast } from '@elastic/eui';
import { EventEmitter } from 'events';
import { ExclusiveUnion } from '@elastic/eui';
import { ExistsParams } from 'elasticsearch';
import { ExplainParams } from 'elasticsearch';
Expand Down Expand Up @@ -148,7 +147,7 @@ import { ReindexRethrottleParams } from 'elasticsearch';
import { RenderSearchTemplateParams } from 'elasticsearch';
import { Reporter } from '@kbn/analytics';
import { RequestAdapter } from 'src/plugins/inspector/common';
import { RequestStatistics as RequestStatistics_2 } from 'src/plugins/inspector/common';
import { RequestStatistics } from 'src/plugins/inspector/common';
import { Required } from '@kbn/utility-types';
import * as Rx from 'rxjs';
import { SavedObject } from 'src/core/server';
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/public/search/aggs/buckets/terms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const getTermsBucketAgg = () =>

const response = await nestedSearchSource.fetch({ abortSignal });
request
.stats(getResponseInspectorStats(nestedSearchSource, response))
.stats(getResponseInspectorStats(response, nestedSearchSource))
.ok({ json: response });
resp = mergeOtherBucketAggResponse(aggConfigs, resp, response, aggConfig, filterAgg());
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/public/search/expressions/esaggs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const handleCourierRequest = async ({

(searchSource as any).lastQuery = queryHash;

request.stats(getResponseInspectorStats(searchSource, response)).ok({ json: response });
request.stats(getResponseInspectorStats(response, searchSource)).ok({ json: response });

(searchSource as any).rawResponse = response;
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ export function getRequestInspectorStats(searchSource: ISearchSource) {

/** @public */
export function getResponseInspectorStats(
searchSource: ISearchSource,
resp: SearchResponse<unknown>
resp: SearchResponse<unknown>,
searchSource?: ISearchSource
) {
const lastRequest = searchSource.history && searchSource.history[searchSource.history.length - 1];
const lastRequest =
searchSource?.history && searchSource.history[searchSource.history.length - 1];
const stats: RequestStatistics = {};

if (resp && resp.took) {
Expand Down
1 change: 0 additions & 1 deletion src/plugins/data/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import { DeleteTemplateParams } from 'elasticsearch';
import { DetailedPeerCertificate } from 'tls';
import { Duration } from 'moment';
import { ErrorToastOptions } from 'src/core/public/notifications';
import { EventEmitter } from 'events';
import { ExistsParams } from 'elasticsearch';
import { ExplainParams } from 'elasticsearch';
import { FieldStatsParams } from 'elasticsearch';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ function discoverController(
}

function onResults(resp) {
inspectorRequest.stats(getResponseInspectorStats($scope.searchSource, resp)).ok({ json: resp });
inspectorRequest.stats(getResponseInspectorStats(resp, $scope.searchSource)).ok({ json: resp });

if (getTimeField()) {
const tabifiedData = tabifyAggResponse($scope.vis.data.aggs, resp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ export class SearchEmbeddable extends Embeddable<SearchInput, SearchOutput>
this.updateOutput({ loading: false, error: undefined });

// Log response to inspector
inspectorRequest.stats(getResponseInspectorStats(searchSource, resp)).ok({ json: resp });
inspectorRequest.stats(getResponseInspectorStats(resp, searchSource)).ok({ json: resp });

// Apply the changes to the angular scope
this.searchScope.$apply(() => {
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/expressions/common/execution/execution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { createExecutionContainer, ExecutionContainer } from './container';
import { createError } from '../util';
import { Defer, now } from '../../../kibana_utils/common';
import { toPromise } from '../../../data/common/utils/abort_utils';
import { RequestAdapter, DataAdapter } from '../../../inspector/common';
import { RequestAdapter, DataAdapter, Adapters } from '../../../inspector/common';
import { isExpressionValueError, ExpressionValueError } from '../expression_types/specs/error';
import {
ExpressionAstExpression,
Expand Down Expand Up @@ -70,7 +70,7 @@ export class Execution<
ExtraContext extends Record<string, unknown> = Record<string, unknown>,
Input = unknown,
Output = unknown,
InspectorAdapters = ExtraContext['inspectorAdapters'] extends object
InspectorAdapters extends Adapters = ExtraContext['inspectorAdapters'] extends object
? ExtraContext['inspectorAdapters']
: DefaultInspectorAdapters
> {
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/expressions/common/execution/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
*/

import { ExpressionType } from '../expression_types';
import { DataAdapter, RequestAdapter } from '../../../inspector/common';
import { Adapters, DataAdapter, RequestAdapter } from '../../../inspector/common';
import { TimeRange, Query, Filter } from '../../../data/common';
import { SavedObject, SavedObjectAttributes } from '../../../../core/public';

/**
* `ExecutionContext` is an object available to all functions during a single execution;
* it provides various methods to perform side-effects.
*/
export interface ExecutionContext<Input = unknown, InspectorAdapters = DefaultInspectorAdapters> {
export interface ExecutionContext<Input = unknown, InspectorAdapters extends Adapters = Adapters> {
/**
* Get initial input with which execution started.
*/
Expand Down Expand Up @@ -75,7 +75,7 @@ export interface ExecutionContext<Input = unknown, InspectorAdapters = DefaultIn
/**
* Default inspector adapters created if inspector adapters are not set explicitly.
*/
export interface DefaultInspectorAdapters {
export interface DefaultInspectorAdapters extends Adapters {
requests: RequestAdapter;
data: DataAdapter;
}
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/expressions/public/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export class ExpressionLoader {
variables: params.variables || {},
inspectorAdapters: params.inspectorAdapters,
});
if (!params.inspectorAdapters) params.inspectorAdapters = this.execution.inspect() as Adapters;

const prevDataHandler = this.execution;
const data = await prevDataHandler.getData();
if (this.execution !== prevDataHandler) {
Expand Down Expand Up @@ -181,6 +181,9 @@ export class ExpressionLoader {
if (params.variables && this.params) {
this.params.variables = params.variables;
}

this.params.inspectorAdapters = (params.inspectorAdapters ||
this.execution?.inspect()) as Adapters;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export function createInputControlVisTypeDefinition(deps: InputControlVisDepende
},
],
},
inspectorAdapters: {},
requestHandler: 'none',
responseHandler: 'none',
};
Expand Down
9 changes: 8 additions & 1 deletion src/plugins/inspector/common/adapters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,12 @@
* under the License.
*/

export { Adapters } from './types';
export { DataAdapter, FormattedData } from './data';
export { RequestAdapter, RequestStatistic, RequestStatistics, RequestStatus } from './request';
export {
RequestAdapter,
RequestStatistic,
RequestStatistics,
RequestStatus,
RequestResponder,
} from './request';
1 change: 1 addition & 0 deletions src/plugins/inspector/common/adapters/request/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@

export { RequestStatistic, RequestStatistics, RequestStatus } from './types';
export { RequestAdapter } from './request_adapter';
export { RequestResponder } from './request_responder';
25 changes: 25 additions & 0 deletions src/plugins/inspector/common/adapters/types.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.
*/

/**
* The interface that the adapters used to open an inspector have to fullfill.
*/
export interface Adapters {
[key: string]: any;
}
8 changes: 7 additions & 1 deletion src/plugins/inspector/public/index.scss
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
@import 'views/index'
@import 'views/index';

.insFlyoutBody {
.euiFlyoutBody__overflowContent {
height: 100%;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary? Targeting EUI classes is usually not a good idea. There may be a better way to fix whatever issue you ran into.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cchaos I have not found a better way to achieve my goal. The problem is that I want to set the height to 100% for the DataGrid / EuiCodeEditor component. Without these changes, it looks like this:
image

I would really appreciate if you could help me do it in more professionally way.

}
}
3 changes: 2 additions & 1 deletion src/plugins/inspector/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import * as React from 'react';
import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from '../../../core/public';
import { toMountPoint } from '../../kibana_react/public';
import { InspectorViewRegistry } from './view_registry';
import { Adapters, InspectorOptions, InspectorSession } from './types';
import { InspectorOptions, InspectorSession } from './types';
import { InspectorPanel } from './ui/inspector_panel';
import { Adapters } from '../common';

import { getRequestsViewDescription, getDataViewDescription } from './views';

Expand Down
12 changes: 3 additions & 9 deletions src/plugins/inspector/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,17 @@
*/

import { OverlayRef } from '../../../core/public';

/**
* The interface that the adapters used to open an inspector have to fullfill.
*/
export interface Adapters {
[key: string]: any;
}
import { Adapters } from '../common';

/**
* The props interface that a custom inspector view component, that will be passed
* to {@link InspectorViewDescription#component}, must use.
*/
export interface InspectorViewProps {
export interface InspectorViewProps<TAdapters extends Adapters = Adapters> {
/**
* Adapters used to open the inspector.
*/
adapters: Adapters;
adapters: TAdapters;
/**
* The title that the inspector is currently using e.g. a visualization name.
*/
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/plugins/inspector/public/ui/inspector_panel.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import React from 'react';
import { mountWithIntl } from 'test_utils/enzyme_helpers';
import { InspectorPanel } from './inspector_panel';
import { Adapters, InspectorViewDescription } from '../types';
import { InspectorViewDescription } from '../types';
import { Adapters } from '../../common';

describe('InspectorPanel', () => {
let adapters: Adapters;
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/inspector/public/ui/inspector_panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import { i18n } from '@kbn/i18n';
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { EuiFlexGroup, EuiFlexItem, EuiFlyoutHeader, EuiTitle, EuiFlyoutBody } from '@elastic/eui';
import { Adapters, InspectorViewDescription } from '../types';
import { InspectorViewDescription } from '../types';
import { Adapters } from '../../common';
import { InspectorViewChooser } from './inspector_view_chooser';

function hasAdaptersChanged(oldAdapters: Adapters, newAdapters: Adapters) {
Expand Down Expand Up @@ -122,7 +123,7 @@ export class InspectorPanel extends Component<InspectorPanelProps, InspectorPane
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlyoutHeader>
<EuiFlyoutBody>{this.renderSelectedPanel()}</EuiFlyoutBody>
<EuiFlyoutBody className="insFlyoutBody">{this.renderSelectedPanel()}</EuiFlyoutBody>
</React.Fragment>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/inspector/public/view_registry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { InspectorViewRegistry } from './view_registry';
import { InspectorViewDescription } from './types';

import { Adapters } from './types';
import { Adapters } from '../common';

function createMockView(
params: {
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/inspector/public/view_registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
*/

import { EventEmitter } from 'events';
import { Adapters, InspectorViewDescription } from './types';
import { InspectorViewDescription } from './types';
import { Adapters } from '../common';

/**
* @callback viewShouldShowFunc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import {
} from '@elastic/eui';

import { DataTableFormat } from './data_table';
import { InspectorViewProps, Adapters } from '../../../types';
import { InspectorViewProps } from '../../../types';
import { Adapters } from '../../../../common';
import {
TabularLoaderOptions,
TabularData,
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/inspector/public/views/data/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import React from 'react';
import { i18n } from '@kbn/i18n';

import { DataViewComponent } from './components/data_view';
import { Adapters, InspectorViewDescription, InspectorViewProps } from '../../types';
import { InspectorViewDescription, InspectorViewProps } from '../../types';
import { Adapters } from '../../../common';
import { IUiSettingsClient } from '../../../../../core/public';

export const getDataViewDescription = (
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/inspector/public/views/requests/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
import { i18n } from '@kbn/i18n';

import { RequestsViewComponent } from './components/requests_view';
import { Adapters, InspectorViewDescription } from '../../types';
import { InspectorViewDescription } from '../../types';
import { Adapters } from '../../../common';

export const getRequestsViewDescription = (): InspectorViewDescription => ({
title: i18n.translate('inspector.requests.requestsTitle', {
Expand Down
1 change: 1 addition & 0 deletions src/plugins/vis_type_markdown/public/markdown_vis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,5 @@ export const markdownVisDefinition = {
},
requestHandler: 'none',
responseHandler: 'none',
inspectorAdapters: {},
};
1 change: 1 addition & 0 deletions src/plugins/vis_type_timelion/public/timelion_vis_type.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export function getTimelionVisDefinition(dependencies: TimelionVisDependencies)
},
requestHandler: timelionRequestHandler,
responseHandler: 'none',
inspectorAdapters: {},
options: {
showIndexSelection: false,
showQueryBar: false,
Expand Down
1 change: 1 addition & 0 deletions src/plugins/vis_type_timeseries/public/metrics_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,6 @@ export const metricsVisDefinition = {
showIndexSelection: false,
},
requestHandler: metricsRequestHandler,
inspectorAdapters: {},
responseHandler: 'none',
};
2 changes: 1 addition & 1 deletion src/plugins/vis_type_vega/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"version": "kibana",
"server": true,
"ui": true,
"requiredPlugins": ["data", "visualizations", "mapsLegacy", "expressions"],
"requiredPlugins": ["data", "visualizations", "mapsLegacy", "expressions", "inspector"],
"requiredBundles": ["kibanaUtils", "kibanaReact"]
}
Loading