1- import { TextField , Chip } from '@material-ui/core '
1+ import classNames from 'classnames '
22import Box from '@mui/material/Box'
3- import { makeStyles } from '@material-ui/core'
3+ import { TextField , Chip , makeStyles } from '@material-ui/core'
4+
5+ import { Select } from '@postgres.ai/shared/components/Select'
46import { InfoIcon } from '@postgres.ai/shared/icons/Info'
57import { Tooltip } from '@postgres.ai/shared/components/Tooltip'
8+
69import { uniqueDatabases } from '../utils'
710
811import styles from '../styles.module.scss'
9- import classNames from 'classnames'
1012
1113const useStyles = makeStyles (
1214 {
@@ -15,6 +17,16 @@ const useStyles = makeStyles(
1517 borderColor : '#000 !important' ,
1618 } ,
1719 } ,
20+ selectField : {
21+ marginTop : '0' ,
22+ '& .MuiInputBase-root' : {
23+ padding : '6px' ,
24+ } ,
25+
26+ '& .MuiSelect-select:focus' : {
27+ backgroundColor : 'inherit' ,
28+ } ,
29+ } ,
1830 } ,
1931 { index : 1 } ,
2032)
@@ -67,7 +79,10 @@ export const InputWithChip = ({
6779 value : string
6880 onChange : ( e : React . ChangeEvent < HTMLInputElement > ) => void
6981 tooltipText : ( ) => React . ReactNode
70- handleDeleteDatabase : ( event : any , database : string ) => void
82+ handleDeleteDatabase : (
83+ event : React . FormEvent < HTMLInputElement > ,
84+ database : string ,
85+ ) => void
7186 label : string
7287 id : string
7388 disabled : boolean | undefined
@@ -122,3 +137,46 @@ export const InputWithChip = ({
122137 </ Box >
123138 )
124139}
140+
141+ export const SelectWithTooltip = ( {
142+ value,
143+ label,
144+ error,
145+ onChange,
146+ tooltipText,
147+ disabled,
148+ items,
149+ } : {
150+ value : string
151+ onChange : ( e : React . ChangeEvent < HTMLInputElement > ) => void
152+ tooltipText : ( ) => React . ReactNode
153+ label : string
154+ error ?: boolean
155+ disabled : boolean | undefined
156+ items : { value : string ; children : React . ReactNode } [ ]
157+ } ) => {
158+ const classes = useStyles ( )
159+
160+ return (
161+ < Box mt = { 2 } mb = { 2 } >
162+ < Box mb = { 1 } display = "flex" alignItems = "center" >
163+ < Select
164+ className = { classNames (
165+ classes . selectField ,
166+ ! disabled && classes . textField ,
167+ styles . textField ,
168+ ) }
169+ label = { label }
170+ error = { error }
171+ value = { value }
172+ disabled = { disabled }
173+ onChange = { onChange }
174+ items = { items }
175+ />
176+ < Tooltip interactive content = { < p > { tooltipText ( ) } </ p > } >
177+ < InfoIcon className = { styles . infoIcon } />
178+ </ Tooltip >
179+ </ Box >
180+ </ Box >
181+ )
182+ }
0 commit comments