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

removing schemas from agg configs #58462

Merged
merged 22 commits into from
Mar 5, 2020
Merged

Conversation

ppisljar
Copy link
Member

@ppisljar ppisljar commented Feb 25, 2020

Summary

removes schemas dependency from aggconfigs

  • saved object format was not changed, schema: string still exists on serialized aggconfigs
  • on aggconfig instance schema is now also just a string (and not schema instance)
  • editor is responsible for matching this to actual schema instance to get the information it needs

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@ppisljar ppisljar added WIP Work in progress v8.0.0 Team:AppArch release_note:skip Skip the PR/issue when compiling release notes v7.7.0 labels Feb 25, 2020
@ppisljar ppisljar requested a review from a team February 25, 2020 12:28
@ppisljar ppisljar requested a review from a team as a code owner February 25, 2020 12:28
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch (Team:AppArch)

@ppisljar ppisljar force-pushed the agg/schemas branch 5 times, most recently from b3798fb to 839edb1 Compare March 3, 2020 19:28
@ppisljar ppisljar removed the WIP Work in progress label Mar 3, 2020
@ppisljar ppisljar changed the title [WIP] removing schemas from agg configs removing schemas from agg configs Mar 3, 2020
const payloadAggConfig = action.payload as IAggConfig;
const aggConfig = state.aggs.createAggConfig(payloadAggConfig, {
const { schema } = action.payload;
const defaultConfig =
Copy link
Member Author

Choose a reason for hiding this comment

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

handling defaults when adding a new aggregation

@@ -1,33 +0,0 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
Copy link
Member Author

Choose a reason for hiding this comment

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

we no longer need this as aggFilter information is no longer present on schema, or anywhere on agg.

this.type.schemas.all
);
let configStates = state.aggs ? state.aggs.aggs || state.aggs : [];
configStates = this.initializeDefaultsFromSchemas(configStates, this.type.schemas.all || []);
Copy link
Member Author

Choose a reason for hiding this comment

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

handling defaults

Copy link
Member

@lukeelmers lukeelmers left a comment

Choose a reason for hiding this comment

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

updates LGTM, pending approval from someone who is more familiar with the default vis editor. 😄

# Conflicts:
#	src/legacy/core_plugins/data/public/search/aggs/agg_types.ts
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.

Please, make sure filtering works correctly!

): ComboBoxGroupedOptions<IAggType> {
const aggTypeOptions = aggTypeFilters.filter((aggTypes as any)[groupName], indexPattern, agg);
const aggTypeOptions = aggTypeFilters
Copy link
Contributor

@sulemanof sulemanof Mar 5, 2020

Choose a reason for hiding this comment

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

Since the aggTypeFilters is used only in rollup for adding a filter,
makes sense to get rid of it at all.
Please, take a look at this comment https://github.com/elastic/kibana/pull/57695/files/555e19e6ecf08b05e0dc39ebdc92d9f2d5bf32ef#r380614658

Of course, you can skip it for now, but anyway it's worth to do.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, lets do that in a followup

name: 'orderAgg',
// This string is never visible to the user so it doesn't need to be translated
title: 'Order Agg',
hideCustomLabel: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

The custom label should not be presented in terms -> order agg

image

const aggTypeOptions = aggTypeFilters
.filter((aggTypes as any)[groupName], indexPattern, agg, aggFilter)
.filter(aggType => {
return filterByName([aggType], allowedAggs).length !== 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we just merge both arrays, instead of adding the second filter, which do the same thing?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it won't give the same results

get(aggConfig.schema, 'aggSettings.top_hits.allowStrings', false)
? '*'
: KBN_FIELD_TYPES.NUMBER,
filterFieldTypes: () => KBN_FIELD_TYPES.NUMBER,
Copy link
Contributor

Choose a reason for hiding this comment

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

Make it as function become redundant.
In such a case, filterFieldTypes type could get rid of function type,
and the getAvailableFields could be simplified:

image

get(aggConfig.schema, 'aggSettings.top_hits.allowStrings', false)
? '*'
: KBN_FIELD_TYPES.NUMBER,
filterFieldTypes: (aggConfig: IMetricAggConfig) => '*',
Copy link
Contributor

Choose a reason for hiding this comment

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

It's a * by default

Suggested change
filterFieldTypes: (aggConfig: IMetricAggConfig) => '*',

Copy link
Contributor

Choose a reason for hiding this comment

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

oh sorry,
I just see that these are in tests file,
anyway I mean, that filterFieldTypes as a function became redundant,
so you could even remove it from tests

const idSelected = `visEditorSplitBy__${agg.params.row}`;
function RowsOrColumnsControl({ editorStateParams, setStateParamValue }: AggControlProps) {
if (editorStateParams.row === undefined) {
editorStateParams.row = true;
Copy link
Contributor

@sulemanof sulemanof Mar 5, 2020

Choose a reason for hiding this comment

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

We do not prefer using object mutations in React, especially props mutations,
it may lead to issues which are hard to find then.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@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.

All the comments were fixed, didn’t find anything else. It’s a great step in simplifying agg configs!
LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes review v7.7.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants