Skip to content

Commit

Permalink
Replace some types with MetricsItemsSchema['values'] to avoid duplica…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
DianaDerevyankina committed Jun 24, 2020
1 parent 1c11748 commit bf4dba3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
8 changes: 3 additions & 5 deletions src/plugins/vis_type_timeseries/common/ui_restrictions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@ export interface UIRestrictions {
[restriction: string]: boolean;
}

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>;
};

/**
* Default value for the UIRestriction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import React from 'react';
import React, { ChangeEvent } from 'react';
import { get } from 'lodash';
import { FormattedMessage } from '@kbn/i18n/react';
import {
Expand Down Expand Up @@ -52,7 +52,7 @@ export const MultiValueRow = ({
}: MultiValueRowProps) => {
const htmlId = htmlIdGenerator();

const onFieldNumberChange = (event: any) =>
const onFieldNumberChange = (event: ChangeEvent<HTMLInputElement>) =>
onChange({
...model,
value: get(event, 'target.value'),
Expand All @@ -72,7 +72,7 @@ export const MultiValueRow = ({
<EuiFlexItem grow={false}>
<EuiFieldNumber
value={model.value === '' ? '' : Number(model.value)}
placeholder={'0'}
placeholder="0"
onChange={onFieldNumberChange}
/>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

import React from 'react';
import { assign } from 'lodash';
import {
htmlIdGenerator,
EuiFlexGroup,
Expand Down Expand Up @@ -69,12 +68,11 @@ export const PercentileRankAgg = (props: PercentileRankAggProps) => {
const handleChange = createChangeHandler(props.onChange, model);
const handleSelectChange = createSelectHandler(handleChange);

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

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { EuiFlexGroup } from '@elastic/eui';
import { MultiValueRow } from './multi_value_row';

interface PercentileRankValuesProps {
model: any[];
model: Array<string | null>;
disableDelete: boolean;
disableAdd: boolean;
showOnlyLastRow: boolean;
Expand Down Expand Up @@ -69,7 +69,7 @@ export const PercentileRankValues = (props: PercentileRankValuesProps) => {
renderRow({
rowModel: {
id: model.length - 1,
value: last(model),
value: last(model) || '',
},
disableAddRow: true,
disableDeleteRow: true,
Expand All @@ -80,7 +80,7 @@ export const PercentileRankValues = (props: PercentileRankValuesProps) => {
renderRow({
rowModel: {
id,
value,
value: value || '',
},
disableAddRow: disableAdd,
disableDeleteRow: disableDelete || array.length < 2,
Expand Down

0 comments on commit bf4dba3

Please sign in to comment.