File tree Expand file tree Collapse file tree 18 files changed +742
-282
lines changed Expand file tree Collapse file tree 18 files changed +742
-282
lines changed Original file line number Diff line number Diff line change 7
7
8
8
import { request } from 'helpers/request'
9
9
10
- export const destroySnapshot = async ( snapshotId ) => {
10
+ export const destroySnapshot = async (
11
+ snapshotId : string ,
12
+ forceDelete : boolean ,
13
+ ) => {
11
14
const response = await request ( `/snapshot/delete` , {
12
15
method : 'POST' ,
13
16
body : JSON . stringify ( {
14
17
snapshotID : snapshotId ,
18
+ force : forceDelete ,
15
19
} ) ,
16
20
} )
17
21
Original file line number Diff line number Diff line change @@ -13,7 +13,8 @@ import {
13
13
import { request } from 'helpers/request'
14
14
15
15
export const getSnapshots : GetSnapshots = async ( req ) => {
16
- const response = await request ( '/snapshots' )
16
+ const url = `/snapshots${ req . branchName ? `?branch=${ req . branchName } ` : '' } ` ;
17
+ const response = await request ( url ) ;
17
18
18
19
return {
19
20
response : response . ok
Original file line number Diff line number Diff line change @@ -337,7 +337,7 @@ export const BranchesPage = observer((props: Props) => {
337
337
{ snapshot . dataStateAt || '-' }
338
338
</ TableBodyCell >
339
339
< TableBodyCell >
340
- { snapshot . comment ?? '-' }
340
+ { snapshot . message ?? '-' }
341
341
</ TableBodyCell >
342
342
</ TableRow >
343
343
) ) }
Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ export const CreateSnapshotPage = observer(
100
100
const clonesList = instance ?. instance ?. state ?. cloning . clones || [ ]
101
101
102
102
const handleSubmit = async ( values : FormValues ) => {
103
- await createSnapshot ( values . cloneID , values . comment ) . then ( ( snapshot ) => {
103
+ await createSnapshot ( values . cloneID , values . message ) . then ( ( snapshot ) => {
104
104
if ( snapshot && generateSnapshotPageId ( snapshot . snapshotID ) ) {
105
105
history . push (
106
106
`/instance/snapshots/${ generateSnapshotPageId (
@@ -165,18 +165,18 @@ export const CreateSnapshotPage = observer(
165
165
: [ ]
166
166
}
167
167
/>
168
- < strong > Comment </ strong >
168
+ < strong > Message </ strong >
169
169
< p className = { classes . marginTop } >
170
- Optional comment to be added to the snapshot.
170
+ Message to be added to the snapshot.
171
171
</ p >
172
172
< TextField
173
- label = "Comment "
173
+ label = "Message * "
174
174
fullWidth
175
175
className = { classes . marginBottom2x }
176
- value = { formik . values . comment }
177
- error = { Boolean ( formik . errors . comment ) }
176
+ value = { formik . values . message }
177
+ error = { Boolean ( formik . errors . message ) }
178
178
onChange = { ( e ) =>
179
- formik . setFieldValue ( 'comment ' , e . target . value )
179
+ formik . setFieldValue ( 'message ' , e . target . value )
180
180
}
181
181
/>
182
182
< Button
Original file line number Diff line number Diff line change @@ -10,18 +10,19 @@ import * as Yup from 'yup'
10
10
11
11
export type FormValues = {
12
12
cloneID : string
13
- comment ? : string
13
+ message : string
14
14
}
15
15
16
16
const Schema = Yup . object ( ) . shape ( {
17
17
cloneID : Yup . string ( ) . required ( 'Clone ID is required' ) ,
18
+ message : Yup . string ( ) . required ( 'Message is required' ) ,
18
19
} )
19
20
20
21
export const useForm = ( onSubmit : ( values : FormValues ) => void ) => {
21
22
const formik = useFormik < FormValues > ( {
22
23
initialValues : {
23
24
cloneID : '' ,
24
- comment : '' ,
25
+ message : '' ,
25
26
} ,
26
27
validationSchema : Schema ,
27
28
onSubmit,
Original file line number Diff line number Diff line change
1
+ import { observer } from 'mobx-react-lite'
2
+ import { makeStyles , TextField } from '@material-ui/core'
3
+ import { Select } from '@postgres.ai/shared/components/Select'
4
+
5
+ interface SnapshotHeaderProps {
6
+ branches : string [ ] | null
7
+ selectedBranch : string
8
+ setMessageFilter : ( value : string ) => void
9
+ setSelectedBranch : ( value : string ) => void
10
+ }
11
+
12
+ const useStyles = makeStyles (
13
+ {
14
+ outerContainer : {
15
+ display : 'flex' ,
16
+ justifyContent : 'space-between' ,
17
+ alignItems : 'center' ,
18
+ paddingBottom : '6px' ,
19
+ } ,
20
+ select : {
21
+ width : '200px' ,
22
+ } ,
23
+ inputContainer : {
24
+ width : '300px' ,
25
+
26
+ '& input' : {
27
+ padding : '8px' ,
28
+ } ,
29
+ } ,
30
+ } ,
31
+ { index : 1 } ,
32
+ )
33
+
34
+ export const SnapshotHeader = observer (
35
+ ( {
36
+ branches,
37
+ selectedBranch,
38
+ setMessageFilter,
39
+ setSelectedBranch,
40
+ } : SnapshotHeaderProps ) => {
41
+ const classes = useStyles ( )
42
+
43
+ return (
44
+ < div className = { classes . outerContainer } >
45
+ < Select
46
+ fullWidth
47
+ label = "Branch"
48
+ className = { classes . select }
49
+ value = { selectedBranch }
50
+ disabled = { ! branches }
51
+ onChange = { ( e ) => {
52
+ setSelectedBranch ( e . target . value )
53
+ } }
54
+ items = {
55
+ branches
56
+ ? branches . map ( ( branch ) => {
57
+ return {
58
+ value : branch ,
59
+ children : < div > { branch } </ div > ,
60
+ }
61
+ } )
62
+ : [ ]
63
+ }
64
+ />
65
+ < TextField
66
+ variant = "outlined"
67
+ className = { classes . inputContainer }
68
+ onChange = { ( e ) => setMessageFilter ( e . target . value ) }
69
+ label = { 'Filter by message' }
70
+ InputLabelProps = { {
71
+ shrink : true ,
72
+ } }
73
+ />
74
+ </ div >
75
+ )
76
+ } ,
77
+ )
You can’t perform that action at this time.
0 commit comments