diff --git a/.betterer.results b/.betterer.results index ff67f56f90c..219d704f96d 100644 --- a/.betterer.results +++ b/.betterer.results @@ -2882,6 +2882,9 @@ exports[`better eslint`] = { "public/app/features/dashboard-scene/scene/PanelMenuBehavior.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], + "public/app/features/dashboard-scene/scene/RowRepeaterBehavior.ts:5381": [ + [0, 0, 0, "Do not use any type assertions.", "0"] + ], "public/app/features/dashboard-scene/scene/Scopes/ScopesInput.tsx:5381": [ [0, 0, 0, "Do not use any type assertions.", "0"] ], diff --git a/public/app/features/dashboard-scene/scene/RowRepeaterBehavior.test.tsx b/public/app/features/dashboard-scene/scene/RowRepeaterBehavior.test.tsx index ec36dafc8e2..eb6d5fb73e5 100644 --- a/public/app/features/dashboard-scene/scene/RowRepeaterBehavior.test.tsx +++ b/public/app/features/dashboard-scene/scene/RowRepeaterBehavior.test.tsx @@ -94,6 +94,24 @@ describe('RowRepeaterBehavior', () => { }); }); + describe('Should not repeat row', () => { + it('Should ignore repeat process if the variable is not a multi select variable', async () => { + const { scene, grid, repeatBehavior } = buildScene({ variableQueryTime: 0 }, undefined, { isMulti: false }); + const gridStateUpdates = []; + grid.subscribeToState((state) => gridStateUpdates.push(state)); + + activateFullSceneTree(scene); + await new Promise((r) => setTimeout(r, 1)); + + // trigger another repeat cycle by changing the variable + repeatBehavior.performRepeat(); + + await new Promise((r) => setTimeout(r, 1)); + + expect(gridStateUpdates.length).toBe(0); + }); + }); + describe('Given scene empty row', () => { let scene: DashboardScene; let grid: SceneGridLayout; @@ -139,7 +157,11 @@ interface SceneOptions { repeatDirection?: RepeatDirection; } -function buildScene(options: SceneOptions, variableOptions?: VariableValueOption[]) { +function buildScene( + options: SceneOptions, + variableOptions?: VariableValueOption[], + variableStateOverrides?: { isMulti: boolean } +) { const repeatBehavior = new RowRepeaterBehavior({ variableName: 'server' }); const grid = new SceneGridLayout({ @@ -223,6 +245,7 @@ function buildScene(options: SceneOptions, variableOptions?: VariableValueOption { label: 'D', value: 'D1' }, { label: 'E', value: 'E1' }, ], + ...variableStateOverrides, }), ], }), diff --git a/public/app/features/dashboard-scene/scene/RowRepeaterBehavior.ts b/public/app/features/dashboard-scene/scene/RowRepeaterBehavior.ts index 5ef6c6137ec..9b96f31c1d6 100644 --- a/public/app/features/dashboard-scene/scene/RowRepeaterBehavior.ts +++ b/public/app/features/dashboard-scene/scene/RowRepeaterBehavior.ts @@ -77,7 +77,12 @@ export class RowRepeaterBehavior extends SceneObjectBase