mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
PanelEdit: Hide multi-/all-select datasource variables in datasource picker (#52142)
This commit is contained in:
@@ -24,7 +24,7 @@ import {
|
|||||||
instanceSettings as expressionInstanceSettings,
|
instanceSettings as expressionInstanceSettings,
|
||||||
} from 'app/features/expressions/ExpressionDatasource';
|
} from 'app/features/expressions/ExpressionDatasource';
|
||||||
|
|
||||||
import { DataSourceVariableModel } from '../variables/types';
|
import { isDataSource } from '../variables/guard';
|
||||||
|
|
||||||
import { importDataSourcePlugin } from './plugin_loader';
|
import { importDataSourcePlugin } from './plugin_loader';
|
||||||
|
|
||||||
@@ -245,11 +245,12 @@ export class DatasourceSrv implements DataSourceService {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (filters.variables) {
|
if (filters.variables) {
|
||||||
for (const variable of this.templateSrv.getVariables().filter((variable) => variable.type === 'datasource')) {
|
for (const variable of this.templateSrv.getVariables()) {
|
||||||
const dsVar = variable as DataSourceVariableModel;
|
if (!isDataSource(variable) || variable.multi || variable.includeAll) {
|
||||||
const first = dsVar.current.value === 'default' ? this.defaultName : dsVar.current.value;
|
continue;
|
||||||
const dsName = first as unknown as string;
|
}
|
||||||
const dsSettings = this.settingsMapByName[dsName];
|
const dsName = variable.current.value === 'default' ? this.defaultName : variable.current.value;
|
||||||
|
const dsSettings = !Array.isArray(dsName) && this.settingsMapByName[dsName];
|
||||||
|
|
||||||
if (dsSettings) {
|
if (dsSettings) {
|
||||||
const key = `$\{${variable.name}\}`;
|
const key = `$\{${variable.name}\}`;
|
||||||
|
@@ -25,6 +25,7 @@ import {
|
|||||||
VariableQueryEditorProps,
|
VariableQueryEditorProps,
|
||||||
VariableWithMultiSupport,
|
VariableWithMultiSupport,
|
||||||
VariableWithOptions,
|
VariableWithOptions,
|
||||||
|
DataSourceVariableModel,
|
||||||
} from './types';
|
} from './types';
|
||||||
|
|
||||||
export const isQuery = (model: VariableModel): model is QueryVariableModel => {
|
export const isQuery = (model: VariableModel): model is QueryVariableModel => {
|
||||||
@@ -39,6 +40,10 @@ export const isConstant = (model: VariableModel): model is ConstantVariableModel
|
|||||||
return model.type === 'constant';
|
return model.type === 'constant';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const isDataSource = (model: VariableModel): model is DataSourceVariableModel => {
|
||||||
|
return model.type === 'datasource';
|
||||||
|
};
|
||||||
|
|
||||||
export const isMulti = (model: VariableModel): model is VariableWithMultiSupport => {
|
export const isMulti = (model: VariableModel): model is VariableWithMultiSupport => {
|
||||||
const withMulti = model as VariableWithMultiSupport;
|
const withMulti = model as VariableWithMultiSupport;
|
||||||
return withMulti.hasOwnProperty('multi') && typeof withMulti.multi === 'boolean';
|
return withMulti.hasOwnProperty('multi') && typeof withMulti.multi === 'boolean';
|
||||||
|
Reference in New Issue
Block a user