@@ -3,6 +3,9 @@ import { Row, Col, Breadcrumb, BreadcrumbItem } from 'reactstrap';
3
3
import PropTypes from 'prop-types' ;
4
4
import moment from 'moment' ;
5
5
import ReactTable from 'react-table-6' ;
6
+ import Checkbox from '@mui/material/Checkbox' ;
7
+ import TextField from '@mui/material/TextField' ;
8
+ import Autocomplete from '@mui/material/Autocomplete' ;
6
9
7
10
import { bugsEndpoint } from '../helpers/url' ;
8
11
import { setUrlParam , getUrlParam } from '../helpers/location' ;
@@ -32,6 +35,7 @@ const MainView = (props) => {
32
35
updateAppState,
33
36
} = props ;
34
37
38
+ const [ selectedProduct , setSelectedProduct ] = React . useState ( [ ] ) ;
35
39
const textFilter = ( filter , row ) => {
36
40
if ( getUrlParam ( filter . id ) !== filter . value ) {
37
41
setUrlParam ( filter . id , filter . value ) ;
@@ -75,7 +79,46 @@ const MainView = (props) => {
75
79
Header : 'Product' ,
76
80
accessor : 'product' ,
77
81
maxWidth : 100 ,
78
- filterMethod : ( filter , row ) => textFilter ( filter , row ) ,
82
+ filterMethod : ( filter , row ) => {
83
+ const regex = RegExp ( filter . value . join ( '|' ) , 'i' ) ;
84
+ if ( regex . test ( row . product ) ) {
85
+ return row ;
86
+ }
87
+ } ,
88
+ Filter : ( { onChange } ) => {
89
+ return (
90
+ < Autocomplete
91
+ multiple
92
+ id = "checkboxes-tags-filter"
93
+ options = { [ ...new Set ( tableData . map ( ( d ) => d . product ) ) ] }
94
+ onChange = { ( _event , values ) => {
95
+ setUrlParam ( 'product' , values ) ;
96
+ onChange ( values ) ;
97
+ } }
98
+ limitTags = { 2 }
99
+ disableCloseOnSelect
100
+ defaultValue = { selectedProduct }
101
+ style = { {
102
+ width : '20em' ,
103
+ } }
104
+ renderOption = { ( props , option , { selected } ) => {
105
+ const { key, ...optionProps } = props ;
106
+ return (
107
+ < li key = { key } { ...optionProps } >
108
+ < Checkbox style = { { marginRight : 8 } } checked = { selected } />
109
+ { option }
110
+ </ li >
111
+ ) ;
112
+ } }
113
+ renderInput = { ( params ) => (
114
+ < TextField
115
+ style = { { border : 'none' , height : '0.3em' , padding : '0' } }
116
+ { ...params }
117
+ />
118
+ ) }
119
+ />
120
+ ) ;
121
+ } ,
79
122
} ,
80
123
{
81
124
Header : 'Component' ,
@@ -128,7 +171,14 @@ const MainView = (props) => {
128
171
for ( const header of [ 'product' , 'component' , 'summary' , 'whiteboard' ] ) {
129
172
const param = getUrlParam ( header ) ;
130
173
if ( param ) {
131
- filters . push ( { id : header , value : getUrlParam ( header ) } ) ;
174
+ if ( header === 'product' ) {
175
+ filters . push ( { id : header , value : param . split ( ',' ) } ) ;
176
+ if ( selectedProduct . length === 0 ) {
177
+ setSelectedProduct ( param . split ( ',' ) ) ;
178
+ }
179
+ } else {
180
+ filters . push ( { id : header , value : param } ) ;
181
+ }
132
182
}
133
183
}
134
184
return filters ;
0 commit comments