Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit a2f39bf

Browse files
DaedalusGCraig Furman
and
Craig Furman
authored
feat(appliance): introduce mock up database configuration step in install flow (#64162)
<!-- PR description tips: https://www.notion.so/sourcegraph/Write-a-good-pull-request-description-610a7fd3e613496eb76f450db5a49b6e --> Initial demo version of the database config on installation of a new Sourcegraph search instance managed by Appliance Currently the disabled external db form and tab options are mock ups that don't do anything. <img width="620" alt="Screenshot 2024-07-31 at 3 06 56 AM" src="https://github.com/user-attachments/assets/98f87ba5-3825-432e-90c9-18c0513325a7"> <img width="830" alt="Screenshot 2024-07-31 at 3 07 09 AM" src="https://github.com/user-attachments/assets/ad820705-4910-4949-b9cc-d5070024d31c"> <img width="837" alt="Screenshot 2024-07-31 at 3 07 18 AM" src="https://github.com/user-attachments/assets/c4839fe4-a70f-4b65-a40f-c5ba1fed85d6"> ## Test plan Tested locally <!-- REQUIRED; info at https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles --> ## Changelog <!-- OPTIONAL; info at https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c --> --------- Co-authored-by: Craig Furman <[email protected]>
1 parent 45630b2 commit a2f39bf

File tree

1 file changed

+127
-25
lines changed

1 file changed

+127
-25
lines changed

internal/appliance/frontend/maintenance/src/Install.tsx

Lines changed: 127 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,45 @@
11
import React, { useState, useEffect } from 'react'
22

3-
import { Button, FormControl, InputLabel, MenuItem, Paper, Select, Stack, Typography } from '@mui/material'
3+
import {
4+
Button,
5+
FormControl,
6+
RadioGroup,
7+
InputLabel,
8+
MenuItem,
9+
Paper,
10+
Select,
11+
Stack,
12+
Typography,
13+
Radio,
14+
FormControlLabel,
15+
FormGroup,
16+
FormLabel,
17+
FormHelperText,
18+
Box,
19+
TextField,
20+
Tab,
21+
Tabs,
22+
} from '@mui/material'
423

524
import { changeStage } from './state'
625

726
export const Install: React.FC = () => {
27+
type installState = 'select-version' | 'select-db-type'
28+
const [installState, setInstallState] = useState<installState>('select-version')
29+
830
const [versions, setVersions] = useState<string[]>([])
931
const [selectedVersion, setSelectedVersion] = useState<string>('')
1032

33+
type dbType = 'built-in' | 'external'
34+
const [dbType, setDbType] = useState<dbType>('built-in')
35+
36+
type dbTab = 'pgsql' | 'codeintel' | 'codeinsights'
37+
const [dbTab, setDbTab] = useState<dbTab>('pgsql')
38+
39+
const handleDbTabChange = (event: React.SyntheticEvent, newValue: dbTab) => {
40+
setDbTab(newValue)
41+
}
42+
1143
useEffect(() => {
1244
const fetchVersions = async () => {
1345
try {
@@ -48,37 +80,107 @@ export const Install: React.FC = () => {
4880
fetchVersions()
4981
}, [])
5082

83+
const next = () => {
84+
if (selectedVersion === '') {
85+
alert('Please select a version')
86+
return
87+
}
88+
setInstallState('select-db-type')
89+
}
90+
91+
const back = () => {
92+
setInstallState('select-version')
93+
}
94+
5195
const install = () => {
5296
changeStage({ action: 'installing', data: selectedVersion })
5397
}
5498

99+
const handleDbSelect = (event: React.ChangeEvent<HTMLInputElement>) => {
100+
setDbType(event.target.value as dbType)
101+
}
102+
55103
return (
104+
// Render a version selection box followed by a database configuration screen, then an install prompt
56105
<div className="install">
57-
<Typography variant="h5">Let's get started...</Typography>
106+
<Typography variant="h5">Setup Sourcegraph</Typography>
58107
<Paper elevation={3} sx={{ p: 4 }}>
59-
<Stack direction="column" spacing={2} sx={{ alignItems: 'center' }}>
60-
<FormControl sx={{ minWidth: 200 }}>
61-
<InputLabel id="demo-simple-select-label">Version</InputLabel>
62-
<Select
63-
value={selectedVersion}
64-
label="Version"
65-
onChange={e => setSelectedVersion(e.target.value)}
66-
sx={{ width: 200 }}
67-
>
68-
{versions.map(version => (
69-
<MenuItem key={version} value={version}>
70-
{version}
71-
</MenuItem>
72-
))}
73-
</Select>
74-
</FormControl>
75-
<div className="message">
76-
<Typography variant="caption">Press install to begin installation.</Typography>
77-
</div>
78-
<Button variant="contained" sx={{ width: 200 }} onClick={install}>
79-
Install
80-
</Button>
81-
</Stack>
108+
{installState === 'select-version' ? (
109+
<Stack direction="column" spacing={2} sx={{ alignItems: 'center' }}>
110+
<FormControl sx={{ minWidth: 200 }}>
111+
<InputLabel id="demo-simple-select-label">Version</InputLabel>
112+
<Select
113+
value={selectedVersion}
114+
label="Version"
115+
onChange={e => setSelectedVersion(e.target.value)}
116+
sx={{ width: 200 }}
117+
>
118+
{versions.map(version => (
119+
<MenuItem key={version} value={version}>
120+
{version}
121+
</MenuItem>
122+
))}
123+
</Select>
124+
</FormControl>
125+
<div className="message">
126+
<Typography variant="caption">Proceed to database configuration.</Typography>
127+
</div>
128+
<Button variant="contained" sx={{ width: 200 }} onClick={next}>
129+
Next
130+
</Button>
131+
</Stack>
132+
) : installState === 'select-db-type' ? (
133+
<Stack direction="column" spacing={2} alignItems={'center'}>
134+
<FormControl>
135+
<FormLabel>Configure Sourcegraph Databases</FormLabel>
136+
<FormGroup>
137+
<RadioGroup value={dbType} onChange={handleDbSelect} defaultValue="built-in">
138+
<FormControlLabel value="built-in" control={<Radio />} label="built-in DBs" />
139+
<FormHelperText id="my-helper-text" fontSize="small">
140+
Selecting built-in dbs, configures sourcegraph to use built in databases.
141+
Provisioned and controlled directly by appliance.{' '}
142+
</FormHelperText>
143+
<FormControlLabel
144+
value="external"
145+
control={<Radio />}
146+
label="External DBs (not yet supported)"
147+
/>
148+
</RadioGroup>
149+
</FormGroup>
150+
</FormControl>
151+
{dbType === 'external' ? (
152+
<Box sx={{ width: '80%' }} alignContent={'center'}>
153+
<Box
154+
alignContent={'center'}
155+
sx={{ paddingBottom: 2.5, borderBottom: 1, borderColor: 'divider' }}
156+
>
157+
<Tabs value={dbTab} onChange={handleDbTabChange}>
158+
<Tab label="Pgsql" disabled />
159+
<Tab label="Codeintel-db" disabled />
160+
<Tab label="Codeinsights-db" disabled />
161+
</Tabs>
162+
</Box>
163+
<FormGroup>
164+
<Stack spacing={2}>
165+
<TextField disabled label="Port" defaultValue="5432" />
166+
<TextField disabled label="User" defaultValue="sg" />
167+
<TextField disabled label="Password" defaultValue="sg" />
168+
<TextField disabled label="Database" defaultValue="sg" />
169+
<TextField disabled label="SSL Mode" defaultValue="disable" />
170+
</Stack>
171+
</FormGroup>
172+
</Box>
173+
) : null}
174+
<Stack direction="row" spacing={2}>
175+
<Button variant="contained" sx={{ width: 200 }} onClick={back}>
176+
Back
177+
</Button>
178+
<Button variant="contained" sx={{ width: 200 }} onClick={install}>
179+
Install
180+
</Button>
181+
</Stack>
182+
</Stack>
183+
) : null}
82184
</Paper>
83185
</div>
84186
)

0 commit comments

Comments
 (0)