From 00bcb6138224f3db5ecc8b8c126a2b4aa947a09e Mon Sep 17 00:00:00 2001 From: Victor Marin <36818606+mdvictor@users.noreply.github.com> Date: Tue, 4 Feb 2025 16:54:29 +0200 Subject: [PATCH] DynamicDashboards: Open edit overlay on selection if pane is collapsed (#99885) * open edit pane on selection * stuff * use drawer instead for override panel options * reverts * closing edit pane while selection exists should also clear selection * set width --- .../edit-pane/DashboardEditPane.tsx | 53 ++++++++++++++----- .../edit-pane/DashboardEditPaneSplitter.tsx | 1 + 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/public/app/features/dashboard-scene/edit-pane/DashboardEditPane.tsx b/public/app/features/dashboard-scene/edit-pane/DashboardEditPane.tsx index 381011a89ff..86ed2e16772 100644 --- a/public/app/features/dashboard-scene/edit-pane/DashboardEditPane.tsx +++ b/public/app/features/dashboard-scene/edit-pane/DashboardEditPane.tsx @@ -1,4 +1,5 @@ -import { css } from '@emotion/css'; +import { css, cx } from '@emotion/css'; +import { Resizable } from 're-resizable'; import { useEffect, useRef } from 'react'; import { GrafanaTheme2 } from '@grafana/data'; @@ -120,13 +121,14 @@ export class DashboardEditPane extends SceneObjectBase { export interface Props { editPane: DashboardEditPane; isCollapsed: boolean; + openOverlay?: boolean; onToggleCollapse: () => void; } /** * Making the EditPane rendering completely standalone (not using editPane.Component) in order to pass custom react props */ -export function DashboardEditPaneRenderer({ editPane, isCollapsed, onToggleCollapse }: Props) { +export function DashboardEditPaneRenderer({ editPane, isCollapsed, onToggleCollapse, openOverlay }: Props) { // Activate the edit pane useEffect(() => { if (!editPane.state.selection) { @@ -143,6 +145,12 @@ export function DashboardEditPaneRenderer({ editPane, isCollapsed, onToggleColla }; }, [editPane]); + useEffect(() => { + if (isCollapsed && editPane.state.selection?.getSelectionEntries().length) { + editPane.clearSelection(); + } + }, [editPane, isCollapsed]); + const { selection } = useSceneObjectState(editPane, { shouldActivateOrKeepAlive: true }); const styles = useStyles2(getStyles); const paneRef = useRef(null); @@ -154,16 +162,24 @@ export function DashboardEditPaneRenderer({ editPane, isCollapsed, onToggleColla if (isCollapsed) { return ( -
- -
+ <> +
+ +
+ + {openOverlay && ( + + + + )} + ); } @@ -190,5 +206,18 @@ function getStyles(theme: GrafanaTheme2) { flexDirection: 'column', padding: theme.spacing(2, 1), }), + // @ts-expect-error csstype doesn't allow !important. see https://github.com/frenic/csstype/issues/114 + fixed: css({ + position: 'absolute !important', + }), + container: css({ + right: 0, + background: theme.colors.background.primary, + borderLeft: `1px solid ${theme.colors.border.weak}`, + boxShadow: theme.shadows.z3, + zIndex: theme.zIndex.navbarFixed, + overflowX: 'hidden', + overflowY: 'scroll', + }), }; } diff --git a/public/app/features/dashboard-scene/edit-pane/DashboardEditPaneSplitter.tsx b/public/app/features/dashboard-scene/edit-pane/DashboardEditPaneSplitter.tsx index adae0492c7e..b2fc279ccde 100644 --- a/public/app/features/dashboard-scene/edit-pane/DashboardEditPaneSplitter.tsx +++ b/public/app/features/dashboard-scene/edit-pane/DashboardEditPaneSplitter.tsx @@ -100,6 +100,7 @@ export function DashboardEditPaneSplitter({ dashboard, isEditing, body, controls editPane={editPane} isCollapsed={splitterState.collapsed} onToggleCollapse={onToggleCollapse} + openOverlay={selectionContext.selected.length > 0} />