mirror of
https://github.com/grafana/grafana.git
synced 2025-08-03 04:22:13 +08:00
Variables: move state tree into a keyed state (#44642)
* 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>
This commit is contained in:
@ -4,6 +4,8 @@ import { createQueryVariableAdapter } from './query/adapter';
|
||||
import { getVariablesUrlParams } from './getAllVariableValuesForUrl';
|
||||
import { initTemplateSrv } from '../../../test/helpers/initTemplateSrv';
|
||||
|
||||
const key = 'key';
|
||||
|
||||
describe('getAllVariableValuesForUrl', () => {
|
||||
beforeAll(() => {
|
||||
variableAdapters.register(createQueryVariableAdapter());
|
||||
@ -12,10 +14,11 @@ describe('getAllVariableValuesForUrl', () => {
|
||||
describe('with multi value', () => {
|
||||
beforeEach(() => {
|
||||
setTemplateSrv(
|
||||
initTemplateSrv([
|
||||
initTemplateSrv(key, [
|
||||
{
|
||||
type: 'query',
|
||||
name: 'test',
|
||||
rootStateKey: key,
|
||||
current: { value: ['val1', 'val2'] },
|
||||
getValueForUrl: function () {
|
||||
return this.current.value;
|
||||
@ -34,9 +37,10 @@ describe('getAllVariableValuesForUrl', () => {
|
||||
describe('skip url sync', () => {
|
||||
beforeEach(() => {
|
||||
setTemplateSrv(
|
||||
initTemplateSrv([
|
||||
initTemplateSrv(key, [
|
||||
{
|
||||
name: 'test',
|
||||
rootStateKey: key,
|
||||
skipUrlSync: true,
|
||||
current: { value: 'value' },
|
||||
getValueForUrl: function () {
|
||||
@ -56,10 +60,11 @@ describe('getAllVariableValuesForUrl', () => {
|
||||
describe('with multi value with skip url sync', () => {
|
||||
beforeEach(() => {
|
||||
setTemplateSrv(
|
||||
initTemplateSrv([
|
||||
initTemplateSrv(key, [
|
||||
{
|
||||
type: 'query',
|
||||
name: 'test',
|
||||
rootStateKey: key,
|
||||
skipUrlSync: true,
|
||||
current: { value: ['val1', 'val2'] },
|
||||
getValueForUrl: function () {
|
||||
@ -78,7 +83,9 @@ describe('getAllVariableValuesForUrl', () => {
|
||||
|
||||
describe('fillVariableValuesForUrl with multi value and scopedVars', () => {
|
||||
beforeEach(() => {
|
||||
setTemplateSrv(initTemplateSrv([{ type: 'query', name: 'test', current: { value: ['val1', 'val2'] } }]));
|
||||
setTemplateSrv(
|
||||
initTemplateSrv(key, [{ type: 'query', name: 'test', rootStateKey: key, current: { value: ['val1', 'val2'] } }])
|
||||
);
|
||||
});
|
||||
|
||||
it('should set scoped value as url params', () => {
|
||||
@ -91,7 +98,9 @@ describe('getAllVariableValuesForUrl', () => {
|
||||
|
||||
describe('fillVariableValuesForUrl with multi value, scopedVars and skip url sync', () => {
|
||||
beforeEach(() => {
|
||||
setTemplateSrv(initTemplateSrv([{ type: 'query', name: 'test', current: { value: ['val1', 'val2'] } }]));
|
||||
setTemplateSrv(
|
||||
initTemplateSrv(key, [{ type: 'query', name: 'test', rootStateKey: key, current: { value: ['val1', 'val2'] } }])
|
||||
);
|
||||
});
|
||||
|
||||
it('should not set scoped value as url params', () => {
|
||||
|
Reference in New Issue
Block a user