mirror of https://github.com/grafana/grafana.git
Import: fix dashboard imports with expressions (#43630)
This commit is contained in:
parent
238345b62d
commit
b09d498484
|
|
@ -6,6 +6,7 @@ import (
|
|||
"regexp"
|
||||
|
||||
"github.com/grafana/grafana/pkg/components/simplejson"
|
||||
"github.com/grafana/grafana/pkg/expr"
|
||||
"github.com/grafana/grafana/pkg/plugins"
|
||||
)
|
||||
|
||||
|
|
@ -47,6 +48,13 @@ func (e *DashTemplateEvaluator) Eval() (*simplejson.Json, error) {
|
|||
inputType := inputDefJson.Get("type").MustString()
|
||||
input := e.findInput(inputName, inputType)
|
||||
|
||||
// force expressions value to `__expr__`
|
||||
if inputDefJson.Get("pluginId").MustString() == expr.DatasourceType {
|
||||
input = &plugins.ImportDashboardInput{
|
||||
Value: expr.DatasourceType,
|
||||
}
|
||||
}
|
||||
|
||||
if input == nil {
|
||||
return nil, &DashboardInputMissingError{VariableName: inputName}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import {
|
|||
Legend,
|
||||
} from '@grafana/ui';
|
||||
import { DataSourcePicker } from '@grafana/runtime';
|
||||
import { ExpressionDatasourceRef } from '@grafana/runtime/src/utils/DataSourceWithBackend';
|
||||
import { selectors } from '@grafana/e2e-selectors';
|
||||
|
||||
import { FolderPicker } from 'app/core/components/Select/FolderPicker';
|
||||
|
|
@ -107,6 +108,9 @@ export const ImportDashboardForm: FC<Props> = ({
|
|||
</Field>
|
||||
{inputs.dataSources &&
|
||||
inputs.dataSources.map((input: DataSourceInput, index: number) => {
|
||||
if (input.pluginId === ExpressionDatasourceRef.type) {
|
||||
return null;
|
||||
}
|
||||
const dataSourceOption = `dataSources[${index}]`;
|
||||
const current = watchDataSources ?? [];
|
||||
return (
|
||||
|
|
|
|||
Loading…
Reference in New Issue