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:
7272 # TODO: Set up caching.
7373# - pnpm config set store-dir /builds/postgres-ai/database-lab/.pnpm-store/
7474 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
7677 - 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)
7881 - 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 = () => {
5959 instance : ( ) => ROUTES . INSTANCE . path ,
6060 snapshot : ( snapshotId : string ) =>
6161 ROUTES . INSTANCE . SNAPSHOTS . SNAPSHOT . createPath ( snapshotId ) ,
62+ createSnapshot : ( cloneId : string ) => ROUTES . INSTANCE . SNAPSHOTS . CREATE . createPath ( cloneId ) ,
6263 } }
6364 api = { api }
6465 elements = { elements }
Original file line number Diff line number Diff line change @@ -27,6 +27,13 @@ export const ROUTES = {
2727 CREATE : {
2828 name : 'Create snapshot' ,
2929 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+ }
3037 } ,
3138
3239 SNAPSHOTS : {
Original file line number Diff line number Diff line change @@ -5,8 +5,12 @@ export const ORG_SNAPSHOTS = {
55 return `/${ org } /instances/${ instanceId } /snapshots`
66 } ,
77 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+ }
1014
1115 return `/${ org } /instances/${ instanceId } /snapshots/add`
1216 } ,
@@ -44,13 +48,19 @@ export const PROJECT_SNAPSHOTS = {
4448 org : string
4549 project : string
4650 instanceId : string
51+ cloneId ?: string
4752 } ) => {
4853 const {
4954 org = ':org' ,
5055 project = ':project' ,
5156 instanceId = ':instanceId' ,
57+ cloneId = undefined ,
5258 } = args ?? { }
5359
60+ if ( cloneId ) {
61+ return `/${ org } /${ project } /instances/${ instanceId } /snapshots/add?clone_id=${ cloneId } `
62+ }
63+
5464 return `/${ org } /${ project } /instances/${ instanceId } /snapshots/add`
5565 } ,
5666 } ,
Original file line number Diff line number Diff line change @@ -45,6 +45,19 @@ export const Clone = () => {
4545 instanceId : params . instanceId ,
4646 snapshotId,
4747 } ) ,
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+ } )
4861 }
4962
5063 const api = {
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ export type Host = {
99 routes : {
1010 instance : ( ) => string
1111 snapshot : ( snapshotId : string ) => string
12+ createSnapshot : ( cloneId : string ) => string
1213 }
1314 api : Api
1415 elements : {
Original file line number Diff line number Diff line change @@ -276,17 +276,7 @@ export const Clone = observer((props: Props) => {
276276 }
277277
278278 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 ) )
290280 }
291281
292282 // Clone reload.
Original file line number Diff line number Diff line change @@ -127,6 +127,23 @@ export const CreateSnapshotPage = observer(
127127 load ( instanceId )
128128 } , [ ] )
129129
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+
130147 return (
131148 < >
132149 { elements . breadcrumbs }
You can’t perform that action at this time.
0 commit comments