99 FlexBox ,
1010 FlexDirection ,
1111 Input ,
12+ List ,
1213} from '@influxdata/clockface'
1314import SearchableDropdown from 'src/shared/components/SearchableDropdown'
1415import WaitingText from 'src/shared/components/WaitingText'
@@ -20,12 +21,16 @@ import {ErrorHandling} from 'src/shared/decorators/errors'
2021
2122// Actions
2223import {
23- removeTagSelector ,
24+ addTagSelector ,
2425 searchTagKeys ,
2526 searchTagValues ,
2627 selectTagKey ,
2728 selectTagValue ,
29+ loadTagSelector ,
30+ removeTagSelector ,
2831} from 'src/timeMachine/actions/queryBuilderThunks'
32+ import { setBuilderTagValuesSelection } from 'src/timeMachine/actions/queryBuilder'
33+
2934import { isFlagEnabled } from 'src/shared/utils/featureFlag'
3035
3136import {
@@ -91,7 +96,7 @@ class TagSelector extends PureComponent<Props> {
9196 index === 0 &&
9297 ( selectedKey === '' || selectedKey === '_measurement' ) &&
9398 aggregateFunctionType !== 'group' &&
94- selectedValues . length <= 1
99+ ( isFlagEnabled ( 'measurementMultiselect' ) || selectedValues . length <= 1 )
95100 )
96101 }
97102
@@ -202,6 +207,35 @@ class TagSelector extends PureComponent<Props> {
202207 )
203208 }
204209
210+ private toggleSelectAll ( ) {
211+ const {
212+ selectedValues,
213+ onSetBuilderTagValuesSelection,
214+ onAddTagSelector,
215+ onRemoveTagSelector,
216+ index,
217+ isLast,
218+ shouldClearLast,
219+ onLoadTagSelector,
220+ } = this . props
221+
222+ if ( selectedValues . length === 1 && selectedValues [ 0 ] === '_all' ) {
223+ onSetBuilderTagValuesSelection ( 0 , [ ] )
224+
225+ if ( shouldClearLast ) {
226+ onRemoveTagSelector ( index + 1 )
227+ }
228+ } else {
229+ onSetBuilderTagValuesSelection ( 0 , [ '_all' ] )
230+
231+ if ( isLast ) {
232+ onAddTagSelector ( )
233+ } else {
234+ onLoadTagSelector ( index + 1 )
235+ }
236+ }
237+ }
238+
205239 private get values ( ) {
206240 const { selectedKey, values, valuesStatus, selectedValues} = this . props
207241
@@ -232,13 +266,38 @@ class TagSelector extends PureComponent<Props> {
232266 )
233267 }
234268
269+ // underscore values are not allowed for user data
270+ // so there shouldn't be collisions
271+ const selectedAll =
272+ selectedValues . length === 1 && selectedValues [ 0 ] === '_all'
273+
235274 return (
236275 < SelectorList
237- items = { values }
276+ items = { values . filter ( t => t !== '_all' ) }
238277 selectedItems = { selectedValues }
239278 onSelectItem = { this . handleSelectValue }
240- multiSelect = { ! this . props . isInCheckOverlay || this . isCompliant }
241- />
279+ multiSelect = {
280+ ! this . props . isInCheckOverlay ||
281+ ( this . isCompliant && isFlagEnabled ( 'measurementMultiselect' ) )
282+ }
283+ disabled = { selectedAll }
284+ >
285+ { this . isCompliant && isFlagEnabled ( 'measurementMultiselect' ) && (
286+ < List . Item
287+ className = "selector-list--item select-all"
288+ testID = "selector-list --select-all"
289+ key = "_all"
290+ value = "_all"
291+ onClick = { ( ) => this . toggleSelectAll ( ) }
292+ title = "Select All"
293+ selected = { selectedAll }
294+ size = { ComponentSize . ExtraSmall }
295+ >
296+ < List . Indicator type = "checkbox" />
297+ All Measurements
298+ </ List . Item >
299+ ) }
300+ </ SelectorList >
242301 )
243302 }
244303
@@ -350,6 +409,9 @@ const mstp = (state: AppState, ownProps: OwnProps) => {
350409 values = [ ...ADDITIONAL_GROUP_BY_COLUMNS , ...tags . map ( tag => tag . key ) ]
351410 }
352411 const isInCheckOverlay = getIsInCheckOverlay ( state )
412+ const isLast = ownProps . index === tags . length - 1
413+ const shouldClearLast =
414+ ownProps . index === tags . length - 2 && ! tags [ tags . length - 1 ] . values . length
353415
354416 return {
355417 aggregateFunctionType,
@@ -363,6 +425,8 @@ const mstp = (state: AppState, ownProps: OwnProps) => {
363425 valuesSearchTerm,
364426 keysSearchTerm,
365427 isInCheckOverlay,
428+ isLast,
429+ shouldClearLast,
366430 }
367431}
368432
@@ -375,6 +439,9 @@ const mdtp = {
375439 onSetBuilderAggregateFunctionType : setBuilderAggregateFunctionType ,
376440 onSetKeysSearchTerm : setKeysSearchTerm ,
377441 onSetValuesSearchTerm : setValuesSearchTerm ,
442+ onSetBuilderTagValuesSelection : setBuilderTagValuesSelection ,
443+ onAddTagSelector : addTagSelector ,
444+ onLoadTagSelector : loadTagSelector ,
378445}
379446
380447const connector = connect ( mstp , mdtp )
0 commit comments