diff --git a/public/app/features/scenes/scenes/index.tsx b/public/app/features/scenes/scenes/index.tsx index 65189c47175..f4dd79f8131 100644 --- a/public/app/features/scenes/scenes/index.tsx +++ b/public/app/features/scenes/scenes/index.tsx @@ -9,7 +9,7 @@ import { getGridWithRowLayoutTest } from './gridWithRow'; import { getNestedScene } from './nested'; import { getQueryVariableDemo } from './queryVariableDemo'; import { getSceneWithRows } from './sceneWithRows'; -import { getVariablesDemo } from './variablesDemo'; +import { getVariablesDemo, getVariablesDemoWithAll } from './variablesDemo'; interface SceneDef { title: string; @@ -27,6 +27,7 @@ export function getScenes(): SceneDef[] { { title: 'Grid with rows and different queries and time ranges', getScene: getGridWithMultipleTimeRanges }, { title: 'Multiple grid layouts test', getScene: getMultipleGridLayoutTest }, { title: 'Variables', getScene: getVariablesDemo }, + { title: 'Variables with All values', getScene: getVariablesDemoWithAll }, { title: 'Query variable', getScene: getQueryVariableDemo }, ]; } diff --git a/public/app/features/scenes/scenes/variablesDemo.tsx b/public/app/features/scenes/scenes/variablesDemo.tsx index 5849de39481..bb7cffe5a46 100644 --- a/public/app/features/scenes/scenes/variablesDemo.tsx +++ b/public/app/features/scenes/scenes/variablesDemo.tsx @@ -85,3 +85,74 @@ export function getVariablesDemo(standalone: boolean): Scene { return standalone ? new Scene(state) : new EmbeddedScene(state); } + +export function getVariablesDemoWithAll(): Scene { + const scene = new Scene({ + title: 'Variables with All values', + $variables: new SceneVariableSet({ + variables: [ + new TestVariable({ + name: 'server', + query: 'A.*', + value: 'AA', + text: 'AA', + includeAll: true, + defaultToAll: true, + delayMs: 1000, + options: [], + }), + new TestVariable({ + name: 'pod', + query: 'A.$server.*', + value: [], + delayMs: 1000, + isMulti: true, + includeAll: true, + defaultToAll: true, + text: '', + options: [], + }), + new TestVariable({ + name: 'handler', + query: 'A.$server.$pod.*', + value: [], + delayMs: 1000, + includeAll: true, + defaultToAll: false, + isMulti: true, + text: '', + options: [], + }), + ], + }), + layout: new SceneFlexLayout({ + direction: 'row', + children: [ + new SceneFlexLayout({ + children: [ + new VizPanel({ + pluginId: 'timeseries', + title: 'handler: $handler', + $data: getQueryRunnerWithRandomWalkQuery({ + alias: 'handler: $handler', + }), + }), + new SceneCanvasText({ + size: { width: '40%' }, + text: 'server: ${server} pod:${pod}', + fontSize: 20, + align: 'center', + }), + ], + }), + ], + }), + $timeRange: new SceneTimeRange(), + actions: [new SceneTimePicker({})], + subMenu: new SceneSubMenu({ + children: [new VariableValueSelectors({})], + }), + }); + + return scene; +} diff --git a/public/app/features/scenes/variables/components/VariableValueSelect.tsx b/public/app/features/scenes/variables/components/VariableValueSelect.tsx index c746fa9988c..348821f2174 100644 --- a/public/app/features/scenes/variables/components/VariableValueSelect.tsx +++ b/public/app/features/scenes/variables/components/VariableValueSelect.tsx @@ -1,34 +1,13 @@ import { isArray } from 'lodash'; import React from 'react'; -import { Select, MultiSelect } from '@grafana/ui'; +import { MultiSelect, Select } from '@grafana/ui'; import { SceneComponentProps } from '../../core/types'; import { MultiValueVariable } from '../variants/MultiValueVariable'; export function VariableValueSelect({ model }: SceneComponentProps) { - const { value, key, loading, isMulti, options } = model.useState(); - - if (isMulti) { - return ( - { - model.changeValueTo( - newValue.map((v) => v.value!), - newValue.map((v) => v.label!) - ); - }} - /> - ); - } + const { value, key, loading } = model.useState(); return (