Skip to content

Commit

Permalink
[TSVB] [Regression] Fix Top Hit / Filter Ratio aggregations (elastic#…
Browse files Browse the repository at this point in the history
…96288)

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
alexwizp and kibanamachine committed Apr 7, 2021
1 parent 66cd29d commit 9a09dec
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export function CalculationAgg(props) {
CalculationAgg.propTypes = {
disableDelete: PropTypes.bool,
fields: PropTypes.object,
indexPattern: PropTypes.string,
indexPattern: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
model: PropTypes.object,
onAdd: PropTypes.func,
onChange: PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export function CumulativeSumAgg(props) {
CumulativeSumAgg.propTypes = {
disableDelete: PropTypes.bool,
fields: PropTypes.object,
indexPattern: PropTypes.string,
indexPattern: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
model: PropTypes.object,
onAdd: PropTypes.func,
onChange: PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const DerivativeAgg = (props) => {
DerivativeAgg.propTypes = {
disableDelete: PropTypes.bool,
fields: PropTypes.object,
indexPattern: PropTypes.string,
indexPattern: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
model: PropTypes.object,
onAdd: PropTypes.func,
onChange: PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { FieldSelect } from './field_select';
import { AggRow } from './agg_row';
import { createChangeHandler } from '../lib/create_change_handler';
import { createSelectHandler } from '../lib/create_select_handler';
import { getIndexPatternKey } from '../../../../common/index_patterns_utils';

import {
htmlIdGenerator,
Expand All @@ -29,7 +30,7 @@ import { getDataStart } from '../../../services';
import { QueryBarWrapper } from '../query_bar_wrapper';

const isFieldHistogram = (fields, indexPattern, field) => {
const indexFields = fields[indexPattern];
const indexFields = fields[getIndexPatternKey(indexPattern)];
if (!indexFields) return false;
const fieldObject = indexFields.find((f) => f.name === field);
if (!fieldObject) return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export function MathAgg(props) {
MathAgg.propTypes = {
disableDelete: PropTypes.bool,
fields: PropTypes.object,
indexPattern: PropTypes.string,
indexPattern: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
model: PropTypes.object,
onAdd: PropTypes.func,
onChange: PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export const MovingAverageAgg = (props) => {
MovingAverageAgg.propTypes = {
disableDelete: PropTypes.bool,
fields: PropTypes.object,
indexPattern: PropTypes.string,
indexPattern: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
model: PropTypes.object,
onAdd: PropTypes.func,
onChange: PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const PositiveOnlyAgg = (props) => {
PositiveOnlyAgg.propTypes = {
disableDelete: PropTypes.bool,
fields: PropTypes.object,
indexPattern: PropTypes.string,
indexPattern: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
model: PropTypes.object,
onAdd: PropTypes.func,
onChange: PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const SerialDiffAgg = (props) => {
SerialDiffAgg.propTypes = {
disableDelete: PropTypes.bool,
fields: PropTypes.object,
indexPattern: PropTypes.string,
indexPattern: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
model: PropTypes.object,
onAdd: PropTypes.func,
onChange: PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ const StandardSiblingAggUi = (props) => {
StandardSiblingAggUi.propTypes = {
disableDelete: PropTypes.bool,
fields: PropTypes.object,
indexPattern: PropTypes.string,
indexPattern: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
model: PropTypes.object,
onAdd: PropTypes.func,
onChange: PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
import { KBN_FIELD_TYPES } from '../../../../../../plugins/data/public';
import { PANEL_TYPES } from '../../../../common/panel_types';
import { getIndexPatternKey } from '../../../../common/index_patterns_utils';

const isFieldTypeEnabled = (fieldRestrictions, fieldType) =>
fieldRestrictions.length ? fieldRestrictions.includes(fieldType) : true;
Expand Down Expand Up @@ -115,8 +116,8 @@ const TopHitAggUi = (props) => {
const handleChange = createChangeHandler(props.onChange, model);
const handleSelectChange = createSelectHandler(handleChange);
const handleTextChange = createTextHandler(handleChange);

const field = fields[indexPattern].find((f) => f.name === model.field);
const fieldsSelector = getIndexPatternKey(indexPattern);
const field = fields[fieldsSelector].find((f) => f.name === model.field);
const aggWithOptions = getAggWithOptions(field, aggWithOptionsRestrictFields);
const orderOptions = getOrderOptions();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ CalculationVars.defaultProps = {

CalculationVars.propTypes = {
fields: PropTypes.object,
indexPattern: PropTypes.string,
indexPattern: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
metrics: PropTypes.array,
model: PropTypes.object,
name: PropTypes.string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ SplitByTermsUI.propTypes = {
intl: PropTypes.object,
model: PropTypes.object,
onChange: PropTypes.func,
indexPattern: PropTypes.string,
indexPattern: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
fields: PropTypes.object,
uiRestrictions: PropTypes.object,
seriesQuantity: PropTypes.object,
Expand Down

0 comments on commit 9a09dec

Please sign in to comment.