mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 12:14:08 -06:00
Varibles: Fixes so clicking on Selected will not include All (#29844)
This commit is contained in:
parent
356fa0dce6
commit
dd326d296e
@ -15,7 +15,7 @@ import {
|
||||
updateSearchQuery,
|
||||
} from './reducer';
|
||||
import { reducerTester } from '../../../../../test/core/redux/reducerTester';
|
||||
import { QueryVariableModel, VariableTag, VariableOption } from '../../types';
|
||||
import { QueryVariableModel, VariableOption, VariableTag } from '../../types';
|
||||
import { ALL_VARIABLE_TEXT, ALL_VARIABLE_VALUE } from '../../state/types';
|
||||
|
||||
const getVariableTestContext = (extend: Partial<OptionsPickerState>) => {
|
||||
@ -570,7 +570,7 @@ describe('optionsPickerReducer', () => {
|
||||
});
|
||||
|
||||
describe('when toggleAllOptions is dispatched', () => {
|
||||
it('should toggle all values to true', () => {
|
||||
it('should toggle all values except All to true', () => {
|
||||
const { initialState } = getVariableTestContext({
|
||||
options: [
|
||||
{ text: 'All', value: '$__all', selected: false },
|
||||
@ -587,12 +587,11 @@ describe('optionsPickerReducer', () => {
|
||||
.thenStateShouldEqual({
|
||||
...initialState,
|
||||
options: [
|
||||
{ text: 'All', value: '$__all', selected: true },
|
||||
{ text: 'All', value: '$__all', selected: false },
|
||||
{ text: 'A', value: 'A', selected: true },
|
||||
{ text: 'B', value: 'B', selected: true },
|
||||
],
|
||||
selectedValues: [
|
||||
{ text: 'All', value: '$__all', selected: true },
|
||||
{ text: 'A', value: 'A', selected: true },
|
||||
{ text: 'B', value: 'B', selected: true },
|
||||
],
|
||||
|
@ -221,10 +221,12 @@ const optionsPickerSlice = createSlice({
|
||||
return applyStateChanges(state, updateOptions);
|
||||
}
|
||||
|
||||
state.selectedValues = state.options.map(option => ({
|
||||
...option,
|
||||
selected: true,
|
||||
}));
|
||||
state.selectedValues = state.options
|
||||
.filter(option => option.value !== ALL_VARIABLE_VALUE)
|
||||
.map(option => ({
|
||||
...option,
|
||||
selected: true,
|
||||
}));
|
||||
|
||||
return applyStateChanges(state, updateOptions);
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user