Skip to content

Commit 09e8058

Browse files
Adrinlolagneum
authored andcommitted
feat(ui): Add select input on configuration page for SE (database-lab#463)
* Add select input for SE on configuration page * Choose latest image version by default * Add text for contact information under the input
1 parent b89ecd3 commit 09e8058

File tree

14 files changed

+601
-305
lines changed

14 files changed

+601
-305
lines changed

‎ui/packages/ce/src/App/Instance/Page/index.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ import { getInstanceRetrieval } from 'api/instances/getInstanceRetrieval'
88
import { getSnapshots } from 'api/snapshots/getSnapshots'
99
import { destroyClone } from 'api/clones/destroyClone'
1010
import { resetClone } from 'api/clones/resetClone'
11-
import { getWSToken } from "api/engine/getWSToken";
12-
import { initWS } from "api/engine/initWS";
11+
import { getWSToken } from 'api/engine/getWSToken'
12+
import { initWS } from 'api/engine/initWS'
1313
import { getConfig } from 'api/configs/getConfig'
1414
import { getFullConfig } from 'api/configs/getFullConfig'
1515
import { updateConfig } from 'api/configs/updateConfig'
1616
import { testDbSource } from 'api/configs/testDbSource'
17+
import { getEngine } from 'api/engine/getEngine'
1718

1819
export const Page = () => {
1920
const routes = {
@@ -34,6 +35,7 @@ export const Page = () => {
3435
updateConfig,
3536
testDbSource,
3637
initWS,
38+
getEngine,
3739
}
3840

3941
const elements = {

‎ui/packages/shared/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"@monaco-editor/react": "^4.4.5",
1515
"@mui/material": "^5.10.12",
1616
"@postgres.ai/shared": "link:../shared",
17+
"@postgres.ai/ce": "link:../ce",
1718
"@types/node": "^12.20.33",
1819
"@types/react": "^17.0.30",
1920
"@types/react-dom": "^17.0.10",

‎ui/packages/shared/pages/Configuration/InputWithTooltip/index.tsx

+62-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
import { TextField, Chip } from '@material-ui/core'
1+
import classNames from 'classnames'
22
import 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'
46
import { InfoIcon } from '@postgres.ai/shared/icons/Info'
57
import { Tooltip } from '@postgres.ai/shared/components/Tooltip'
8+
69
import { uniqueDatabases } from '../utils'
710

811
import styles from '../styles.module.scss'
9-
import classNames from 'classnames'
1012

1113
const 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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export const imageOptions = [
2+
{
3+
name: 'Generic Postgres (postgresai/extended-postgres)',
4+
type: 'Generic Postgres',
5+
},
6+
{ name: 'Generic Postgres with PostGIS', type: 'postgis' },
7+
{ name: 'Amazon RDS for Postgres', type: 'rds' },
8+
{ name: 'Amazon RDS Aurora for Postgres', type: 'rds' },
9+
{ name: 'Heroku Postgres', type: 'heroku' },
10+
{ name: 'Supabase Postgres', type: 'supabase' },
11+
{ name: 'Custom image', type: 'custom' },
12+
]

0 commit comments

Comments
 (0)