Fixed issues with panel size in edit mode, fixes #14703

This commit is contained in:
Torkel Ödegaard
2019-01-02 10:54:57 +01:00
parent 6f998541c8
commit 9aef3f4fb1
4 changed files with 12 additions and 12 deletions
@@ -160,14 +160,14 @@ export class DashboardPanel extends PureComponent<Props, State> {
return ( return (
<div className={containerClass}> <div className={containerClass}>
<PanelResizer <PanelResizer
isEditing={!!isEditing} isEditing={isEditing}
panel={panel} panel={panel}
render={(panelHeight: number | 'inherit') => ( render={styles => (
<div <div
className={panelWrapperClass} className={panelWrapperClass}
onMouseEnter={this.onMouseEnter} onMouseEnter={this.onMouseEnter}
onMouseLeave={this.onMouseLeave} onMouseLeave={this.onMouseLeave}
style={{ height: panelHeight }} style={styles}
> >
{plugin.exports.Panel && this.renderReactPanel()} {plugin.exports.Panel && this.renderReactPanel()}
{plugin.exports.PanelCtrl && this.renderAngularPanel()} {plugin.exports.PanelCtrl && this.renderAngularPanel()}
@@ -1,4 +1,4 @@
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
import { throttle } from 'lodash'; import { throttle } from 'lodash';
import Draggable from 'react-draggable'; import Draggable from 'react-draggable';
@@ -6,7 +6,7 @@ import { PanelModel } from '../panel_model';
interface Props { interface Props {
isEditing: boolean; isEditing: boolean;
render: (height: number | 'inherit') => JSX.Element; render: (styles: object) => JSX.Element;
panel: PanelModel; panel: PanelModel;
} }
@@ -19,6 +19,7 @@ export class PanelResizer extends PureComponent<Props, State> {
prevEditorHeight: number; prevEditorHeight: number;
throttledChangeHeight: (height: number) => void; throttledChangeHeight: (height: number) => void;
throttledResizeDone: () => void; throttledResizeDone: () => void;
noStyles: object = {};
constructor(props) { constructor(props) {
super(props); super(props);
@@ -65,7 +66,7 @@ export class PanelResizer extends PureComponent<Props, State> {
return ( return (
<> <>
{render(isEditing ? editorHeight : 'inherit')} {render(isEditing ? {height: editorHeight} : this.noStyles)}
{isEditing && ( {isEditing && (
<div className="panel-editor-container__resizer"> <div className="panel-editor-container__resizer">
<Draggable axis="y" grid={[100, 1]} onDrag={this.onDrag} position={{ x: 0, y: 0 }}> <Draggable axis="y" grid={[100, 1]} onDrag={this.onDrag} position={{ x: 0, y: 0 }}>
+4 -5
View File
@@ -198,11 +198,10 @@ export class PanelCtrl {
} }
calculatePanelHeight() { calculatePanelHeight() {
if (this.panel.fullscreen) { if (this.panel.isEditing) {
const docHeight = $('.react-grid-layout').height(); this.containerHeight = $('.panel-wrapper--edit').height();
const editHeight = Math.floor(docHeight * 0.35); } else if (this.panel.fullscreen) {
const fullscreenHeight = Math.floor(docHeight * 0.8); this.containerHeight = $('.panel-wrapper--view').height();
this.containerHeight = this.panel.isEditing ? editHeight : fullscreenHeight;
} else { } else {
this.containerHeight = this.panel.gridPos.h * GRID_CELL_HEIGHT + (this.panel.gridPos.h - 1) * GRID_CELL_VMARGIN; this.containerHeight = this.panel.gridPos.h * GRID_CELL_HEIGHT + (this.panel.gridPos.h - 1) * GRID_CELL_VMARGIN;
} }
+1 -1
View File
@@ -14,7 +14,7 @@
&--view { &--view {
flex: 1 1 0; flex: 1 1 0;
height: 80%; height: 90%;
margin: 0 $dashboard-padding; margin: 0 $dashboard-padding;
padding-top: $dashboard-padding; padding-top: $dashboard-padding;
} }