diff --git a/public/app/features/dashboard/components/PanelEditor/PanelEditor.tsx b/public/app/features/dashboard/components/PanelEditor/PanelEditor.tsx index bcdcbe71842..d8ca3636174 100644 --- a/public/app/features/dashboard/components/PanelEditor/PanelEditor.tsx +++ b/public/app/features/dashboard/components/PanelEditor/PanelEditor.tsx @@ -1,6 +1,6 @@ import React, { PureComponent } from 'react'; import { GrafanaTheme, FieldConfigSource, PanelData, LoadingState, DefaultTimeRange, PanelEvents } from '@grafana/data'; -import { stylesFactory, Forms, FieldConfigEditor, CustomScrollbar } from '@grafana/ui'; +import { stylesFactory, Forms, FieldConfigEditor, CustomScrollbar, selectThemeVariant } from '@grafana/ui'; import { css, cx } from 'emotion'; import config from 'app/core/config'; @@ -13,14 +13,23 @@ import { StoreState } from '../../../../types/store'; import { connect } from 'react-redux'; import { updateLocation } from '../../../../core/reducers/location'; import { Unsubscribable } from 'rxjs'; +import { PanelTitle } from './PanelTitle'; const getStyles = stylesFactory((theme: GrafanaTheme) => { + const handleColor = selectThemeVariant( + { + dark: theme.colors.dark9, + light: theme.colors.gray6, + }, + theme.type + ); + const resizer = css` padding: 3px; font-style: italic; background: ${theme.colors.panelBg}; &:hover { - background: ${theme.colors.headingColor}; + background: ${handleColor}; } `; @@ -54,8 +63,23 @@ const getStyles = stylesFactory((theme: GrafanaTheme) => { ), noScrollPaneContent: css` height: 100%; + width: 100%; overflow: hidden; `, + toolbar: css` + padding: ${theme.spacing.sm}; + height: 48px; + display: flex; + justify-content: space-between; + `, + panes: css` + height: calc(100% - 48px); + position: relative; + `, + toolbarLeft: css` + display: flex; + align-items: center; + `, }; }); @@ -204,6 +228,11 @@ export class PanelEditor extends PureComponent { console.log('TODO, save splitter settings'); }; + onPanelTitleChange = (title: string) => { + this.state.panel.title = title; + this.forceUpdate(); + }; + render() { const { dashboard } = this.props; const { panel } = this.state; @@ -215,56 +244,62 @@ export class PanelEditor extends PureComponent { return (
-
- - {panel.title} - - Discard - +
+
+ + +
+
+ + Discard + +
- (document.body.style.cursor = 'col-resize')} - onDragFinished={this.onDragFinished} - > +
(document.body.style.cursor = 'row-resize')} + minSize={50} + defaultSize={350} + resizerClassName={styles.resizerV} + onDragStarted={() => (document.body.style.cursor = 'col-resize')} onDragFinished={this.onDragFinished} > -
- -
+ (document.body.style.cursor = 'row-resize')} + onDragFinished={this.onDragFinished} + > +
+ +
+
+ +
+
- + +
+ {this.renderFieldOptions()} + {this.renderVisSettings()} +
+
-
- -
- {this.renderFieldOptions()} - {this.renderVisSettings()} -
-
-
- +
); } diff --git a/public/app/features/dashboard/components/PanelEditor/PanelTitle.tsx b/public/app/features/dashboard/components/PanelEditor/PanelTitle.tsx new file mode 100644 index 00000000000..4e0b900bcee --- /dev/null +++ b/public/app/features/dashboard/components/PanelEditor/PanelTitle.tsx @@ -0,0 +1,35 @@ +import React, { useState } from 'react'; +import { css } from 'emotion'; +import { Forms, useTheme } from '@grafana/ui'; + +interface PanelTitleProps { + value: string; + onChange: (value: string) => void; +} + +export const PanelTitle: React.FC = ({ value, onChange }) => { + const [isEditing, setIsEditing] = useState(false); + const theme = useTheme(); + return ( + <> + {isEditing ? ( + onChange(e.currentTarget.value)} + onBlur={() => setIsEditing(false)} + placeholder="Panel Title" + /> + ) : ( + setIsEditing(true)} + > + {value} + + )} + + ); +};