Skip to content

Enable panel resizing #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions public/app/features/dashboard/dashgrid/DashboardGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import classNames from 'classnames';
import React, { PureComponent, CSSProperties } from 'react';
import ReactGridLayout, { ItemCallback } from 'react-grid-layout';
import { connect } from 'react-redux';
import AutoSizer from 'react-virtualized-auto-sizer';
import { Subscription } from 'rxjs';

import { config } from '@grafana/runtime';
import { GRID_CELL_HEIGHT, GRID_CELL_VMARGIN, GRID_COLUMN_COUNT } from 'app/core/constants';
import { contextSrv } from 'app/core/services/context_srv';
import { StoreState } from 'app/types';
import { DashboardPanelsChangedEvent } from 'app/types/events';

import { AddLibraryPanelWidget } from '../components/AddLibraryPanelWidget';
Expand All @@ -24,8 +26,10 @@ export interface Props {
editPanel: PanelModel | null;
viewPanel: PanelModel | null;
hidePanelMenus?: boolean;
isFnDashboard?: boolean;
}
export class DashboardGrid extends PureComponent<Props> {

export class Component extends PureComponent<Props> {
private panelMap: { [key: string]: PanelModel } = {};
private eventSubs = new Subscription();
private windowHeight = 1200;
Expand Down Expand Up @@ -216,7 +220,7 @@ export class DashboardGrid extends PureComponent<Props> {
};

render() {
const { isEditable, dashboard } = this.props;
const { isEditable, dashboard, isFnDashboard } = this.props;

if (config.featureToggles.emptyDashboardPage && dashboard.panels.length === 0) {
return <DashboardEmpty dashboard={dashboard} canCreate={isEditable} />;
Expand Down Expand Up @@ -249,7 +253,7 @@ export class DashboardGrid extends PureComponent<Props> {
<ReactGridLayout
width={width}
isDraggable={draggable}
isResizable={isEditable}
isResizable={isFnDashboard ? true : isEditable}
containerPadding={[0, 0]}
useCSSTransforms={true}
margin={[GRID_CELL_VMARGIN, GRID_CELL_VMARGIN]}
Expand Down Expand Up @@ -336,3 +340,11 @@ function translateGridHeightToScreenHeight(gridHeight: number): number {
}

GrafanaGridItem.displayName = 'GridItemWithDimensions';

function mapStateToProps() {
return (state: StoreState) => ({
isFnDashboard: state.fnGlobalState.FNDashboard,
});
}

export const DashboardGrid = connect(mapStateToProps)(Component);