mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Variables: Fix for changing readonly query property (#35992)
* Variables: Fix for changing readonly query property * Docs: adds release * Docs: adds release
This commit is contained in:
parent
91cf062d0b
commit
ffc18ebbcf
@ -2,14 +2,23 @@ export type StringSelector = string;
|
|||||||
export type FunctionSelector = (id: string) => string;
|
export type FunctionSelector = (id: string) => string;
|
||||||
export type CssSelector = () => string;
|
export type CssSelector = () => string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @alpha
|
||||||
|
*/
|
||||||
export interface Selectors {
|
export interface Selectors {
|
||||||
[key: string]: StringSelector | FunctionSelector | CssSelector | UrlSelector | Selectors;
|
[key: string]: StringSelector | FunctionSelector | CssSelector | UrlSelector | Selectors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @alpha
|
||||||
|
*/
|
||||||
export type E2ESelectors<S extends Selectors> = {
|
export type E2ESelectors<S extends Selectors> = {
|
||||||
[P in keyof S]: S[P];
|
[P in keyof S]: S[P];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @alpha
|
||||||
|
*/
|
||||||
export interface UrlSelector extends Selectors {
|
export interface UrlSelector extends Selectors {
|
||||||
url: string | FunctionSelector;
|
url: string | FunctionSelector;
|
||||||
}
|
}
|
||||||
|
@ -293,6 +293,7 @@ describe('QueryRunners', () => {
|
|||||||
const target = runner.getTarget({ datasource, variable });
|
const target = runner.getTarget({ datasource, variable });
|
||||||
expect(target).toEqual({ refId: 'A', query: 'A query' });
|
expect(target).toEqual({ refId: 'A', query: 'A query' });
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('and ref id is missing', () => {
|
describe('and ref id is missing', () => {
|
||||||
it('then it should return correct target with dummy ref id', () => {
|
it('then it should return correct target with dummy ref id', () => {
|
||||||
const { runner, datasource, variable } = getDatasourceTestContext();
|
const { runner, datasource, variable } = getDatasourceTestContext();
|
||||||
|
@ -160,10 +160,7 @@ class DatasourceQueryRunner implements QueryRunner {
|
|||||||
|
|
||||||
getTarget({ datasource, variable }: GetTargetArgs) {
|
getTarget({ datasource, variable }: GetTargetArgs) {
|
||||||
if (hasDatasourceVariableSupport(datasource)) {
|
if (hasDatasourceVariableSupport(datasource)) {
|
||||||
if (!variable.query.refId) {
|
return { ...variable.query, refId: variable.query.refId ?? variableDummyRefId };
|
||||||
variable.query.refId = variableDummyRefId;
|
|
||||||
}
|
|
||||||
return variable.query;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Error("Couldn't create a target with supplied arguments.");
|
throw new Error("Couldn't create a target with supplied arguments.");
|
||||||
|
Loading…
Reference in New Issue
Block a user