From 71658d1e769470707e33f3b4c158645368479aeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 15 Dec 2017 16:23:26 +0100 Subject: [PATCH] grid: disable resize and drag on non editable dashboards, closes #10235 --- package.json | 2 +- .../dashboard/dashgrid/DashboardGrid.tsx | 43 ++++++++++++------- yarn.lock | 6 +-- 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 6bcd140cc1b..3f3d67ca691 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "postcss-browser-reporter": "^0.5.0", "postcss-loader": "^2.0.6", "postcss-reporter": "^5.0.0", - "prettier": "1.7.3", + "prettier": "1.9.2", "react-test-renderer": "^16.0.0", "sass-lint": "^1.10.2", "sass-loader": "^6.0.6", diff --git a/public/app/features/dashboard/dashgrid/DashboardGrid.tsx b/public/app/features/dashboard/dashgrid/DashboardGrid.tsx index be8f1822d62..3f65c33c90d 100644 --- a/public/app/features/dashboard/dashgrid/DashboardGrid.tsx +++ b/public/app/features/dashboard/dashgrid/DashboardGrid.tsx @@ -1,16 +1,28 @@ import React from 'react'; import ReactGridLayout from 'react-grid-layout'; -import {GRID_CELL_HEIGHT, GRID_CELL_VMARGIN, GRID_COLUMN_COUNT} from 'app/core/constants'; -import {DashboardPanel} from './DashboardPanel'; -import {DashboardModel} from '../dashboard_model'; -import {PanelContainer} from './PanelContainer'; -import {PanelModel} from '../panel_model'; +import { GRID_CELL_HEIGHT, GRID_CELL_VMARGIN, GRID_COLUMN_COUNT } from 'app/core/constants'; +import { DashboardPanel } from './DashboardPanel'; +import { DashboardModel } from '../dashboard_model'; +import { PanelContainer } from './PanelContainer'; +import { PanelModel } from '../panel_model'; import classNames from 'classnames'; import sizeMe from 'react-sizeme'; let lastGridWidth = 1200; -function GridWrapper({size, layout, onLayoutChange, children, onDragStop, onResize, onResizeStop, onWidthChange, className}) { +function GridWrapper({ + size, + layout, + onLayoutChange, + children, + onDragStop, + onResize, + onResizeStop, + onWidthChange, + className, + isResizable, + isDraggable, +}) { if (size.width === 0) { console.log('size is zero!'); } @@ -25,8 +37,8 @@ function GridWrapper({size, layout, onLayoutChange, children, onDragStop, onResi PanelContainer; @@ -54,7 +66,7 @@ export class DashboardGrid extends React.Component { gridToPanelMap: any; panelContainer: PanelContainer; dashboard: DashboardModel; - panelMap: {[id: string]: PanelModel}; + panelMap: { [id: string]: PanelModel }; constructor(props) { super(props); @@ -65,7 +77,7 @@ export class DashboardGrid extends React.Component { this.onDragStop = this.onDragStop.bind(this); this.onWidthChange = this.onWidthChange.bind(this); - this.state = {animated: false}; + this.state = { animated: false }; // subscribe to dashboard events this.dashboard = this.panelContainer.getDashboard(); @@ -153,7 +165,7 @@ export class DashboardGrid extends React.Component { componentDidMount() { setTimeout(() => { this.setState(() => { - return {animated: true}; + return { animated: true }; }); }); } @@ -162,7 +174,7 @@ export class DashboardGrid extends React.Component { const panelElements = []; for (let panel of this.dashboard.panels) { - const panelClasses = classNames({panel: true, 'panel--fullscreen': panel.fullscreen}); + const panelClasses = classNames({ panel: true, 'panel--fullscreen': panel.fullscreen }); panelElements.push(
@@ -176,8 +188,10 @@ export class DashboardGrid extends React.Component { render() { return ( { ); } } - diff --git a/yarn.lock b/yarn.lock index 9ce16177ee7..d5aa06eaffb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7668,9 +7668,9 @@ preserve@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" -prettier@1.7.3: - version "1.7.3" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.7.3.tgz#8e6974725273914b1c47439959dd3d3ba53664b6" +prettier@1.9.2: + version "1.9.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.9.2.tgz#96bc2132f7a32338e6078aeb29727178c6335827" pretty-bytes@^1.0.0: version "1.0.4"