From 7c04d4123ac17774176ef29a81326a91b6daa76b Mon Sep 17 00:00:00 2001 From: Paul Marbach Date: Wed, 3 Dec 2025 18:00:30 -0500 Subject: [PATCH] collapsible sections --- .../PanelDataPane/QueryTransformList.tsx | 346 +++++++++--------- 1 file changed, 178 insertions(+), 168 deletions(-) diff --git a/public/app/features/dashboard-scene/panel-edit/PanelDataPane/QueryTransformList.tsx b/public/app/features/dashboard-scene/panel-edit/PanelDataPane/QueryTransformList.tsx index 09a183821e1..2014572a241 100644 --- a/public/app/features/dashboard-scene/panel-edit/PanelDataPane/QueryTransformList.tsx +++ b/public/app/features/dashboard-scene/panel-edit/PanelDataPane/QueryTransformList.tsx @@ -69,6 +69,7 @@ export const QueryTransformList = memo( const [selectedContextIds, setSelectedContextIds] = useState([]); const [hovered, setHovered] = useState(null); const [viewingConnections, setViewingConnections] = useState(false); + const [collapsed, setCollapsed] = useState({ queries: false, transforms: false }); const onDragStart = () => { setIsDragging(true); @@ -339,193 +340,201 @@ export const QueryTransformList = memo( {/* Data Sources Section (Queries + Expressions) */} -
+ {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions */} +
setCollapsed((c) => ({ ...c, queries: !c.queries }))} + > + {t('dashboard-scene.query-transform-list.queries-expressions', 'Queries & Expressions')}
- {dataSourceItems.length > 0 ? ( - - {(provided, snapshot) => { - // Check if dragging from transformations section - const isDraggingFromOtherSection = - isDragging && snapshot.draggingFromThisWith === null && snapshot.isDraggingOver; + {!collapsed.queries && + (dataSourceItems.length > 0 ? ( + + {(provided, snapshot) => { + // Check if dragging from transformations section + const isDraggingFromOtherSection = + isDragging && snapshot.draggingFromThisWith === null && snapshot.isDraggingOver; - return ( -
- - {filteredDataSourceItems.map((item) => ( -
- - {(provided, snapshot) => ( -
- handleCardClick(item.id)} - onAddQuery={onAddQuery} - onAddTransform={onAddTransform} - onAddExpression={onAddExpression} - {...getHandlers(item)} - /> -
- )} -
-
- + + {filteredDataSourceItems.map((item) => ( +
+ + > + {(provided, snapshot) => ( +
+ handleCardClick(item.id)} + onAddExpression={onAddExpression} + onAddQuery={onAddQuery} + onAddTransform={onAddTransform} + {...getHandlers(item)} + /> +
+ )} +
+
+ +
-
- ))} - {provided.placeholder} - + ))} + {provided.placeholder} + -
-
- +
+
+ +
-
- ); - }} - - ) : ( - - )} + ); + }} + + ) : ( + + ))} {/* Transformations Section */} -
+ {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions */} +
setCollapsed((c) => ({ ...c, transforms: !c.transforms }))} + > + {t('dashboard-scene.query-transform-list.transformations', 'Transformations')}
- {transformItems.length > 0 ? ( - - {(provided, snapshot) => { - // Check if dragging from data sources section - const isDraggingFromOtherSection = - isDragging && snapshot.draggingFromThisWith === null && snapshot.isDraggingOver; + {!collapsed.transforms && + (transformItems.length > 0 ? ( + + {(provided, snapshot) => { + // Check if dragging from data sources section + const isDraggingFromOtherSection = + isDragging && snapshot.draggingFromThisWith === null && snapshot.isDraggingOver; - return ( -
- - {transformItems.map((item) => ( -
- - {(provided, snapshot) => ( -
- handleCardClick(item.id)} - onAddQuery={onAddQuery} - onAddTransform={onAddTransform} - onAddExpression={onAddExpression} - {...getHandlers(item)} - /> -
- )} -
-
- + return ( +
+ + {transformItems.map((item) => ( +
+ + {(provided, snapshot) => ( +
+ handleCardClick(item.id)} + onAddExpression={onAddExpression} + onAddQuery={onAddQuery} + onAddTransform={onAddTransform} + {...getHandlers(item)} + /> +
+ )} +
+
+ +
+ ))} + {provided.placeholder} +
+
+
+
- ))} - {provided.placeholder} - -
-
-
-
- ); - }} - - ) : ( - - )} + ); + }} + + ) : ( + + ))}
@@ -592,6 +601,7 @@ const getStyles = (theme: GrafanaTheme2) => { color: theme.colors.text.primary, }), sectionLabel: css({ + cursor: 'pointer', fontFamily: theme.typography.fontFamilyMonospace, fontSize: theme.typography.bodySmall.fontSize, color: theme.colors.text.maxContrast,