grid: disable resize and drag on non editable dashboards, closes #10235

This commit is contained in:
Torkel Ödegaard 2017-12-15 16:23:26 +01:00
parent 4112abd699
commit 71658d1e76
3 changed files with 32 additions and 19 deletions

View File

@ -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",

View File

@ -10,7 +10,19 @@ 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
<ReactGridLayout
width={lastGridWidth}
className={className}
isDraggable={true}
isResizable={true}
isDraggable={isDraggable}
isResizable={isResizable}
measureBeforeMount={false}
containerPadding={[0, 0]}
useCSSTransforms={true}
@ -176,8 +188,10 @@ export class DashboardGrid extends React.Component<DashboardGridProps, any> {
render() {
return (
<SizedReactLayoutGrid
className={classNames({'layout': true, 'animated': this.state.animated})}
className={classNames({ layout: true, animated: this.state.animated })}
layout={this.buildLayout()}
isResizable={this.dashboard.meta.canEdit}
isDraggable={this.dashboard.meta.canEdit}
onLayoutChange={this.onLayoutChange}
onWidthChange={this.onWidthChange}
onDragStop={this.onDragStop}
@ -188,4 +202,3 @@ export class DashboardGrid extends React.Component<DashboardGridProps, any> {
);
}
}

View File

@ -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"