From eaa57627786aec814774ce779a0993d143dc117e Mon Sep 17 00:00:00 2001 From: natellium Date: Wed, 12 Nov 2025 19:28:36 +0100 Subject: [PATCH] poc layout --- .../features/explore/CorrelationHelper.tsx | 141 ++++++++++-------- 1 file changed, 76 insertions(+), 65 deletions(-) diff --git a/public/app/features/explore/CorrelationHelper.tsx b/public/app/features/explore/CorrelationHelper.tsx index e107fd360ea..4b54a9ab4f0 100644 --- a/public/app/features/explore/CorrelationHelper.tsx +++ b/public/app/features/explore/CorrelationHelper.tsx @@ -1,9 +1,9 @@ import { css } from '@emotion/css'; import { useEffect, useId, useState } from 'react'; -import { useForm } from 'react-hook-form'; +import { Controller, useForm } from 'react-hook-form'; import { useAsync } from 'react-use'; -import { DataLinkTransformationConfig, ExploreCorrelationHelperData, GrafanaTheme2 } from '@grafana/data'; +import { DataLinkTransformationConfig, ExploreCorrelationHelperData, GrafanaTheme2, SelectableValue } from '@grafana/data'; import { Trans, t } from '@grafana/i18n'; import { Alert, @@ -15,6 +15,7 @@ import { Icon, IconButton, Input, + Select, Stack, Tooltip, useStyles2, @@ -35,6 +36,7 @@ interface Props { } interface FormValues { + type: string; label: string; description: string; } @@ -54,7 +56,11 @@ export const CorrelationHelper = ({ exploreId, correlations }: Props) => { ] ); - const { register, watch, getValues, setValue } = useForm(); + const { control, register, watch, getValues, setValue } = useForm({ + defaultValues: { + type: 'Link', + }, + }); const [isLabelDescOpen, setIsLabelDescOpen] = useState(false); const [isTransformOpen, setIsTransformOpen] = useState(false); const [showTransformationAddModal, setShowTransformationAddModal] = useState(false); @@ -164,16 +170,71 @@ export const CorrelationHelper = ({ exploreId, correlations }: Props) => { >
- - When saved, the {'{{resultField}}'} field will have a clickable link that runs your target - query below. Use the below variables in your query. When clicked, they're replaced with values from that - row. - + > */} +

+ When saved, the {correlations.resultField} field will have a clickable link that runs your target + query below. +

+ {/* */}
-
+
+ + +

General

+
+ + { + const typeOptions: Array> = [ + { label: 'Link', value: 'Link' }, + { label: 'Explore Query', value: 'Explore Query' }, + ]; + return ( + { + if (getValues('label') === '' && defaultLabel !== undefined) { + setValue('label', defaultLabel); + } + }} + /> + + + + + + {/* Transformations */} + Variables (optional) + + + + +

Use these variables in your target query. When a correlation link is clicked, each variable is filled in with its value from that row.

+
+ {Object.entries(correlations.vars).map(([name, value]) => (
@@ -186,58 +247,8 @@ export const CorrelationHelper = ({ exploreId, correlations }: Props) => {
))} -
-
- { - setIsLabelDescOpen(!isLabelDescOpen); - }} - label={ - - - Correlation Label / Description - - {!isLabelDescOpen && !loadingLabel && ( - {`Label: ${getValues('label') || defaultLabel}`} - )} - - } - > - - { - if (getValues('label') === '' && defaultLabel !== undefined) { - setValue('label', defaultLabel); - } - }} - /> - - - - - - { - setIsTransformOpen(!isTransformOpen); - }} - label={ - - Transformations - - - - - } - > + + {transformations.map((transformation, i) => { const { type, field, expression, mapValue } = transformation; @@ -288,8 +300,7 @@ export const CorrelationHelper = ({ exploreId, correlations }: Props) => { ); })} - - +
); };