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 77
88import { request } from 'helpers/request'
99
10- export const destroySnapshot = async ( snapshotId ) => {
10+ export const destroySnapshot = async (
11+ snapshotId : string ,
12+ forceDelete : boolean ,
13+ ) => {
1114 const response = await request ( `/snapshot/delete` , {
1215 method : 'POST' ,
1316 body : JSON . stringify ( {
1417 snapshotID : snapshotId ,
18+ force : forceDelete ,
1519 } ) ,
1620 } )
1721
Original file line number Diff line number Diff line change @@ -13,7 +13,8 @@ import {
1313import { request } from 'helpers/request'
1414
1515export 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 ) ;
1718
1819 return {
1920 response : response . ok
Original file line number Diff line number Diff line change @@ -337,7 +337,7 @@ export const BranchesPage = observer((props: Props) => {
337337 { snapshot . dataStateAt || '-' }
338338 </ TableBodyCell >
339339 < TableBodyCell >
340- { snapshot . comment ?? '-' }
340+ { snapshot . message ?? '-' }
341341 </ TableBodyCell >
342342 </ TableRow >
343343 ) ) }
Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ export const CreateSnapshotPage = observer(
100100 const clonesList = instance ?. instance ?. state ?. cloning . clones || [ ]
101101
102102 const handleSubmit = async ( values : FormValues ) => {
103- await createSnapshot ( values . cloneID , values . comment ) . then ( ( snapshot ) => {
103+ await createSnapshot ( values . cloneID , values . message ) . then ( ( snapshot ) => {
104104 if ( snapshot && generateSnapshotPageId ( snapshot . snapshotID ) ) {
105105 history . push (
106106 `/instance/snapshots/${ generateSnapshotPageId (
@@ -165,18 +165,18 @@ export const CreateSnapshotPage = observer(
165165 : [ ]
166166 }
167167 />
168- < strong > Comment </ strong >
168+ < strong > Message </ strong >
169169 < p className = { classes . marginTop } >
170- Optional comment to be added to the snapshot.
170+ Message to be added to the snapshot.
171171 </ p >
172172 < TextField
173- label = "Comment "
173+ label = "Message * "
174174 fullWidth
175175 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 ) }
178178 onChange = { ( e ) =>
179- formik . setFieldValue ( 'comment ' , e . target . value )
179+ formik . setFieldValue ( 'message ' , e . target . value )
180180 }
181181 />
182182 < Button
Original file line number Diff line number Diff line change @@ -10,18 +10,19 @@ import * as Yup from 'yup'
1010
1111export type FormValues = {
1212 cloneID : string
13- comment ? : string
13+ message : string
1414}
1515
1616const Schema = Yup . object ( ) . shape ( {
1717 cloneID : Yup . string ( ) . required ( 'Clone ID is required' ) ,
18+ message : Yup . string ( ) . required ( 'Message is required' ) ,
1819} )
1920
2021export const useForm = ( onSubmit : ( values : FormValues ) => void ) => {
2122 const formik = useFormik < FormValues > ( {
2223 initialValues : {
2324 cloneID : '' ,
24- comment : '' ,
25+ message : '' ,
2526 } ,
2627 validationSchema : Schema ,
2728 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