From de1e70a474cfb31135348fddfe6932c533f04788 Mon Sep 17 00:00:00 2001 From: Dominik Prokop Date: Thu, 23 Apr 2020 20:36:42 +0200 Subject: [PATCH] NewPanelEditor: don't break when plugin is skipDataQuery (#23836) --- .../components/PanelEditor/PanelEditor.tsx | 78 +++++++++++-------- .../components/PanelEditor/state/selectors.ts | 4 + 2 files changed, 48 insertions(+), 34 deletions(-) diff --git a/public/app/features/dashboard/components/PanelEditor/PanelEditor.tsx b/public/app/features/dashboard/components/PanelEditor/PanelEditor.tsx index e76bc3b9998..debf450ed15 100644 --- a/public/app/features/dashboard/components/PanelEditor/PanelEditor.tsx +++ b/public/app/features/dashboard/components/PanelEditor/PanelEditor.tsx @@ -151,10 +151,39 @@ export class PanelEditorUnconnected extends PureComponent { updatePanelEditorUIState({ isPanelOptionsVisible: !uiState.isPanelOptionsVisible }); }; + renderPanel = (styles: EditorStyles) => { + const { dashboard, panel, tabs, uiState } = this.props; + return ( +
+ {this.renderPanelToolbar(styles)} +
+ + {({ width, height }) => { + if (width < 3 || height < 3) { + return null; + } + return ( +
+
+ +
+
+ ); + }} +
+
+
+ ); + }; renderHorizontalSplit(styles: EditorStyles) { const { dashboard, panel, tabs, data, uiState } = this.props; - - return ( + return tabs.length > 0 ? ( { onDragStarted={this.onDragStarted} onDragFinished={size => this.onDragFinished(Pane.Top, size)} > -
- {this.renderPanelToolbar(styles)} -
- - {({ width, height }) => { - if (width < 3 || height < 3) { - return null; - } - return ( -
-
- -
-
- ); - }} -
-
-
+ {this.renderPanel(styles)}
+ ) : ( + this.renderPanel(styles) ); } @@ -371,7 +378,7 @@ enum Pane { export const getStyles = stylesFactory((theme: GrafanaTheme, props: Props) => { const { uiState } = props; const handleColor = theme.palette.blue95; - const paneSpaceing = theme.spacing.md; + const paneSpacing = theme.spacing.md; const resizer = css` font-style: italic; @@ -415,7 +422,10 @@ export const getStyles = stylesFactory((theme: GrafanaTheme, props: Props) => { flex-direction: column; height: 100%; width: 100%; - padding-right: ${uiState.isPanelOptionsVisible ? 0 : paneSpaceing}; + padding-right: ${uiState.isPanelOptionsVisible ? 0 : paneSpacing}; + `, + mainPaneWrapperNoTabs: css` + padding-bottom: ${paneSpacing}; `, variablesWrapper: css` display: flex; @@ -424,13 +434,13 @@ export const getStyles = stylesFactory((theme: GrafanaTheme, props: Props) => { flex: 1 1 0; min-height: 0; width: 100%; - padding-left: ${paneSpaceing}; + padding-left: ${paneSpacing}; `, resizerV: cx( resizer, css` cursor: col-resize; - width: ${paneSpaceing}; + width: ${paneSpacing}; border-right-width: 1px; margin-top: 18px; ` @@ -438,13 +448,13 @@ export const getStyles = stylesFactory((theme: GrafanaTheme, props: Props) => { resizerH: cx( resizer, css` - height: ${paneSpaceing}; + height: ${paneSpacing}; cursor: row-resize; position: relative; top: 0px; z-index: 1; border-top-width: 1px; - margin-left: ${paneSpaceing}; + margin-left: ${paneSpacing}; ` ), tabsWrapper: css` @@ -460,7 +470,7 @@ export const getStyles = stylesFactory((theme: GrafanaTheme, props: Props) => { `, panelToolbar: css` display: flex; - padding: ${paneSpaceing} 0 ${paneSpaceing} ${paneSpaceing}; + padding: ${paneSpacing} 0 ${paneSpacing} ${paneSpacing}; justify-content: space-between; flex-wrap: wrap; `, diff --git a/public/app/features/dashboard/components/PanelEditor/state/selectors.ts b/public/app/features/dashboard/components/PanelEditor/state/selectors.ts index 121edcec6bc..0913a8f9be2 100644 --- a/public/app/features/dashboard/components/PanelEditor/state/selectors.ts +++ b/public/app/features/dashboard/components/PanelEditor/state/selectors.ts @@ -12,6 +12,10 @@ export const getPanelEditorTabs = memoizeOne((location: LocationState, plugin?: let defaultTab = PanelEditorTabId.Visualize; + if (plugin.meta.skipDataQuery) { + return []; + } + if (!plugin.meta.skipDataQuery) { defaultTab = PanelEditorTabId.Query;