From b42544526e39adcbbb07605cab3eacec7f26d2f8 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Tue, 17 Jan 2023 21:26:49 +0100 Subject: [PATCH] [v9.3.x] Dashboard: Making a dashboard editable does not allow resizing of panels (#59943) Dashboard: Making a dashboard editable does not allow resizing of panels (#59255) * DashboardGrid should rerender ReactGridLayout when mutable dashboard updates * add missing prop to test (cherry picked from commit db1e19fe8682219e248e7a91424e4a897af22f00) Co-authored-by: Polina Boneva <13227501+polibb@users.noreply.github.com> --- .../app/features/dashboard/containers/DashboardPage.tsx | 7 ++++++- .../features/dashboard/dashgrid/DashboardGrid.test.tsx | 1 + public/app/features/dashboard/dashgrid/DashboardGrid.tsx | 8 ++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/public/app/features/dashboard/containers/DashboardPage.tsx b/public/app/features/dashboard/containers/DashboardPage.tsx index 40c6b6100d8..67344d504f0 100644 --- a/public/app/features/dashboard/containers/DashboardPage.tsx +++ b/public/app/features/dashboard/containers/DashboardPage.tsx @@ -392,7 +392,12 @@ export class UnthemedDashboardPage extends PureComponent { )} - + {inspectPanel && } diff --git a/public/app/features/dashboard/dashgrid/DashboardGrid.test.tsx b/public/app/features/dashboard/dashgrid/DashboardGrid.test.tsx index 05af4a5831e..111583e7745 100644 --- a/public/app/features/dashboard/dashgrid/DashboardGrid.test.tsx +++ b/public/app/features/dashboard/dashgrid/DashboardGrid.test.tsx @@ -57,6 +57,7 @@ describe('DashboardGrid', () => { const props: Props = { editPanel: null, viewPanel: null, + isEditable: true, dashboard: getTestDashboard(), }; expect(() => render()).not.toThrow(); diff --git a/public/app/features/dashboard/dashgrid/DashboardGrid.tsx b/public/app/features/dashboard/dashgrid/DashboardGrid.tsx index 74f11cfea55..02a2204fbb7 100644 --- a/public/app/features/dashboard/dashgrid/DashboardGrid.tsx +++ b/public/app/features/dashboard/dashgrid/DashboardGrid.tsx @@ -17,6 +17,7 @@ import { DashboardPanel } from './DashboardPanel'; export interface Props { dashboard: DashboardModel; + isEditable: boolean; editPanel: PanelModel | null; viewPanel: PanelModel | null; } @@ -200,7 +201,7 @@ export class DashboardGrid extends PureComponent { } render() { - const { dashboard } = this.props; + const { isEditable } = this.props; /** * We have a parent with "flex: 1 1 0" we need to reset it to "flex: 1 1 auto" to have the AutoSizer @@ -215,14 +216,13 @@ export class DashboardGrid extends PureComponent { return null; } - const draggable = width <= 769 ? false : dashboard.meta.canEdit; + const draggable = width <= 769 ? false : isEditable; /* Disable draggable if mobile device, solving an issue with unintentionally moving panels. https://github.com/grafana/grafana/issues/18497 theme.breakpoints.md = 769 */ - return ( /** * The children is using a width of 100% so we need to guarantee that it is wrapped @@ -233,7 +233,7 @@ export class DashboardGrid extends PureComponent {