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

[TSVB] fix include/exclude fields appear to migrated TSVB visualization when using Group by Terms #104848

Merged
merged 3 commits into from
Jul 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
EuiFormRow,
EuiSpacer,
} from '@elastic/eui';
import { getIndexPatternKey } from '../../../../common/index_patterns_utils';

export function CumulativeSumAgg(props) {
const { model, siblings, fields, indexPattern } = props;
Expand Down Expand Up @@ -70,7 +71,7 @@ export function CumulativeSumAgg(props) {
onChange={handleSelectChange('field')}
metrics={siblings}
metric={model}
fields={fields[indexPattern]}
fields={fields[getIndexPatternKey(indexPattern)]}
value={model.field}
exclude={[METRIC_TYPES.TOP_HIT]}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
EuiSpacer,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { getIndexPatternKey } from '../../../../common/index_patterns_utils';

export const DerivativeAgg = (props) => {
const { siblings, fields, indexPattern } = props;
Expand Down Expand Up @@ -80,7 +81,7 @@ export const DerivativeAgg = (props) => {
onChange={handleSelectChange('field')}
metrics={siblings}
metric={model}
fields={fields[indexPattern]}
fields={fields[getIndexPatternKey(indexPattern)]}
value={model.field}
exclude={[METRIC_TYPES.TOP_HIT]}
fullWidth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
EuiFieldNumber,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { getIndexPatternKey } from '../../../../common/index_patterns_utils';

const DEFAULTS = {
model_type: MODEL_TYPES.UNWEIGHTED,
Expand Down Expand Up @@ -141,7 +142,7 @@ export const MovingAverageAgg = (props) => {
onChange={handleSelectChange('field')}
metrics={siblings}
metric={model}
fields={fields[indexPattern]}
fields={fields[getIndexPatternKey(indexPattern)]}
value={model.field}
exclude={[METRIC_TYPES.TOP_HIT]}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
EuiSpacer,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { getIndexPatternKey } from '../../../../common/index_patterns_utils';

export const PositiveOnlyAgg = (props) => {
const { siblings, fields, indexPattern } = props;
Expand Down Expand Up @@ -74,7 +75,7 @@ export const PositiveOnlyAgg = (props) => {
onChange={handleSelectChange('field')}
metrics={siblings}
metric={model}
fields={fields[indexPattern]}
fields={fields[getIndexPatternKey(indexPattern)]}
value={model.field}
exclude={[METRIC_TYPES.TOP_HIT]}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
EuiSpacer,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { getIndexPatternKey } from '../../../../common/index_patterns_utils';

export const SerialDiffAgg = (props) => {
const { siblings, fields, indexPattern, model } = props;
Expand Down Expand Up @@ -74,7 +75,7 @@ export const SerialDiffAgg = (props) => {
onChange={handleSelectChange('field')}
metrics={siblings}
metric={model}
fields={fields[indexPattern]}
fields={fields[getIndexPatternKey(indexPattern)]}
value={model.field}
exclude={[METRIC_TYPES.TOP_HIT]}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
EuiSpacer,
} from '@elastic/eui';
import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
import { getIndexPatternKey } from '../../../../common/index_patterns_utils';

const StandardSiblingAggUi = (props) => {
const { siblings, intl, fields, indexPattern } = props;
Expand Down Expand Up @@ -147,7 +148,7 @@ const StandardSiblingAggUi = (props) => {
onChange={handleSelectChange('field')}
exclude={[METRIC_TYPES.PERCENTILE, METRIC_TYPES.TOP_HIT]}
metrics={siblings}
fields={fields[indexPattern]}
fields={fields[getIndexPatternKey(indexPattern)]}
metric={model}
value={model.field}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { AddDeleteButtons } from '../add_delete_buttons';
import { collectionActions } from '../lib/collection_actions';
import { MetricSelect } from './metric_select';
import { EuiFlexGroup, EuiFlexItem, EuiFieldText } from '@elastic/eui';
import { getIndexPatternKey } from '../../../../common/index_patterns_utils';

export const newVariable = (opts) => ({ id: uuid.v1(), name: '', field: '', ...opts });

Expand Down Expand Up @@ -59,7 +60,7 @@ export class CalculationVars extends Component {
metrics={this.props.metrics}
metric={this.props.model}
value={row.field}
fields={this.props.fields[this.props.indexPattern]}
fields={this.props.fields[getIndexPatternKey(this.props.indexPattern)]}
includeSiblings={this.props.includeSiblings}
exclude={this.props.exclude}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
import { injectI18n, FormattedMessage } from '@kbn/i18n/react';
import { KBN_FIELD_TYPES } from '../../../../../data/public';
import { STACKED_OPTIONS } from '../../visualizations/constants';
import { getIndexPatternKey } from '../../../../common/index_patterns_utils';

const DEFAULTS = { terms_direction: 'desc', terms_size: 10, terms_order_by: '_count' };

Expand Down Expand Up @@ -75,10 +76,11 @@ export const SplitByTermsUI = ({
}),
},
];
const fieldsSelector = getIndexPatternKey(indexPattern);
const selectedDirectionOption = dirOptions.find((option) => {
return model.terms_direction === option.value;
});
const selectedField = find(fields[indexPattern], ({ name }) => name === model.terms_field);
const selectedField = find(fields[fieldsSelector], ({ name }) => name === model.terms_field);
const selectedFieldType = get(selectedField, 'type');

if (
Expand Down Expand Up @@ -198,7 +200,7 @@ export const SplitByTermsUI = ({
metrics={metrics}
clearable={false}
additionalOptions={[defaultCount, terms]}
fields={fields[indexPattern]}
fields={fields[fieldsSelector]}
onChange={handleSelectChange('terms_order_by')}
restrict="basic"
value={model.terms_order_by}
Expand Down