From 298f8b00282da3c27d33d421056b869fecb56ad4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=A4ggmark?= Date: Wed, 20 May 2020 14:15:06 +0200 Subject: [PATCH] PanelInspector: hides unsupported data display options for Panel type (#24918) (cherry picked from commit 0b5d8187715005c9f0e969224ca44c137d9ab0d4) --- .../components/Inspector/InspectDataTab.tsx | 75 ++++++++++++------- 1 file changed, 47 insertions(+), 28 deletions(-) diff --git a/public/app/features/dashboard/components/Inspector/InspectDataTab.tsx b/public/app/features/dashboard/components/Inspector/InspectDataTab.tsx index f80b3147c54..6bb5bd8fd07 100644 --- a/public/app/features/dashboard/components/Inspector/InspectDataTab.tsx +++ b/public/app/features/dashboard/components/Inspector/InspectDataTab.tsx @@ -110,8 +110,53 @@ export class InspectDataTab extends PureComponent { }); } + renderDataOptions = () => { + const { options, onOptionsChange, panel } = this.props; + const { transformId } = this.state; + const styles = getPanelInspectorStyles(); + + const panelTransformations = panel.getTransformations(); + const showPanelTransformationsOption = + panelTransformations && panelTransformations.length > 0 && (transformId as any) !== 'join by time'; + const showFieldConfigsOption = !panel.plugin?.fieldConfigRegistry.isEmpty(); + const showDataOptions = showPanelTransformationsOption || showFieldConfigsOption; + + if (!showDataOptions) { + return null; + } + + return ( +
+ + {showPanelTransformationsOption && ( +
+ onOptionsChange({ ...options, withTransforms: !options.withTransforms })} + /> +
+ )} + {showFieldConfigsOption && ( +
+ onOptionsChange({ ...options, withFieldConfig: !options.withFieldConfig })} + /> +
+ )} +
+
+ ); + }; + render() { - const { isLoading, data, options, onOptionsChange } = this.props; + const { isLoading, data } = this.props; const { dataFrameIndex, transformId, transformationOptions } = this.state; const styles = getPanelInspectorStyles(); @@ -136,8 +181,6 @@ export class InspectDataTab extends PureComponent { }; }); - const panelTransformations = this.props.panel.getTransformations(); - return (
@@ -169,31 +212,7 @@ export class InspectDataTab extends PureComponent { )}
- -
- - {panelTransformations && panelTransformations.length > 0 && (transformId as any) !== 'join by time' && ( -
- onOptionsChange({ ...options, withTransforms: !options.withTransforms })} - /> -
- )} -
- onOptionsChange({ ...options, withFieldConfig: !options.withFieldConfig })} - /> -
-
-
+ {this.renderDataOptions()}