PanelInspector: hides Query tab for plugins without Query ability (#24216)

* PanelInspector: fixes so Query tab is hidden for plugins without Query ability

* Refactor: changes after PR comments
This commit is contained in:
Hugo Häggmark
2020-05-04 13:58:05 +02:00
committed by GitHub
parent 2d5e675d4e
commit 215f2e005b
4 changed files with 44 additions and 3 deletions

View File

@@ -27,6 +27,7 @@ import { config } from 'app/core/config';
import { getPanelInspectorStyles } from './styles';
import { StoreState } from 'app/types';
import { InspectDataTab } from './InspectDataTab';
import { supportsDataQuery } from '../PanelEditor/utils';
interface OwnProps {
dashboard: DashboardModel;
@@ -269,7 +270,7 @@ export class PanelInspectorUnconnected extends PureComponent<Props, State> {
const error = last?.error;
const tabs = [];
if (plugin && !plugin.meta.skipDataQuery) {
if (supportsDataQuery(plugin)) {
tabs.push({ label: 'Data', value: InspectTab.Data });
tabs.push({ label: 'Stats', value: InspectTab.Stats });
}
@@ -284,7 +285,7 @@ export class PanelInspectorUnconnected extends PureComponent<Props, State> {
tabs.push({ label: 'Error', value: InspectTab.Error });
}
if (dashboard.meta.canEdit) {
if (dashboard.meta.canEdit && supportsDataQuery(plugin)) {
tabs.push({ label: 'Query', value: InspectTab.Query });
}
return tabs;

View File

@@ -8,6 +8,7 @@ import { CopyToClipboard } from 'app/core/components/CopyToClipboard/CopyToClipb
import { CoreEvents } from 'app/types';
import { PanelModel } from 'app/features/dashboard/state';
import { getPanelInspectorStyles } from './styles';
import { supportsDataQuery } from '../PanelEditor/utils';
interface DsQuery {
isLoading: boolean;
@@ -188,6 +189,10 @@ export class QueryInspector extends PureComponent<Props, State> {
const styles = getPanelInspectorStyles();
const haveData = Object.keys(response).length > 0;
if (!supportsDataQuery(this.props.panel.plugin)) {
return null;
}
return (
<>
<div aria-label={selectors.components.PanelInspector.Query.content}>