-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement first version of new aggregation controls, including suppor…
…t 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 0efd3b2) * 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 <dennis@graylog.com>
- Loading branch information
1 parent
39e080a
commit 9f7c4e4
Showing
32 changed files
with
1,657 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...g2-web-interface/src/views/components/aggregationwizard/AggregationElementSelect.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (C) 2020 Graylog, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the Server Side Public License, version 1, | ||
* as published by MongoDB, Inc. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* Server Side Public License for more details. | ||
* | ||
* You should have received a copy of the Server Side Public License | ||
* along with this program. If not, see | ||
* <http://www.mongodb.com/licensing/server-side-public-license>. | ||
*/ | ||
import React from 'react'; | ||
import { render, screen } from 'wrappedTestingLibrary'; | ||
import selectEvent from 'react-select-event'; | ||
|
||
import AggregationElementSelect from './AggregationElementSelect'; | ||
import type { AggregationElement } from './aggregationElements/AggregationElementType'; | ||
|
||
const aggregationElements: Array<AggregationElement> = [ | ||
{ | ||
title: 'Metric', | ||
key: 'metric', | ||
order: 1, | ||
allowCreate: () => true, | ||
onCreate: () => {}, | ||
component: () => <div />, | ||
}, | ||
{ | ||
title: 'Sort', | ||
key: 'sort', | ||
order: 1, | ||
allowCreate: () => false, | ||
onCreate: () => {}, | ||
component: () => <div />, | ||
}, | ||
]; | ||
|
||
describe('AggregationElementSelect', () => { | ||
it('should select an aggregation element', async () => { | ||
const onElementCreateMock = jest.fn(); | ||
|
||
render(<AggregationElementSelect onElementCreate={onElementCreateMock} | ||
formValues={{ metrics: [] }} | ||
aggregationElements={aggregationElements} />); | ||
|
||
const aggregationElementSelect = screen.getByLabelText('Select an element to add ...'); | ||
|
||
await selectEvent.openMenu(aggregationElementSelect); | ||
await selectEvent.select(aggregationElementSelect, 'Metric'); | ||
|
||
expect(onElementCreateMock).toHaveBeenCalledTimes(1); | ||
expect(onElementCreateMock).toHaveBeenCalledWith('metric'); | ||
}); | ||
|
||
it('should not list already configured aggregation elements which can not be configured multiple times', async () => { | ||
render(<AggregationElementSelect onElementCreate={() => {}} | ||
formValues={{ metrics: [] }} | ||
aggregationElements={aggregationElements} />); | ||
|
||
const aggregationElementSelect = screen.getByLabelText('Select an element to add ...'); | ||
|
||
await selectEvent.openMenu(aggregationElementSelect); | ||
|
||
expect(screen.queryByText('Sort')).not.toBeInTheDocument(); | ||
expect(screen.getByText('Metric')).toBeInTheDocument(); | ||
}); | ||
}); |
Oops, something went wrong.