Parcourir la source

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

Torkel Ödegaard il y a 7 ans
Parent
commit
9aef3f4fb1

+ 3 - 3
public/app/features/dashboard/dashgrid/DashboardPanel.tsx

@@ -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()}

+ 4 - 3
public/app/features/dashboard/dashgrid/PanelResizer.tsx

@@ -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
public/app/features/panel/panel_ctrl.ts

@@ -198,11 +198,10 @@ export class PanelCtrl {
   }
   }
 
 
   calculatePanelHeight() {
   calculatePanelHeight() {
-    if (this.panel.fullscreen) {
-      const docHeight = $('.react-grid-layout').height();
-      const editHeight = Math.floor(docHeight * 0.35);
-      const fullscreenHeight = Math.floor(docHeight * 0.8);
-      this.containerHeight = this.panel.isEditing ? editHeight : fullscreenHeight;
+    if (this.panel.isEditing) {
+      this.containerHeight = $('.panel-wrapper--edit').height();
+    } else if (this.panel.fullscreen)  {
+      this.containerHeight = $('.panel-wrapper--view').height();
     } 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
public/sass/components/_panel_editor.scss

@@ -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;
   }
   }