From 7b0a59d6e80c4731a7556c79ae5b3c4a59906e3a Mon Sep 17 00:00:00 2001 From: Oscar Kilhed Date: Tue, 16 Jan 2024 09:52:40 +0100 Subject: [PATCH] add add and remove buttons --- .../PanelDataTransformationsTab.tsx | 53 +++++++++++++++---- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/public/app/features/dashboard-scene/panel-edit/PanelDataPane/PanelDataTransformations/PanelDataTransformationsTab.tsx b/public/app/features/dashboard-scene/panel-edit/PanelDataPane/PanelDataTransformations/PanelDataTransformationsTab.tsx index 4f75cd0d5c4..defe6326108 100644 --- a/public/app/features/dashboard-scene/panel-edit/PanelDataPane/PanelDataTransformations/PanelDataTransformationsTab.tsx +++ b/public/app/features/dashboard-scene/panel-edit/PanelDataPane/PanelDataTransformations/PanelDataTransformationsTab.tsx @@ -1,9 +1,11 @@ +import { css } from '@emotion/css'; import React from 'react'; import { DragDropContext, Droppable } from 'react-beautiful-dnd'; -import { DataTransformerConfig, IconName } from '@grafana/data'; +import { DataTransformerConfig, GrafanaTheme2, IconName } from '@grafana/data'; +import { selectors } from '@grafana/e2e-selectors'; import { SceneObjectBase, SceneComponentProps, SceneDataTransformer } from '@grafana/scenes'; -import { Container, CustomScrollbar } from '@grafana/ui'; +import { Button, ButtonGroup, ConfirmModal, Container, CustomScrollbar, useStyles2 } from '@grafana/ui'; import { TransformationOperationRows } from 'app/features/dashboard/components/TransformationsEditor/TransformationOperationRows'; import { VizPanelManager } from '../../VizPanelManager'; @@ -31,7 +33,7 @@ export class PanelDataTransformationsTab if (dataProvider instanceof SceneDataTransformer) { return dataProvider.state.transformations.length; } else { - return 0; + return null; } } @@ -58,6 +60,7 @@ function TransformationsEditor(props: TransformationEditorProps) { const transformations: DataTransformerConfig[] = []; for (const t of dataState.transformations) { + // We can't have any CustomTransformerOperators in the panel editor. This get's rid of them and fixes the type. if ('id' in t) { transformations.push(t); } @@ -98,6 +101,7 @@ function TransformationsEditor(props: TransformationEditorProps) { } export function PanelDataTransformationsTabRendered({ model }: SceneComponentProps) { + const styles = useStyles2(getStyles); const panelManagerState = model.panelManager.useState(); const panelState = panelManagerState.panel.useState(); @@ -113,14 +117,45 @@ export function PanelDataTransformationsTabRendered({ model }: SceneComponentPro {dataState.transformations.length < 1 ? ( {}}> ) : ( - { - model.panelManager.changeTransformations(transformations); - }} - sceneDataTransformer={panelState.$data} - > + <> + { + model.panelManager.changeTransformations(transformations); + }} + sceneDataTransformer={panelState.$data} + > + + + + + {}} + onDismiss={() => {}} + /> + )} ); } + +function getStyles(theme: GrafanaTheme2) { + return { + removeAll: css` + margin-left: ${theme.spacing(2)}; + `, + }; +}