-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Clean up TSVB type client code to conform to the schema #68519
Conversation
nested?: { path: string }; | ||
} | ||
|
||
export interface FieldDescriptor { |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 }; |
There was a problem hiding this comment.
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?
# Conflicts: # src/plugins/vis_type_timeseries/common/post_vis_schema.ts
@@ -18,6 +18,7 @@ | |||
*/ | |||
|
|||
import React from 'react'; | |||
// @ts-ignore |
There was a problem hiding this comment.
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
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) |
There was a problem hiding this comment.
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.
Pinging @elastic/kibana-app (Team:KibanaApp) |
@elasticmachine merge upstream |
There was a problem hiding this 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
@elasticmachine merge upstream |
There was a problem hiding this 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
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>; | ||
} |
There was a problem hiding this comment.
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?
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[]; |
There was a problem hiding this comment.
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'];
?
const handlePercentileRankValuesChange = (values: Array<string | null> | null | undefined) => { | ||
handleChange( | ||
assign({}, model, { | ||
values, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) => |
There was a problem hiding this comment.
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'} |
There was a problem hiding this comment.
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"
There was a problem hiding this 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
@elasticmachine merge upstream |
💚 Build SucceededBuild metrics
History
To update your PR or re-run it, just comment with: |
* 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]>
* 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) ...
) * 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]>
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