mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
chore: Only show Queries tab for panel plugins with isDataPanel set to true
This commit is contained in:
parent
ec02ddd27b
commit
0019e0ffc9
@ -30,6 +30,32 @@ interface PanelEditorTab {
|
|||||||
text: string;
|
text: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum PanelEditorTabIds {
|
||||||
|
Queries = 'queries',
|
||||||
|
Visualization = 'visualization',
|
||||||
|
Advanced = 'advanced',
|
||||||
|
Alert = 'alert'
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PanelEditorTab {
|
||||||
|
id: string;
|
||||||
|
text: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const panelEditorTabTexts = {
|
||||||
|
[PanelEditorTabIds.Queries]: 'Queries',
|
||||||
|
[PanelEditorTabIds.Visualization]: 'Visualization',
|
||||||
|
[PanelEditorTabIds.Advanced]: 'Panel Options',
|
||||||
|
[PanelEditorTabIds.Alert]: 'Alert',
|
||||||
|
};
|
||||||
|
|
||||||
|
const getPanelEditorTab = (tabId: PanelEditorTabIds): PanelEditorTab => {
|
||||||
|
return {
|
||||||
|
id: tabId,
|
||||||
|
text: panelEditorTabTexts[tabId]
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
export class PanelEditor extends PureComponent<PanelEditorProps> {
|
export class PanelEditor extends PureComponent<PanelEditorProps> {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
@ -72,31 +98,26 @@ export class PanelEditor extends PureComponent<PanelEditorProps> {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { plugin } = this.props;
|
const { plugin } = this.props;
|
||||||
let activeTab = store.getState().location.query.tab || 'queries';
|
let activeTab: PanelEditorTabIds = store.getState().location.query.tab || PanelEditorTabIds.Queries;
|
||||||
|
|
||||||
const tabs: PanelEditorTab[] = [
|
const tabs: PanelEditorTab[] = [
|
||||||
{ id: 'queries', text: 'Queries' },
|
getPanelEditorTab(PanelEditorTabIds.Queries),
|
||||||
{ id: 'visualization', text: 'Visualization' },
|
getPanelEditorTab(PanelEditorTabIds.Visualization),
|
||||||
{ id: 'advanced', text: 'Panel Options' },
|
getPanelEditorTab(PanelEditorTabIds.Advanced),
|
||||||
];
|
];
|
||||||
|
|
||||||
// handle panels that do not have queries tab
|
// handle panels that do not have queries tab
|
||||||
if (plugin.exports.PanelCtrl) {
|
if (!plugin.isDataPanel) {
|
||||||
if (!plugin.exports.PanelCtrl.prototype.onDataReceived) {
|
// remove queries tab
|
||||||
// remove queries tab
|
tabs.shift();
|
||||||
tabs.shift();
|
// switch tab
|
||||||
// switch tab
|
if (activeTab === PanelEditorTabIds.Queries) {
|
||||||
if (activeTab === 'queries') {
|
activeTab = PanelEditorTabIds.Visualization;
|
||||||
activeTab = 'visualization';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.alertingEnabled && plugin.id === 'graph') {
|
if (config.alertingEnabled && plugin.id === 'graph') {
|
||||||
tabs.push({
|
tabs.push(getPanelEditorTab(PanelEditorTabIds.Alert));
|
||||||
id: 'alert',
|
|
||||||
text: 'Alert',
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user