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

Hides advanced json for count metric #74636

Merged
merged 14 commits into from
Aug 31, 2020

Conversation

stratoula
Copy link
Contributor

@stratoula stratoula commented Aug 10, 2020

Summary

Closes #74241
We want to hide the advanced json input when the user selects the Count aggregation as it can't affect this specific aggregation.

Checklist

@stratoula stratoula added Feature:Aggregations Aggregation infrastructure (AggConfig, esaggs, ...) Feature:Vis Editor Visualization editor issues labels Aug 10, 2020
@stratoula stratoula changed the title remove advanced json for count agg Hides advanced json for count metric Aug 10, 2020
@stratoula stratoula marked this pull request as ready for review August 10, 2020 12:39
@stratoula stratoula requested a review from a team August 10, 2020 12:39
@stratoula stratoula added release_note:skip Skip the PR/issue when compiling release notes v7.10.0 v8.0.0 Team:Visualizations Visualization editors, elastic-charts and infrastructure labels Aug 10, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@@ -115,6 +115,7 @@ function getAggParamsToRender({
}

if (!paramEditor) {
if (agg.type.name === 'count' && param.type === 'json') return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Your solutions was tested locally and it works fine. But could you please use METRIC_TYPES.COUNT instead of hardcoded value.

Also from the design perspective I don't like idea to add some if's into high level component. From my point of view all of that edge cases should be handled in src/plugins/vis_default_editor/public/components/agg_params_map.ts

But looks like agg_params_map also requires some refactoring to exclude some fields from that map =( but I prefer to go this way

@sulemanof what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

In its simplest form, it looks like

agg_params_map.ts:

image

agg_params_helper.ts:
image

Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO,
the restriction of an any param should come from an agg type.
The source of building any aggregation on UI is the agg.type.params, which is based on agg config.
In that case, we should restrict the count metric have the json param in its config.
I could suggest smth like that:

src/plugins/data/common/search/aggs/metrics/count.ts

image

and than in src/plugins/data/common/search/aggs/agg_type.ts

image

The same is happening now to customLabel param:

image

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably yes, /plugins/data/common/search/aggs/metrics/count_fn.ts should be also updated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Than you both ❤️ Will look into this

@stratoula stratoula requested a review from a team as a code owner August 20, 2020 08:33
@lukeelmers lukeelmers self-requested a review August 20, 2020 16:38
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.

Overall the changes to the aggs service make sense. In the long run I'd like to completely remove the "magic" addition of the json param onto every agg type, and instead have each agg explicitly declare it so that you don't need something like a json: false setting. But that's pretty far outside the scope of this PR, so in the interim I'm comfortable with this approach.

...rest,
json: getParsedValue(args, 'json'),
},
params: rest,
Copy link
Member

Choose a reason for hiding this comment

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

We should remove the json argument from the function definition above as well, since it's no longer being used.

Note that this might cause a TS error because the function definition is using AggExpressionFunctionArgs which is pulling the relevant type from the AggParamsMapping. For count, the value used is BaseAggParams which includes json:

[METRIC_TYPES.COUNT]: BaseAggParams;

If TS gives you trouble, you may need to define an AggParamsMetricCount in the count.ts file without extending BaseAggParams as others agg types do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanx @lukeelmers , I missed that, TS looks happy btw :)

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@stratoula
Copy link
Contributor Author

@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.

LGTM 💟

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.

App arch code updates LGTM!

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@stratoula
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

page load bundle size

id value diff baseline
data 1.4MB -1.3KB 1.4MB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Member

@kertal kertal left a comment

Choose a reason for hiding this comment

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

Code LGTM, tested locally in Chrome, Firefox & Safari, works 👍
Bildschirmfoto 2020-08-31 um 11 31 31
Just one request regarding the PR's summary, could you provide a bit more details? many thx!

@stratoula stratoula merged commit 9ddd49a into elastic:master Aug 31, 2020
stratoula added a commit to stratoula/kibana that referenced this pull request Aug 31, 2020
* remove advanced json for count agg

* Remove only advanced json from count agg

* use Constant from data plugin

* add the logic to data plugin

* remove json arg from function definition

* remove unecessary translations

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
jloleysens added a commit to jloleysens/kibana that referenced this pull request Aug 31, 2020
…s-for-710

* 'master' of github.com:elastic/kibana: (43 commits)
  [APM] Chart units don't update when toggling the chart legends (elastic#74931)
  [ILM] Add support for frozen phase in UI (elastic#75968)
  Hides advanced json for count metric (elastic#74636)
  add client-side feature usage API (elastic#75486)
  [Maps] add drilldown support map embeddable (elastic#75598)
  [Enterprise Search] Request handler refactors/enhancements + update existing routes to use shared handler (elastic#76106)
  [Resolver] model `location.search` in redux (elastic#76140)
  [APM] Prevent imports of public in server code (elastic#75979)
  fix eslint issue
  skip flaky suite (elastic#76223)
  [APM] Transaction duration anomaly alerting integration (elastic#75719)
  [Transforms] Avoid using "Are you sure" (elastic#75932)
  [Security Solution][Exceptions] - Fix bug of alerts not updating after closure from exceptions modal (elastic#76145)
  [plugin-helpers] improve 3rd party KP plugin support (elastic#75019)
  [docs/getting-started] link to yarn v1 specifically (elastic#76169)
  [Security_Solution][Resolver] Resolver loading and error state (elastic#75600)
  Fixes App Search documentation links (elastic#76133)
  Fix alerts unable to create / update when the name has trailing whitepace(s) (elastic#76079)
  [Resolver] Fix useSelector usage (elastic#76129)
  [Enterprise Search] Migrate util and components from ent-search (elastic#76051)
  ...

# Conflicts:
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/data_tier_allocation/node_allocation.tsx
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.tsx
#	x-pack/plugins/index_lifecycle_management/public/application/services/policies/types.ts
#	x-pack/plugins/index_lifecycle_management/public/application/services/policies/warm_phase.ts
stratoula added a commit that referenced this pull request Aug 31, 2020
* remove advanced json for count agg

* Remove only advanced json from count agg

* use Constant from data plugin

* add the logic to data plugin

* remove json arg from function definition

* remove unecessary translations

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Aggregations Aggregation infrastructure (AggConfig, esaggs, ...) Feature:Vis Editor Visualization editor issues release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.10.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hide Advanced Json input for Count metric
7 participants