@@ -10,6 +10,10 @@ 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 ,
@@ -20,7 +24,7 @@ import {
20
24
useAnchor
21
25
} from "../../../utils" ;
22
26
import { APISource } from "../../sources" ;
23
- import { AccountTreeOutlined , FolderOpen } from "@material-ui/icons" ;
27
+ import { AccountTreeOutlined , FolderOpen , Search as SearchIcon } from "@material-ui/icons" ;
24
28
import { APIDictionary } from '../../dictionaries/types' ;
25
29
26
30
interface Props {
@@ -59,6 +63,10 @@ const useStyles = makeStyles((theme: Theme) =>
59
63
marginRight : "0.2rem" ,
60
64
fill : "#8080809c"
61
65
} ,
66
+ searchInput : {
67
+ textAlign : "center" ,
68
+ fontSize : "larger"
69
+ } ,
62
70
} )
63
71
) ;
64
72
@@ -70,8 +78,11 @@ const ViewConceptsHeader: React.FC<Props> = ({
70
78
children,
71
79
sources,
72
80
dictionaries
81
+ // showOnlyVerified,
82
+ // toggleShowVerified
73
83
} ) => {
74
84
const [ showSources , setShowSources ] = useState ( false ) ;
85
+ const [ search , setSearch ] = useState ( "" ) ;
75
86
const [ preferredSources , setPreferredSources ] = useState < { name : string ; url : string } [ ] > ( ) ;
76
87
useEffect ( ( ) => {
77
88
const defaultSources = Object . entries ( PREFERRED_SOURCES_VIEW_ONLY ) . map ( ( [ key , value ] ) => ( { name : key , url : value } ) ) ;
@@ -82,6 +93,9 @@ const ViewConceptsHeader: React.FC<Props> = ({
82
93
setPreferredSources ( allSources ) ;
83
94
} else setPreferredSources ( defaultSources ) ;
84
95
} , [ showSources , sources , dictionaries ] ) ;
96
+ // const handleSearch = (event) => {
97
+ // setSearch(event.target.value)
98
+ // }
85
99
86
100
const classes = useStyles ( ) ;
87
101
const isSourceContainer = containerType === SOURCE_CONTAINER ;
@@ -91,7 +105,6 @@ const ViewConceptsHeader: React.FC<Props> = ({
91
105
handleSwitchSourceClick ,
92
106
handleSwitchSourceClose
93
107
] = useAnchor ( ) ;
94
-
95
108
const getTitleBasedOnContainerType = ( ) => {
96
109
return isAddToDictionary
97
110
? `Import existing concept from ${ getContainerIdFromUrl ( containerUrl ) } `
@@ -124,14 +137,55 @@ const ViewConceptsHeader: React.FC<Props> = ({
124
137
keepMounted
125
138
open = { Boolean ( switchSourceAnchor ) }
126
139
onClose = { handleSwitchSourceClose }
127
- >
128
- < Button
129
- variant = "contained"
130
- color = "primary"
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
131
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 ) }
132
168
>
133
- { showSources ? "Select a recommended source" : "Select an alternative source" }
134
- </ Button >
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"
182
+ />
183
+ }
184
+ label={
185
+ showOnlyVerified ? `Showing verified {"Select a recommended source"} only` : `Show verified {"Select an alternative source"} only`
186
+ }
187
+ /> */ }
188
+ </ Grid >
135
189
{ preferredSources ?. map ( ( { name, url } ) => (
136
190
< MenuItem
137
191
// replace because we want to keep the back button useful
0 commit comments