Skip to content

Commit 55e5760

Browse files
committed
Merge branch '431-configurator-polish' into 'master'
fix: Configurator UI improvements (#431) Closes #431 See merge request postgres-ai/database-lab!601
2 parents 0e5220a + ac24464 commit 55e5760

File tree

10 files changed

+479
-246
lines changed

10 files changed

+479
-246
lines changed

Diff for: ui/packages/shared/icons/External/icon.svg

+1
Loading

Diff for: ui/packages/shared/icons/External/index.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { ReactComponent } from './icon.svg'
2+
3+
export const ExternalIcon = ReactComponent

Diff for: ui/packages/shared/pages/Configuration/Header/index.tsx

+67-22
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,79 @@
55
*--------------------------------------------------------------------------
66
*/
77

8+
import classNames from 'classnames'
89
import { Link, Typography, Box } from '@material-ui/core'
910
import { SectionTitle } from '@postgres.ai/shared/components/SectionTitle'
11+
import { ExternalIcon } from '@postgres.ai/shared/icons/External'
12+
1013
import styles from '../styles.module.scss'
1114

1215
type Props = {
1316
retrievalMode: string
1417
setOpen: () => void
1518
}
1619

17-
export const Header = (props: Props) => {
18-
return (
19-
<div className={styles.root}>
20-
<Box mb={3}>
21-
<Typography paragraph>
22-
Only select parameters can be changed here.
23-
</Typography>
24-
<Typography paragraph>
25-
However, you can still see the{' '}
26-
<Link href="#" underline="always" onClick={props.setOpen}>
27-
full configuration file{' '}
28-
</Link>{' '}
29-
(with sensitive values masked).
30-
</Typography>
31-
<Typography paragraph>
32-
<strong>Data retrieval mode</strong>: {props.retrievalMode}
33-
</Typography>
34-
</Box>
35-
<SectionTitle level={2} tag="h2" text="Section global" />
36-
</div>
37-
)
38-
}
20+
export const ConfigSectionTitle = ({ tag }: { tag: string }) => (
21+
<SectionTitle
22+
level={2}
23+
tag="h2"
24+
text={
25+
<div className={styles.sectionTitle}>
26+
<p>Section</p>
27+
<p>"{tag}"</p>
28+
</div>
29+
}
30+
/>
31+
)
32+
33+
const DOCS_URL =
34+
'https://postgres.ai/docs/reference-guides/database-lab-engine-configuration-reference'
35+
36+
export const Header = (props: Props) => (
37+
<div className={styles.root}>
38+
<Box mb={3}>
39+
<Typography paragraph>
40+
Only select parameters can be changed here.
41+
</Typography>
42+
<Typography paragraph>
43+
However, you can still see{' '}
44+
<Link
45+
href="#"
46+
underline="always"
47+
onClick={props.setOpen}
48+
className={styles.externalLink}
49+
>
50+
the full config
51+
</Link>
52+
. For details, read{' '}
53+
<a href={DOCS_URL} target="_blank" className={styles.externalLink}>
54+
the docs
55+
<ExternalIcon className={styles.externalIcon} />
56+
</a>
57+
.
58+
</Typography>
59+
<Typography paragraph>
60+
<strong>Data retrieval mode</strong>: {props.retrievalMode}
61+
</Typography>
62+
</Box>
63+
<ConfigSectionTitle tag="global" />
64+
</div>
65+
)
66+
67+
export const ModalTitle = () => (
68+
<div>
69+
<Typography className={styles.modalTitle}>
70+
Full configuration file (view only)
71+
</Typography>
72+
<Typography variant="h3">
73+
Sensitive values are masked. For details, read{' '}
74+
<a href={DOCS_URL} target="_blank" className={styles.externalLink}>
75+
the docs
76+
<ExternalIcon
77+
className={classNames(styles.externalIcon, styles.largeIcon)}
78+
/>
79+
</a>
80+
.
81+
</Typography>
82+
</div>
83+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
import { Box, TextField, Chip } from '@material-ui/core'
2+
import { makeStyles } from '@material-ui/core/styles'
3+
import { InfoIcon } from '@postgres.ai/shared/icons/Info'
4+
import { Tooltip } from '@postgres.ai/shared/components/Tooltip'
5+
import { uniqueDatabases } from '../utils'
6+
7+
import styles from '../styles.module.scss'
8+
import classNames from 'classnames'
9+
10+
const useStyles = makeStyles({
11+
textField: {
12+
'& .MuiOutlinedInput-notchedOutline': {
13+
borderColor: '#000 !important',
14+
},
15+
},
16+
})
17+
18+
export const InputWithTooltip = ({
19+
value,
20+
label,
21+
error,
22+
onChange,
23+
tooltipText,
24+
}: {
25+
value?: string
26+
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void
27+
tooltipText: () => React.ReactNode
28+
label: string
29+
error?: string
30+
}) => {
31+
const classes = useStyles()
32+
33+
return (
34+
<Box mt={2} mb={2} display="flex" alignItems="center">
35+
<TextField
36+
className={classNames(classes.textField, styles.textField)}
37+
label={label}
38+
variant="outlined"
39+
size="small"
40+
value={value}
41+
error={Boolean(error)}
42+
onChange={onChange}
43+
/>
44+
<Tooltip content={<p className={styles.tooltipText}>{tooltipText()}</p>}>
45+
<InfoIcon className={styles.infoIcon} />
46+
</Tooltip>
47+
</Box>
48+
)
49+
}
50+
51+
export const InputWithChip = ({
52+
value,
53+
label,
54+
id,
55+
onChange,
56+
tooltipText,
57+
handleDeleteDatabase,
58+
}: {
59+
value: string
60+
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void
61+
tooltipText: () => React.ReactNode
62+
handleDeleteDatabase: (event: any, database: string) => void
63+
label: string
64+
id: string
65+
}) => {
66+
const classes = useStyles()
67+
68+
return (
69+
<Box mt={2} mb={2}>
70+
<Box display="flex" alignItems="center">
71+
<TextField
72+
className={classNames(classes.textField, styles.textField)}
73+
variant="outlined"
74+
onChange={onChange}
75+
value={value}
76+
multiline
77+
label={label}
78+
inputProps={{
79+
name: id,
80+
id: id,
81+
}}
82+
InputLabelProps={{
83+
shrink: true,
84+
}}
85+
/>
86+
<Tooltip
87+
content={<p className={styles.tooltipText}>{tooltipText()}</p>}
88+
>
89+
<InfoIcon className={styles.infoIcon} />
90+
</Tooltip>
91+
</Box>
92+
<div>
93+
{value &&
94+
uniqueDatabases(value)
95+
.split(' ')
96+
.map((database, index) => {
97+
if (database !== '') {
98+
return (
99+
<Chip
100+
key={index}
101+
className={styles.chip}
102+
label={database}
103+
onDelete={(event) => handleDeleteDatabase(event, database)}
104+
color="primary"
105+
/>
106+
)
107+
}
108+
})}
109+
</div>
110+
</Box>
111+
)
112+
}

0 commit comments

Comments
 (0)