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

Clean up TSVB type client code to conform to the schema #68519

Merged
merged 11 commits into from
Jun 25, 2020

Conversation

DianaDerevyankina
Copy link
Contributor

Part of #57342

Summary

Summarize your PR. If it involves visual changes include a screenshot or gif.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@DianaDerevyankina DianaDerevyankina added Feature:TSVB TSVB (Time Series Visual Builder) v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.9.0 labels Jun 8, 2020
@DianaDerevyankina DianaDerevyankina self-assigned this Jun 8, 2020
nested?: { path: string };
}

export interface FieldDescriptor {
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume IFieldType from data plugin is fully suitable for TSVB, isn't it?

onDelete: (event: MouseEvent) => void;
}

export function AddDeleteButtons(props: AddDeleteButtonsProps) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to type in addition the test file for this component: add_delete_buttons.test.js ?

panel: PanelSchema;
series: SeriesItemsSchema;
siblings: MetricsItemsSchema[];
uiRestrictions: { '*': boolean };
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a list of possible ui restrictions keys exist in src/plugins/vis_type_timeseries/common/ui_restrictions.ts.
Could you please add them as possible keys?

@@ -18,6 +18,7 @@
*/

import React from 'react';
// @ts-ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

I think import { expect } from 'chai'; was added by mistake. Please remove it

@alexwizp alexwizp requested a review from stratoula June 16, 2020 08:16
const { siblings, panelType, value, onChange, uiRestrictions, ...rest } = props;

const selectedOptions = allAggOptions.filter((option) => {
return value === option.value && isMetricEnabled(option.value, uiRestrictions);
});

