mirror of
https://github.com/grafana/grafana.git
synced 2025-02-14 09:33:34 -06:00
* Variables: move state tree into a keyed state * Update public/app/features/variables/state/transactionReducer.ts Co-authored-by: kay delaney <45561153+kaydelaney@users.noreply.github.com> * Chore: fix prettier error * Chore: renamed slices and lastUid * Chore: rename toUidAction * Chore: rename dashboardVariableReducer * Chore: rename state prop back to templating * Chore renames variable.dashboardUid * Chore: rename toDashboardVariableIdentifier * Chore: rename getDashboardVariable * Chore: rename getDashboardVariablesState * Chore: rename getDashboardVariables * Chore: some more renames * Chore: small clean up * Chore: small rename * Chore: removes unused function * Chore: rename VariableModel.stateKey * Chore: rename KeyedVariableIdentifier.stateKey * user essentials mob! 🔱 * user essentials mob! 🔱 * user essentials mob! 🔱 * user essentials mob! 🔱 Co-authored-by: kay delaney <45561153+kaydelaney@users.noreply.github.com> Co-authored-by: kay delaney <kay@grafana.com> Co-authored-by: Alexandra Vargas <alexa1866@gmail.com> Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
27 lines
846 B
TypeScript
27 lines
846 B
TypeScript
import { ScopedVars, UrlQueryMap } from '@grafana/data';
|
|
import { getTemplateSrv } from '@grafana/runtime';
|
|
import { variableAdapters } from './adapters';
|
|
|
|
export function getVariablesUrlParams(scopedVars?: ScopedVars): UrlQueryMap {
|
|
const params: UrlQueryMap = {};
|
|
const variables = getTemplateSrv().getVariables();
|
|
|
|
for (let i = 0; i < variables.length; i++) {
|
|
const variable = variables[i];
|
|
if (scopedVars && scopedVars[variable.name] !== void 0) {
|
|
if (scopedVars[variable.name].skipUrlSync) {
|
|
continue;
|
|
}
|
|
params['var-' + variable.name] = scopedVars[variable.name].value;
|
|
} else {
|
|
// @ts-ignore
|
|
if (variable.skipUrlSync) {
|
|
continue;
|
|
}
|
|
params['var-' + variable.name] = variableAdapters.get(variable.type).getValueForUrl(variable as any);
|
|
}
|
|
}
|
|
|
|
return params;
|
|
}
|