@@ -105,6 +105,8 @@ import {
105
105
import { FILTER_SUPPORTED_TYPES , INPUT_WIDTH } from './constants' ;
106
106
import DependencyList from './DependencyList' ;
107
107
108
+ const FORM_ITEM_WIDTH = 260 ;
109
+
108
110
const TabPane = styled ( Tabs . TabPane ) `
109
111
padding: ${ ( { theme } ) => theme . gridUnit * 4 } px 0px;
110
112
` ;
@@ -136,8 +138,8 @@ const controlsOrder: ControlKey[] = [
136
138
'inverseSelection' ,
137
139
] ;
138
140
139
- export const StyledFormItem = styled ( FormItem ) `
140
- width: 49%;
141
+ export const StyledFormItem = styled ( FormItem ) < { expanded : boolean } > `
142
+ width: ${ ( { expanded } ) => ( expanded ? ' 49%' : ` ${ FORM_ITEM_WIDTH } px` ) } ;
141
143
margin-bottom: ${ ( { theme } ) => theme . gridUnit * 4 } px;
142
144
143
145
& .ant-form-item-label {
@@ -149,10 +151,10 @@ export const StyledFormItem = styled(FormItem)`
149
151
}
150
152
` ;
151
153
152
- export const StyledRowFormItem = styled ( FormItem ) `
154
+ export const StyledRowFormItem = styled ( FormItem ) < { expanded : boolean } > `
153
155
margin-bottom: 0;
154
156
padding-bottom: 0;
155
- min-width: 50%;
157
+ min-width: ${ ( { expanded } ) => ( expanded ? ' 50%' : ` ${ FORM_ITEM_WIDTH } px` ) } ;
156
158
157
159
& .ant-form-item-label {
158
160
padding-bottom: 0;
@@ -167,8 +169,8 @@ export const StyledRowFormItem = styled(FormItem)`
167
169
}
168
170
` ;
169
171
170
- export const StyledRowSubFormItem = styled ( FormItem ) `
171
- min-width: 50%;
172
+ export const StyledRowSubFormItem = styled ( FormItem ) < { expanded : boolean } > `
173
+ min-width: ${ ( { expanded } ) => ( expanded ? ' 50%' : ` ${ FORM_ITEM_WIDTH } px` ) } ;
172
174
173
175
& .ant-form-item-label {
174
176
padding-bottom: 0;
@@ -264,9 +266,9 @@ const StyledAsterisk = styled.span`
264
266
}
265
267
` ;
266
268
267
- const FilterTypeInfo = styled . div `
268
- ${ ( { theme } ) => `
269
- width: 49%;
269
+ const FilterTypeInfo = styled . div < { expanded : boolean } > `
270
+ ${ ( { theme, expanded } ) => `
271
+ width: ${ expanded ? ' 49%' : ` ${ FORM_ITEM_WIDTH } px` } ;
270
272
font-size: ${ theme . typography . sizes . s } px;
271
273
color: ${ theme . colors . grayscale . light1 } ;
272
274
margin:
@@ -300,6 +302,7 @@ export const FilterPanels = {
300
302
} ;
301
303
302
304
export interface FiltersConfigFormProps {
305
+ expanded : boolean ;
303
306
filterId : string ;
304
307
filterToEdit ?: Filter ;
305
308
removedFilters : Record < string , FilterRemoval > ;
@@ -334,6 +337,7 @@ const FILTER_TYPE_NAME_MAPPING = {
334
337
*/
335
338
const FiltersConfigForm = (
336
339
{
340
+ expanded,
337
341
filterId,
338
342
filterToEdit,
339
343
removedFilters,
@@ -376,7 +380,7 @@ const FiltersConfigForm = (
376
380
const nativeFilterVizTypes = Object . entries ( nativeFilterItems )
377
381
// @ts -ignore
378
382
. filter ( ( [ , { value } ] ) => value . behaviors ?. includes ( Behavior . NativeFilter ) )
379
- . map ( ( [ key ] ) => key ) ;
383
+ . map ( ( [ key ] ) => key as keyof typeof FILTER_SUPPORTED_TYPES ) ;
380
384
381
385
const loadedDatasets = useSelector < RootState , DatasourcesState > (
382
386
( { datasources } ) => datasources ,
@@ -411,6 +415,7 @@ const FiltersConfigForm = (
411
415
412
416
const { controlItems = { } , mainControlItems = { } } = formFilter
413
417
? getControlItemsMap ( {
418
+ expanded,
414
419
datasetId,
415
420
disabled : false ,
416
421
forceUpdate,
@@ -760,6 +765,7 @@ const FiltersConfigForm = (
760
765
761
766
const timeColumn = (
762
767
< StyledRowFormItem
768
+ expanded = { expanded }
763
769
name = { [ 'filters' , filterId , 'granularity_sqla' ] }
764
770
label = {
765
771
< >
@@ -807,13 +813,15 @@ const FiltersConfigForm = (
807
813
>
808
814
< StyledContainer >
809
815
< StyledFormItem
816
+ expanded = { expanded }
810
817
name = { [ 'filters' , filterId , 'type' ] }
811
818
hidden
812
819
initialValue = { NativeFilterType . NativeFilter }
813
820
>
814
821
< Input />
815
822
</ StyledFormItem >
816
823
< StyledFormItem
824
+ expanded = { expanded }
817
825
name = { [ 'filters' , filterId , 'name' ] }
818
826
label = { < StyledLabel > { t ( 'Filter name' ) } </ StyledLabel > }
819
827
initialValue = { filterToEdit ?. name }
@@ -822,6 +830,7 @@ const FiltersConfigForm = (
822
830
< Input { ...getFiltersConfigModalTestId ( 'name-input' ) } />
823
831
</ StyledFormItem >
824
832
< StyledFormItem
833
+ expanded = { expanded }
825
834
name = { [ 'filters' , filterId , 'filterType' ] }
826
835
rules = { [ { required : ! isRemoved , message : t ( 'Name is required' ) } ] }
827
836
initialValue = { filterToEdit ?. filterType || 'filter_select' }
@@ -867,7 +876,7 @@ const FiltersConfigForm = (
867
876
</ StyledFormItem >
868
877
</ StyledContainer >
869
878
{ formFilter ?. filterType === 'filter_time' && (
870
- < FilterTypeInfo >
879
+ < FilterTypeInfo expanded = { expanded } >
871
880
{ t ( `Dashboard time range filters apply to temporal columns defined in
872
881
the filter section of each chart. Add temporal columns to the chart
873
882
filters to have this dashboard filter impact those charts.` ) }
@@ -877,6 +886,7 @@ const FiltersConfigForm = (
877
886
< StyledRowContainer >
878
887
{ showDataset ? (
879
888
< StyledFormItem
889
+ expanded = { expanded }
880
890
name = { [ 'filters' , filterId , 'dataset' ] }
881
891
label = { < StyledLabel > { t ( 'Dataset' ) } </ StyledLabel > }
882
892
initialValue = {
@@ -915,7 +925,10 @@ const FiltersConfigForm = (
915
925
/>
916
926
</ StyledFormItem >
917
927
) : (
918
- < StyledFormItem label = { < StyledLabel > { t ( 'Dataset' ) } </ StyledLabel > } >
928
+ < StyledFormItem
929
+ expanded = { expanded }
930
+ label = { < StyledLabel > { t ( 'Dataset' ) } </ StyledLabel > }
931
+ >
919
932
< Loading position = "inline-centered" />
920
933
</ StyledFormItem >
921
934
) }
@@ -941,6 +954,7 @@ const FiltersConfigForm = (
941
954
>
942
955
{ canDependOnOtherFilters && hasAvailableFilters && (
943
956
< StyledRowFormItem
957
+ expanded = { expanded }
944
958
name = { [ 'filters' , filterId , 'dependencies' ] }
945
959
initialValue = { dependencies }
946
960
>
@@ -981,6 +995,7 @@ const FiltersConfigForm = (
981
995
} }
982
996
>
983
997
< StyledRowSubFormItem
998
+ expanded = { expanded }
984
999
name = { [ 'filters' , filterId , 'adhoc_filters' ] }
985
1000
css = { { width : INPUT_WIDTH } }
986
1001
initialValue = { filterToEdit ?. adhoc_filters }
@@ -1016,6 +1031,7 @@ const FiltersConfigForm = (
1016
1031
</ StyledRowSubFormItem >
1017
1032
{ showTimeRangePicker && (
1018
1033
< StyledRowFormItem
1034
+ expanded = { expanded }
1019
1035
name = { [ 'filters' , filterId , 'time_range' ] }
1020
1036
label = { < StyledLabel > { t ( 'Time range' ) } </ StyledLabel > }
1021
1037
initialValue = {
@@ -1057,6 +1073,7 @@ const FiltersConfigForm = (
1057
1073
} }
1058
1074
>
1059
1075
< StyledRowFormItem
1076
+ expanded = { expanded }
1060
1077
name = { [
1061
1078
'filters' ,
1062
1079
filterId ,
@@ -1077,6 +1094,7 @@ const FiltersConfigForm = (
1077
1094
</ StyledRowFormItem >
1078
1095
{ hasMetrics && (
1079
1096
< StyledRowSubFormItem
1097
+ expanded = { expanded }
1080
1098
name = { [ 'filters' , filterId , 'sortMetric' ] }
1081
1099
initialValue = { filterToEdit ?. sortMetric }
1082
1100
label = {
@@ -1126,6 +1144,7 @@ const FiltersConfigForm = (
1126
1144
} }
1127
1145
>
1128
1146
< StyledRowFormItem
1147
+ expanded = { expanded }
1129
1148
name = { [
1130
1149
'filters' ,
1131
1150
filterId ,
@@ -1164,6 +1183,7 @@ const FiltersConfigForm = (
1164
1183
key = { `${ filterId } -${ FilterPanels . settings . key } ` }
1165
1184
>
1166
1185
< StyledFormItem
1186
+ expanded = { expanded }
1167
1187
name = { [ 'filters' , filterId , 'description' ] }
1168
1188
initialValue = { filterToEdit ?. description }
1169
1189
label = { < StyledLabel > { t ( 'Description' ) } </ StyledLabel > }
@@ -1194,6 +1214,7 @@ const FiltersConfigForm = (
1194
1214
>
1195
1215
{ ! isRemoved && (
1196
1216
< StyledRowSubFormItem
1217
+ expanded = { expanded }
1197
1218
name = { [ 'filters' , filterId , 'defaultDataMask' ] }
1198
1219
initialValue = { initialDefaultValue }
1199
1220
data-test = "default-input"
0 commit comments