@@ -10,18 +10,21 @@ import { getContainerIdFromUrl } from "../utils";
10
10
import {
11
11
Button ,
12
12
createStyles ,
13
+ Grid ,
14
+ IconButton ,
15
+ Input ,
16
+ InputAdornment ,
13
17
makeStyles ,
14
18
Menu ,
15
19
MenuItem ,
16
- TextField ,
17
20
Theme
18
21
} from "@material-ui/core" ;
19
22
import {
20
23
PREFERRED_SOURCES_VIEW_ONLY ,
21
24
useAnchor
22
25
} from "../../../utils" ;
23
26
import { APISource } from "../../sources" ;
24
- import { AccountTreeOutlined , FolderOpen } from "@material-ui/icons" ;
27
+ import { AccountTreeOutlined , FolderOpen , Search as SearchIcon } from "@material-ui/icons" ;
25
28
import { APIDictionary } from '../../dictionaries/types' ;
26
29
27
30
interface Props {
@@ -60,6 +63,10 @@ const useStyles = makeStyles((theme: Theme) =>
60
63
marginRight : "0.2rem" ,
61
64
fill : "#8080809c"
62
65
} ,
66
+ searchInput : {
67
+ textAlign : "center" ,
68
+ fontSize : "larger"
69
+ } ,
63
70
} )
64
71
) ;
65
72
@@ -71,8 +78,11 @@ const ViewConceptsHeader: React.FC<Props> = ({
71
78
children,
72
79
sources,
73
80
dictionaries
81
+ // showOnlyVerified,
82
+ // toggleShowVerified
74
83
} ) => {
75
84
const [ showSources , setShowSources ] = useState ( false ) ;
85
+ const [ search , setSearch ] = useState ( "" ) ;
76
86
const [ preferredSources , setPreferredSources ] = useState < { name : string ; url : string } [ ] > ( ) ;
77
87
useEffect ( ( ) => {
78
88
const defaultSources = Object . entries ( PREFERRED_SOURCES_VIEW_ONLY ) . map ( ( [ key , value ] ) => ( { name : key , url : value } ) ) ;
@@ -83,6 +93,9 @@ const ViewConceptsHeader: React.FC<Props> = ({
83
93
setPreferredSources ( allSources ) ;
84
94
} else setPreferredSources ( defaultSources ) ;
85
95
} , [ showSources , sources , dictionaries ] ) ;
96
+ // const handleSearch = (event) => {
97
+ // setSearch(event.target.value)
98
+ // }
86
99
87
100
const classes = useStyles ( ) ;
88
101
const isSourceContainer = containerType === SOURCE_CONTAINER ;
@@ -92,7 +105,6 @@ const ViewConceptsHeader: React.FC<Props> = ({
92
105
handleSwitchSourceClick ,
93
106
handleSwitchSourceClose
94
107
] = useAnchor ( ) ;
95
-
96
108
const getTitleBasedOnContainerType = ( ) => {
97
109
return isAddToDictionary
98
110
? `Import existing concept from ${ getContainerIdFromUrl ( containerUrl ) } `
@@ -125,21 +137,55 @@ const ViewConceptsHeader: React.FC<Props> = ({
125
137
keepMounted
126
138
open = { Boolean ( switchSourceAnchor ) }
127
139
onClose = { handleSwitchSourceClose }
128
- >
129
- < TextField
130
- multiline
131
- className = { classes . textField }
132
- InputProps = { {
133
- className : classes . underline
134
- } }
135
- inputProps = { {
136
- className : classes . input
137
- } }
138
- value = {
139
- showSources ? "Choose a source/dictionary" : "Select a different source/dictionary"
140
- }
141
- onClick = { ( ) => setShowSources ( ! showSources ) }
140
+ >
141
+ < Grid
142
+ container
143
+ // eslint-disable-next-line react/jsx-no-comment-textnodes
144
+ direction = "column" >
145
+ { showSources ?
146
+ < Input
147
+ color = "primary"
148
+ type = "search"
149
+ fullWidth
150
+ placeholder = { "Select an alternative source" }
151
+ value = { search }
152
+ onChange = { event => setSearch ( event . target . value ) }
153
+ data-testid = "switch-source"
154
+ endAdornment = {
155
+ < InputAdornment position = "end" >
156
+ < IconButton
157
+ onClick = { ( ) => setShowSources ( ! showSources ) }
158
+ data-testid = "searchButton"
159
+ >
160
+ < SearchIcon />
161
+ </ IconButton >
162
+ </ InputAdornment >
163
+ }
164
+ /> :
165
+ < Button
166
+ variant = "text"
167
+ onClick = { ( ) => setShowSources ( ! showSources ) }
168
+ >
169
+ Select a recommended source
170
+ { /* {showSources ? "Select a recommended source" : "Select an alternative source"} */ }
171
+ </ Button >
172
+ }
173
+
174
+ { /* <FormControlLabel
175
+ control={
176
+ <Switch
177
+ checkedIcon={<VerifiedSource />}
178
+ checked={showOnlyVerified}
179
+ onChange={toggleShowVerified}
180
+ color="primary"
181
+ name="displayVerified"
142
182
/>
183
+ }
184
+ label={
185
+ showOnlyVerified ? `Showing verified {"Select a recommended source"} only` : `Show verified {"Select an alternative source"} only`
186
+ }
187
+ /> */ }
188
+ </ Grid >
143
189
{ preferredSources ?. map ( ( { name, url } ) => (
144
190
< MenuItem
145
191
// replace because we want to keep the back button useful
0 commit comments