From 9f7c4e45e56f0a02638e725fab57a84089520513 Mon Sep 17 00:00:00 2001 From: Linus Pahl Date: Mon, 22 Mar 2021 13:39:42 +0100 Subject: [PATCH] Implement first version of new aggregation controls, including support for metric configuration. (#10281) * Creating basic `AggregationWizard` component. * Creating basic components for aggregation attribute configuration. * Rename aggregation attribute to aggregation action. * Improve aggregation actions structure and expandability. * Fixing typo. * Fixing headline font size and `AggregationWizard` props. * Creating test for `AggregationActionSelect`. * Creating test for `ActionConfigurationContainer`. * Creating test for `AggregationWizard`. * Clearing `AggregationActionSelect` value after selection an action. * Renaming aggregation action properties label to title and value to key. * Reverting `AggregationWizard` usage in views bindings. * Fixing linter warnings. * List aggregation action in `AggregationActionSelect` if it can be configured multiple times. * Renaming aggregation action to aggregation element. * Do not add new section for an already configured aggregation action. * Removing no longer needed `createDefault` series method. * Changing order of configured aggregation elements. * Always display configured aggregation elements in correct order. * Updating `AggregationElementSelect.test`.` * Creating `WidgetConfigForm`. * Moving `SearchBarForm` from `EditWidgetFrame` to `WidgetQueryControls`. * Rename `MetricConfiguration` to `MetricsConfiguration`. * Creating basic metric form with function and field select. * Enable widget configuration update for metrics. * Providing correct initial values for metrics configuration form. * Removing no longer needed aggregation wizard state by using `WidgetConfigForm` only. * Updating type definition of `SeriesConfig` value and constructor. * Splitting up `AggregationWizard` in multiple components. * Migrating `AggregationFunctionsStore` to ts. * Importing aggregation functions for metrics configuration directly from `AggregationFunctionsStore`. * Reverting `Series` and `SeriesConfiguration` constructor type definition changes. * Fixing type imports * Only display aggregation element configuraion container if form has related values. * Validating metric functions, triggering manual validation on initial mount. * Validate form on change/on mount. * Switching from field-level to form-level validation. * Handling percentile parameter for `percentile` function. * Do not include metrics errors in validation result if empty. * Include name field for metric. * Include placeholder for name field. * Fixing vertical scrolling of aggregation elements column in aggregation wizard. (cherry picked from commit 0efd3b222bcd41b198c92fbcd637152f7f948652) * Styling fixes * Removing section headlines to save vertical space. * Fixing horizontal scrolling of element configuration containers by adjusting bootstrap elements padding. The negative row / form-group margin caused the horizontal scroll bar. * Creating one file for each aggregation element. * Fixing types. * Fixing types. * Replacing aggregation element properties `isConfigured` and `multipleUse` with `allowCreate`. * Defining theme color for element separator. * Reducing element container padding. * Fixing `allowCreate` usage. * Providing form values as a prop for `AggregationElementSelect` to simplify testing. * Updating `AggregationElementSelect.test`. * Udpating `MetricsConfiguration.test`. * Adding missing key in `MetricsConfiguration`. * Extend PropType definition for common `Select` value with number. * Extending `AgggregationWizard.test` with tests for metrics element. * Fixing linter warnings * Updating `WidgetQueryControls.test` regarding `SearchBarForm` addition. * Implement `ElementConfigurationSection` for `MetricsConfiguration` which separates each section of the metrics element configuration. * Test configuration of metric with multiple functions. * Creating separate file for metric element tests. * Fixing linter warnings. * Reimplementing type definition for `Widget.tsx` config prop. * Fixing import path. Co-authored-by: Dennis Oelkers --- .../src/components/common/Select.tsx | 2 + .../components/WidgetQueryControls.test.tsx | 36 ++- .../views/components/WidgetQueryControls.tsx | 136 ++++++---- .../AggregationElementSelect.test.tsx | 72 ++++++ .../AggregationElementSelect.tsx | 61 +++++ .../AggregationWizard.test.tsx | 98 ++++++++ .../aggregationwizard/AggregationWizard.tsx | 144 +++++++++++ .../ElementsConfiguration.tsx | 79 ++++++ .../aggregationwizard/WidgetConfigForm.tsx | 63 +++++ .../AggregationWizard.metric.test.tsx | 232 ++++++++++++++++++ .../AggregationElementType.ts | 35 +++ .../aggregationElements/GroupByElement.ts | 29 +++ .../aggregationElements/MetricElement.ts | 109 ++++++++ .../aggregationElements/SortElement.ts | 32 +++ .../VisualizationElement.ts | 32 +++ .../aggregationElements/index.ts | 28 +++ .../ElementConfigurationContainer.test.tsx | 76 ++++++ .../ElementConfigurationContainer.tsx | 86 +++++++ .../ElementConfigurationSection.tsx | 40 +++ .../GroupByConfiguration.tsx | 35 +++ .../elementConfiguration/Metric.tsx | 117 +++++++++ .../MetricsConfiguration.tsx | 57 +++++ .../SortConfiguration.tsx | 35 +++ .../VisualizationConfiguration.tsx | 35 +++ .../views/components/common/EditableTitle.tsx | 1 - .../components/widgets/EditWidgetFrame.tsx | 72 ++---- .../widgets/SaveOrCancelButtons.tsx | 27 +- .../src/views/components/widgets/Widget.tsx | 2 +- .../views/components/widgets/WidgetHeader.css | 2 +- .../views/logic/aggregationbuilder/Series.ts | 11 +- .../logic/aggregationbuilder/SeriesConfig.ts | 4 +- ...sStore.js => AggregationFunctionsStore.ts} | 9 +- 32 files changed, 1657 insertions(+), 140 deletions(-) create mode 100644 graylog2-web-interface/src/views/components/aggregationwizard/AggregationElementSelect.test.tsx create mode 100644 graylog2-web-interface/src/views/components/aggregationwizard/AggregationElementSelect.tsx create mode 100644 graylog2-web-interface/src/views/components/aggregationwizard/AggregationWizard.test.tsx create mode 100644 graylog2-web-interface/src/views/components/aggregationwizard/AggregationWizard.tsx create mode 100644 graylog2-web-interface/src/views/components/aggregationwizard/ElementsConfiguration.tsx create mode 100644 graylog2-web-interface/src/views/components/aggregationwizard/WidgetConfigForm.tsx create mode 100644 graylog2-web-interface/src/views/components/aggregationwizard/__tests__/AggregationWizard.metric.test.tsx create mode 100644 graylog2-web-interface/src/views/components/aggregationwizard/aggregationElements/AggregationElementType.ts create mode 100644 graylog2-web-interface/src/views/components/aggregationwizard/aggregationElements/GroupByElement.ts create mode 100644 graylog2-web-interface/src/views/components/aggregationwizard/aggregationElements/MetricElement.ts create mode 100644 graylog2-web-interface/src/views/components/aggregationwizard/aggregationElements/SortElement.ts create mode 100644 graylog2-web-interface/src/views/components/aggregationwizard/aggregationElements/VisualizationElement.ts create mode 100644 graylog2-web-interface/src/views/components/aggregationwizard/aggregationElements/index.ts create mode 100644 graylog2-web-interface/src/views/components/aggregationwizard/elementConfiguration/ElementConfigurationContainer.test.tsx create mode 100644 graylog2-web-interface/src/views/components/aggregationwizard/elementConfiguration/ElementConfigurationContainer.tsx create mode 100644 graylog2-web-interface/src/views/components/aggregationwizard/elementConfiguration/ElementConfigurationSection.tsx create mode 100644 graylog2-web-interface/src/views/components/aggregationwizard/elementConfiguration/GroupByConfiguration.tsx create mode 100644 graylog2-web-interface/src/views/components/aggregationwizard/elementConfiguration/Metric.tsx create mode 100644 graylog2-web-interface/src/views/components/aggregationwizard/elementConfiguration/MetricsConfiguration.tsx create mode 100644 graylog2-web-interface/src/views/components/aggregationwizard/elementConfiguration/SortConfiguration.tsx create mode 100644 graylog2-web-interface/src/views/components/aggregationwizard/elementConfiguration/VisualizationConfiguration.tsx rename graylog2-web-interface/src/views/stores/{AggregationFunctionsStore.js => AggregationFunctionsStore.ts} (82%) diff --git a/graylog2-web-interface/src/components/common/Select.tsx b/graylog2-web-interface/src/components/common/Select.tsx index 298bdf485c14..cf67f2e81632 100644 --- a/graylog2-web-interface/src/components/common/Select.tsx +++ b/graylog2-web-interface/src/components/common/Select.tsx @@ -214,6 +214,7 @@ type Props = { optionRenderer?: (option: Option) => React.ReactElement, options: Array