Skip to content

Commit b8ea479

Browse files
authored
Enable panel resizing (#105)
1 parent 111a571 commit b8ea479

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

public/app/features/dashboard/dashgrid/DashboardGrid.tsx

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import classNames from 'classnames';
22
import React, { PureComponent, CSSProperties } from 'react';
33
import ReactGridLayout, { ItemCallback } from 'react-grid-layout';
4+
import { connect } from 'react-redux';
45
import AutoSizer from 'react-virtualized-auto-sizer';
56
import { Subscription } from 'rxjs';
67

78
import { config } from '@grafana/runtime';
89
import { GRID_CELL_HEIGHT, GRID_CELL_VMARGIN, GRID_COLUMN_COUNT } from 'app/core/constants';
910
import { contextSrv } from 'app/core/services/context_srv';
11+
import { StoreState } from 'app/types';
1012
import { DashboardPanelsChangedEvent } from 'app/types/events';
1113

1214
import { AddLibraryPanelWidget } from '../components/AddLibraryPanelWidget';
@@ -24,8 +26,10 @@ export interface Props {
2426
editPanel: PanelModel | null;
2527
viewPanel: PanelModel | null;
2628
hidePanelMenus?: boolean;
29+
isFnDashboard?: boolean;
2730
}
28-
export class DashboardGrid extends PureComponent<Props> {
31+
32+
export class Component extends PureComponent<Props> {
2933
private panelMap: { [key: string]: PanelModel } = {};
3034
private eventSubs = new Subscription();
3135
private windowHeight = 1200;
@@ -216,7 +220,7 @@ export class DashboardGrid extends PureComponent<Props> {
216220
};
217221

218222
render() {
219-
const { isEditable, dashboard } = this.props;
223+
const { isEditable, dashboard, isFnDashboard } = this.props;
220224

221225
if (config.featureToggles.emptyDashboardPage && dashboard.panels.length === 0) {
222226
return <DashboardEmpty dashboard={dashboard} canCreate={isEditable} />;
@@ -249,7 +253,7 @@ export class DashboardGrid extends PureComponent<Props> {
249253
<ReactGridLayout
250254
width={width}
251255
isDraggable={draggable}
252-
isResizable={isEditable}
256+
isResizable={isFnDashboard ? true : isEditable}
253257
containerPadding={[0, 0]}
254258
useCSSTransforms={true}
255259
margin={[GRID_CELL_VMARGIN, GRID_CELL_VMARGIN]}
@@ -336,3 +340,11 @@ function translateGridHeightToScreenHeight(gridHeight: number): number {
336340
}
337341

338342
GrafanaGridItem.displayName = 'GridItemWithDimensions';
343+
344+
function mapStateToProps() {
345+
return (state: StoreState) => ({
346+
isFnDashboard: state.fnGlobalState.FNDashboard,
347+
});
348+
}
349+
350+
export const DashboardGrid = connect(mapStateToProps)(Component);

0 commit comments

Comments
 (0)