File tree Expand file tree Collapse file tree 8 files changed +57
-15
lines changed
App/Instance/Clones/Clone Expand file tree Collapse file tree 8 files changed +57
-15
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,10 @@ e2e-ce-ui-test:
72
72
# TODO: Set up caching.
73
73
# - pnpm config set store-dir /builds/postgres-ai/database-lab/.pnpm-store/
74
74
script :
75
- - pnpm --dir ui/ i --no-frozen-lockfile
75
+ - pnpm --dir ui/ --filter @postgres.ai/ce install
76
+ - pnpm --dir ui/ --filter @postgres.ai/ce build
76
77
- pnpm --dir ui/ --filter @postgres.ai/ce exec cypress install
77
- - pnpm --dir ui/ --filter @postgres.ai/ce start & wait-on http://localhost:3001
78
+ - npx serve -s ui/packages/ce/build -l 3001 > server.log 2>&1 &
79
+ - sleep 20
80
+ - timeout 120s wait-on http://localhost:3001 || (echo "❌ UI didn't start in time"; cat server.log; exit 1)
78
81
- pnpm --dir ui/ --filter @postgres.ai/ce cy:run
Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ export const Clone = () => {
59
59
instance : ( ) => ROUTES . INSTANCE . path ,
60
60
snapshot : ( snapshotId : string ) =>
61
61
ROUTES . INSTANCE . SNAPSHOTS . SNAPSHOT . createPath ( snapshotId ) ,
62
+ createSnapshot : ( cloneId : string ) => ROUTES . INSTANCE . SNAPSHOTS . CREATE . createPath ( cloneId ) ,
62
63
} }
63
64
api = { api }
64
65
elements = { elements }
Original file line number Diff line number Diff line change @@ -27,6 +27,13 @@ export const ROUTES = {
27
27
CREATE : {
28
28
name : 'Create snapshot' ,
29
29
path : `/instance/snapshots/create` ,
30
+ createPath : ( cloneId ?: string ) => {
31
+ const params = new URLSearchParams ( ) ;
32
+ if ( cloneId ) params . set ( 'clone_id' , cloneId ) ;
33
+
34
+ const query = params . toString ( ) ;
35
+ return `/instance/snapshots/create${ query ? `?${ query } ` : '' } ` ;
36
+ }
30
37
} ,
31
38
32
39
SNAPSHOTS : {
Original file line number Diff line number Diff line change @@ -5,8 +5,12 @@ export const ORG_SNAPSHOTS = {
5
5
return `/${ org } /instances/${ instanceId } /snapshots`
6
6
} ,
7
7
ADD : {
8
- createPath : ( args ?: { org : string ; instanceId : string } ) => {
9
- const { org = ':org' , instanceId = ':instanceId' } = args ?? { }
8
+ createPath : ( args ?: { org : string ; instanceId : string , cloneId ?: string } ) => {
9
+ const { org = ':org' , instanceId = ':instanceId' , cloneId = undefined } = args ?? { }
10
+
11
+ if ( cloneId ) {
12
+ return `/${ org } /instances/${ instanceId } /snapshots/add?clone_id=${ cloneId } `
13
+ }
10
14
11
15
return `/${ org } /instances/${ instanceId } /snapshots/add`
12
16
} ,
@@ -44,13 +48,19 @@ export const PROJECT_SNAPSHOTS = {
44
48
org : string
45
49
project : string
46
50
instanceId : string
51
+ cloneId ?: string
47
52
} ) => {
48
53
const {
49
54
org = ':org' ,
50
55
project = ':project' ,
51
56
instanceId = ':instanceId' ,
57
+ cloneId = undefined ,
52
58
} = args ?? { }
53
59
60
+ if ( cloneId ) {
61
+ return `/${ org } /${ project } /instances/${ instanceId } /snapshots/add?clone_id=${ cloneId } `
62
+ }
63
+
54
64
return `/${ org } /${ project } /instances/${ instanceId } /snapshots/add`
55
65
} ,
56
66
} ,
Original file line number Diff line number Diff line change @@ -45,6 +45,19 @@ export const Clone = () => {
45
45
instanceId : params . instanceId ,
46
46
snapshotId,
47
47
} ) ,
48
+ createSnapshot : ( ) =>
49
+ params . project
50
+ ? ROUTES . ORG . PROJECT . INSTANCES . INSTANCE . SNAPSHOTS . ADD . createPath ( {
51
+ org : params . org ,
52
+ project : params . project ,
53
+ instanceId : params . instanceId ,
54
+ cloneId : params . cloneId ,
55
+ } )
56
+ : ROUTES . ORG . INSTANCES . INSTANCE . SNAPSHOTS . ADD . createPath ( {
57
+ org : params . org ,
58
+ instanceId : params . instanceId ,
59
+ cloneId : params . cloneId ,
60
+ } )
48
61
}
49
62
50
63
const api = {
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ export type Host = {
9
9
routes : {
10
10
instance : ( ) => string
11
11
snapshot : ( snapshotId : string ) => string
12
+ createSnapshot : ( cloneId : string ) => string
12
13
}
13
14
api : Api
14
15
elements : {
Original file line number Diff line number Diff line change @@ -276,17 +276,7 @@ export const Clone = observer((props: Props) => {
276
276
}
277
277
278
278
const createSnapshot = async ( ) => {
279
- await snapshots
280
- . createSnapshot ( props . cloneId , '' , props . instanceId )
281
- . then ( ( snapshot ) => {
282
- if ( snapshot && generateSnapshotPageId ( snapshot . snapshotID ) ) {
283
- history . push (
284
- props . routes . snapshot (
285
- generateSnapshotPageId ( snapshot . snapshotID ) as string ,
286
- ) ,
287
- )
288
- }
289
- } )
279
+ history . push ( props . routes . createSnapshot ( props . cloneId ) )
290
280
}
291
281
292
282
// Clone reload.
Original file line number Diff line number Diff line change @@ -127,6 +127,23 @@ export const CreateSnapshotPage = observer(
127
127
load ( instanceId )
128
128
} , [ ] )
129
129
130
+ useEffect ( ( ) => {
131
+ if ( ! history . location . search ) return
132
+
133
+ const queryString = history . location . search . split ( '?' ) [ 1 ]
134
+
135
+ if ( ! queryString ) return
136
+
137
+ const params = new URLSearchParams ( queryString )
138
+
139
+ const cloneID = params . get ( 'clone_id' )
140
+
141
+ if ( ! cloneID ) return
142
+
143
+ formik . setFieldValue ( 'cloneID' , cloneID )
144
+
145
+ } , [ history . location . search , formik . initialValues ] )
146
+
130
147
return (
131
148
< >
132
149
{ elements . breadcrumbs }
You can’t perform that action at this time.
0 commit comments