let enablePipelines = siblings.some((s) => !!metricAggs.find((m) => m.value === s.type));
let enablePipelines = siblings.some(
(s: { id: string; type: string }) => !!metricAggs.find((m) => m.value === s.type)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't add extra types like e.g. { id: string; type: string }. You already set type for siblings variable.

@DianaDerevyankina DianaDerevyankina added the Team:Visualizations Visualization editors, elastic-charts and infrastructure label Jun 17, 2020
@DianaDerevyankina DianaDerevyankina marked this pull request as ready for review June 17, 2020 08:09
@DianaDerevyankina DianaDerevyankina requested a review from a team June 17, 2020 08:09
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@alexwizp
Copy link
Contributor

@elasticmachine merge upstream

Copy link
Contributor

@alexwizp alexwizp left a comment

Choose a reason for hiding this comment

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

Good first step of migrating js -> ts

@alexwizp
Copy link
Contributor

@elasticmachine merge upstream

Copy link
Contributor

@sulemanof sulemanof left a comment

Choose a reason for hiding this comment

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

Left few comments, but overall LGTM

Comment on lines 47 to 51
export interface TimeseriesUIRestrictions {
[RESTRICTIONS_KEYS.WHITE_LISTED_GROUP_BY_FIELDS]: Record<string, UIRestrictions>;
[RESTRICTIONS_KEYS.WHITE_LISTED_METRICS]: Record<string, UIRestrictions>;
[RESTRICTIONS_KEYS.WHITE_LISTED_TIMERANGE_MODES]: Record<string, UIRestrictions>;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this work for your case?

Suggested change
export interface TimeseriesUIRestrictions {
[RESTRICTIONS_KEYS.WHITE_LISTED_GROUP_BY_FIELDS]: Record<string, UIRestrictions>;
[RESTRICTIONS_KEYS.WHITE_LISTED_METRICS]: Record<string, UIRestrictions>;
[RESTRICTIONS_KEYS.WHITE_LISTED_TIMERANGE_MODES]: Record<string, UIRestrictions>;
}
export type TimeseriesUIRestrictions = {
[key in RESTRICTIONS_KEYS]: Record<string, UIRestrictions>;
};

import React from 'react';
import { last } from 'lodash';

import { EuiFlexGroup } from '@elastic/eui';
import { MultiValueRow } from './multi_value_row';

export const PercentileRankValues = (props) => {
interface PercentileRankValuesProps {
model: any[];
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesnt it receive MetricsItemsSchema['values']; ?

Comment on lines 72 to 75
const handlePercentileRankValuesChange = (values: Array<string | null> | null | undefined) => {
handleChange(
assign({}, model, {
values,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const handlePercentileRankValuesChange = (values: Array<string | null> | null | undefined) => {
handleChange(
assign({}, model, {
values,
const handlePercentileRankValuesChange = (values: MetricsItemsSchema['values']) => {
handleChange(
assign({}, model, {
values,

You could also get rid of lodash here (we are trying to do it if possible):

handleChange({
  ...model,
  values
})

const htmlId = htmlIdGenerator();

const onFieldNumberChange = (event) =>
const onFieldNumberChange = (event: any) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we avoid this any ?

@@ -54,7 +72,7 @@ export const MultiValueRow = ({ model, onChange, onDelete, onAdd, disableAdd, di
<EuiFlexItem grow={false}>
<EuiFieldNumber
value={model.value === '' ? '' : Number(model.value)}
placeholder={0}
placeholder={'0'}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: you could also omit curly brackets with "0"

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

LGTM, nice first touch :) I have also tested it on Chrome. Works as expected

@alexwizp
Copy link
Contributor

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@DianaDerevyankina DianaDerevyankina merged commit 2b72de5 into elastic:master Jun 25, 2020
DianaDerevyankina added a commit to DianaDerevyankina/kibana that referenced this pull request Jun 25, 2020
* Clean up TSVB type client code to conform to the schema

Part of elastic#57342

* Replace FieldDescriptor with IFieldType, add UIRestrictions interface

* Replace expect from chai with @kbn/expect, remove unnecessary type

* Add TimeseriesUIRestrictions type and refactor add_delete_buttons.test

* Replace some types with MetricsItemsSchema['values'] to avoid duplications

Co-authored-by: Elastic Machine <[email protected]>
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jun 25, 2020
* master: (45 commits)
  [QA] Unskip functional tests (elastic#69760)
  [SIEM][Detection Engine] - Update DE to work with new exceptions schema (elastic#69715)
  Fixes elastic#69639: Ignore url.url fields above 2048 characters (elastic#69863)
  PR: Provide limit warnings to user when API limits are reached. (elastic#69590)
  [Maps] Remove broken button (elastic#69853)
  Makes usage collection methods available on start (elastic#69836)
  [SIEM][CASE] Improve Jira's labelling (elastic#69892)
  [Logs UI] Access ML via the programmatic plugin API (elastic#68905)
  [ML] DF Analytics: Creation wizard part 3 (elastic#69456)
  Update Resolver generator script documentation (elastic#69912)
  [ML] Changes View results button text on new job page (elastic#69809)
  Add master branch to backport config (elastic#69893)
  [Ingest Manager] Kibana, not EPR, controls removable packages (elastic#69761)
  unskips 'Events columns' test (elastic#69684)
  [ML] Changes the ML overview empty analytics panel text (elastic#69801)
  [DOCS] Emphasizes where File Data Visualizer is located. (elastic#69812)
  add the `exactRoute` property to app registration (elastic#69772)
  Bump backport to 5.4.6 (elastic#69880)
  [Logs UI] ML log integration splash screen (elastic#69288)
  Clean up TSVB type client code to conform to the schema (elastic#68519)
  ...
DianaDerevyankina added a commit that referenced this pull request Jun 26, 2020
)

* Clean up TSVB type client code to conform to the schema

Part of #57342

* Replace FieldDescriptor with IFieldType, add UIRestrictions interface

* Replace expect from chai with @kbn/expect, remove unnecessary type

* Add TimeseriesUIRestrictions type and refactor add_delete_buttons.test

* Replace some types with MetricsItemsSchema['values'] to avoid duplications

Co-authored-by: Elastic Machine <[email protected]>

Co-authored-by: Elastic Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:TSVB TSVB (Time Series Visual Builder) release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.9.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants