[Vis: Default Editor] Prevent disabling of the only metrics agg#46575
[Vis: Default Editor] Prevent disabling of the only metrics agg#46575sulemanof merged 10 commits intoelastic:masterfrom
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
💚 Build Succeeded |
| export interface DefaultEditorAggGroupProps extends DefaultEditorAggCommonProps { | ||
| schemas: Schema[]; | ||
| addSchema: (schems: Schema) => void; | ||
| addSchema: (schemas: Schema) => void; |
There was a problem hiding this comment.
Spell checker plugin is a pretty useful thing 👍
| 0 | ||
| ); | ||
|
|
||
| if (!enabledAggsCount && metrics.length) { |
There was a problem hiding this comment.
Would it be clearer to have if enabledAggsCount > 0?
There was a problem hiding this comment.
This condition is checked whether there are no enabled aggs, e.g. enabledAggsCount === 0. If it's true, we make the first one is enabled.
| 0 | ||
| ); | ||
| const metricCount = group.reduce((count, aggregation: AggConfig) => { | ||
| return aggregation.schema.name === agg.schema.name ? ++count : count; |
There was a problem hiding this comment.
Why do we need to modify count here?
There was a problem hiding this comment.
This code calculates how many aggs there are with the same schema name as the current agg has.
|
I noticed one more case. Aggs in |
src/legacy/ui/public/vis/editors/default/components/agg_group.tsx
Outdated
Show resolved
Hide resolved
src/legacy/ui/public/vis/editors/default/components/agg_group.tsx
Outdated
Show resolved
Hide resolved
💚 Build Succeeded |
💚 Build Succeeded |
flash1293
left a comment
There was a problem hiding this comment.
Code LGTM, didn't test
…tic#46575) * Prevent disabling of the only metrics agg * Add unit tests * Fix when aggs with different schema name
…) (#47107) * Prevent disabling of the only metrics agg * Add unit tests * Fix when aggs with different schema name
Summary
Fixes #41571
When there are multiple Metrics aggs with different schema name: