mirror of
https://github.com/grafana/grafana.git
synced 2025-02-15 01:53:33 -06:00
* Templating: Introduce macros to simplify and optimize some scopedVars * Fixing tests * fix test * minor fix * refactoring so macros work with formatting * remove breaking change and keep current inconsistency * Rename valueIndex to rowIndex * Minor fixes * Added test dashboard * Added tags to dashboard * Update * Added test to check it returns match * Update * Fixed dashboard * fix
23 lines
801 B
TypeScript
23 lines
801 B
TypeScript
import { DataLinkBuiltInVars, ScopedVars, urlUtil } from '@grafana/data';
|
|
|
|
import { getTimeSrv } from '../dashboard/services/TimeSrv';
|
|
import { getVariablesUrlParams } from '../variables/getAllVariableValuesForUrl';
|
|
|
|
import { valueMacro } from './dataMacros';
|
|
import { MacroHandler } from './types';
|
|
|
|
export const macroRegistry: Record<string, MacroHandler> = {
|
|
['__value']: valueMacro,
|
|
[DataLinkBuiltInVars.includeVars]: includeVarsMacro,
|
|
[DataLinkBuiltInVars.keepTime]: urlTimeRangeMacro,
|
|
};
|
|
|
|
function includeVarsMacro(match: string, fieldPath?: string, scopedVars?: ScopedVars) {
|
|
const allVariablesParams = getVariablesUrlParams(scopedVars);
|
|
return urlUtil.toUrlParams(allVariablesParams);
|
|
}
|
|
|
|
function urlTimeRangeMacro() {
|
|
return urlUtil.toUrlParams(getTimeSrv().timeRangeForUrl());
|
|
}
|