Correlations: Add transformation editor (#66217)

* There was an attempt

* Change disabled state based on transformation type

* Add validation to transformation type

* Revert "Add validation to transformation type"

This reverts commit 2188a3d9a93aec5eeafcdd40510391ba1a53671a.

* Add validation to transformation type

* Move transformations editor to a separate file

* Make name more descriptive

* Ensure type dropdown has always the same width

* Add tooltips around transformation options

* Slight style changes

* Remove autofocus on append, integrate read only to transformationeditor, save values that disappear so they come back

* Remove yaml changes

* Have variable background color work with alternating colors on different themes

* Make expression required for regular expressions

* Remove unused empty form object

* Fix bug about transformation’s values saved in memory

* Better validation formatting for expression

* Add labels and (for now) non working test, attempt to fix saved transformation delete/add bug

* Fix datalink comment

* Remove fancy CSS due to background change

* Fix deleting saved transformation bug, finish tests

* Consolidate transformation types

* Double check aria labels

* Change aria labels, fix tests

* Add a transformation with the create correlation test

---------

Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com>
This commit is contained in:
Kristina
2023-04-18 07:17:30 -05:00
committed by GitHub
parent 15c9ced944
commit 9d69d3173f
8 changed files with 447 additions and 37 deletions

View File

@@ -52,15 +52,20 @@ export interface DataLink<T extends DataQuery = any> {
origin?: DataLinkConfigOrigin;
}
/** @internal */
export enum SupportedTransformationTypes {
/**
* We provide tooltips with information about these to guide the user, please
* check for validity when adding more transformation types.
*
* @internal
*/
export enum SupportedTransformationType {
Regex = 'regex',
Logfmt = 'logfmt',
}
/** @internal */
export interface DataLinkTransformationConfig {
type: SupportedTransformationTypes;
type: SupportedTransformationType;
field?: string;
expression?: string;
mapValue?: string;

View File

@@ -1,4 +1,4 @@
import { UseFormReturn, FieldValues, FieldErrors } from 'react-hook-form';
import { UseFormReturn, FieldValues, FieldErrors, FieldArrayMethodProps } from 'react-hook-form';
export type { SubmitHandler as FormsOnSubmit, FieldErrors as FormFieldErrors } from 'react-hook-form';
export type FormAPI<T extends FieldValues> = Omit<UseFormReturn<T>, 'trigger' | 'handleSubmit'> & {
@@ -9,7 +9,7 @@ type FieldArrayValue = Partial<FieldValues> | Array<Partial<FieldValues>>;
export interface FieldArrayApi {
fields: Array<Record<string, any>>;
append: (value: FieldArrayValue) => void;
append: (value: FieldArrayValue, options?: FieldArrayMethodProps) => void;
prepend: (value: FieldArrayValue) => void;
remove: (index?: number | number[]) => void;
swap: (indexA: number, indexB: number) => void;