Skip to content

Commit 63f50d4

Browse files
committed
Merge branch 'dle-4-0-ui-adjustments' into 'dle-4-0'
UI: dle-4-0 release fixes See merge request postgres-ai/database-lab!944
2 parents d78f176 + e2f20b7 commit 63f50d4

File tree

34 files changed

+541
-481
lines changed

34 files changed

+541
-481
lines changed

ui/packages/ce/cypress/e2e/tabs.cy.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Cypress.on('uncaught:exception', () => {
44
return false
55
})
66

7-
// Function to set up intercepts for the requests
87
function setupIntercepts() {
98
const exceptions = [
109
'/healthz',
@@ -44,7 +43,6 @@ function setupIntercepts() {
4443
},
4544
})
4645

47-
// Intercept all fetch requests and return a 200
4846
cy.intercept('GET', '*', (req) => {
4947
if (
5048
req.resourceType === 'fetch' &&
@@ -61,7 +59,6 @@ function setupIntercepts() {
6159
}
6260

6361
describe('Configuration tab', () => {
64-
// It should intercept the requests
6562
beforeEach(() => {
6663
setupIntercepts()
6764
})
@@ -71,19 +68,10 @@ describe('Configuration tab', () => {
7168
retryOnStatusCodeFailure: true,
7269
onLoad: () => {
7370
cy.get('.MuiTabs-flexContainer')
74-
.contains('Configuration', { timeout: 10000 })
71+
.contains('Configuration')
7572
.should('be.visible')
7673
.click({ force: true })
7774
},
7875
})
7976
})
80-
81-
it('should have form inputs in the "Configuration" tab', () => {
82-
cy.get('.MuiTabs-flexContainer')
83-
.contains('Configuration', { timeout: 10000 })
84-
.should('be.visible')
85-
.click({ force: true })
86-
87-
cy.get('button[type="button"]').should('exist')
88-
})
8977
})

ui/packages/ce/src/App/Instance/Branches/CreateBranch/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { getBranches } from 'api/branches/getBranches'
22
import { createBranch } from 'api/branches/createBranch'
3-
import { getSnapshotList } from 'api/branches/getSnapshotList'
3+
import { getBranchSnapshots } from 'api/snapshots/getBranchSnapshots'
44

55
import { CreateBranchPage } from '@postgres.ai/shared/pages/CreateBranch'
66

@@ -12,7 +12,7 @@ export const CreateBranch = () => {
1212
const api = {
1313
getBranches,
1414
createBranch,
15-
getSnapshotList,
15+
getBranchSnapshots,
1616
}
1717

1818
const elements = {

ui/packages/ce/src/App/Instance/Clones/CreateClone/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import { NavPath } from 'components/NavPath'
55
import { ROUTES } from 'config/routes'
66
import { getInstance } from 'api/instances/getInstance'
77
import { getInstanceRetrieval } from 'api/instances/getInstanceRetrieval'
8-
import { getSnapshots } from 'api/snapshots/getSnapshots'
98
import { createClone } from 'api/clones/createClone'
109
import { getClone } from 'api/clones/getClone'
1110
import { getBranches } from 'api/branches/getBranches'
11+
import { getBranchSnapshots } from 'api/snapshots/getBranchSnapshots'
1212

1313
export const CreateClone = () => {
1414
const routes = {
@@ -17,12 +17,12 @@ export const CreateClone = () => {
1717
}
1818

1919
const api = {
20-
getSnapshots,
2120
getInstance,
2221
getInstanceRetrieval,
2322
createClone,
2423
getClone,
2524
getBranches,
25+
getBranchSnapshots,
2626
}
2727

2828
const elements = {

ui/packages/ce/src/api/branches/deleteBranch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ export const deleteBranch = async (branchName: string) => {
1111
const response = await request('/branch/delete', {
1212
method: 'POST',
1313
body: JSON.stringify({
14-
branchName: branchName,
14+
branchName,
1515
}),
1616
})
1717

1818
return {
1919
response: response.ok ? await response.json() : null,
20-
error: response.ok ? null : response,
20+
error: response.ok ? null : await response.json(),
2121
}
2222
}

ui/packages/ce/src/api/branches/getBranches.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
*/
77

88
import { request } from 'helpers/request'
9+
import { formatBranchesDto } from '@postgres.ai/shared/types/api/endpoints/getBranches'
910

1011
export const getBranches = async () => {
1112
const response = await request(`/branches`)
1213

1314
return {
14-
response: response.ok ? await response.json() : null,
15+
response: response.ok ? formatBranchesDto(await response.json()) : null,
1516
error: response.ok ? null : response,
1617
}
1718
}

ui/packages/ce/src/api/snapshots/destroySnapshot.ts renamed to ui/packages/ce/src/api/snapshots/destroySnapshot.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
*--------------------------------------------------------------------------
66
*/
77

8-
import { DestroySnapshot } from '@postgres.ai/shared/types/api/endpoints/destroySnapshot'
9-
108
import { request } from 'helpers/request'
119

12-
export const destroySnapshot: DestroySnapshot = async (snapshotId) => {
10+
export const destroySnapshot = async (snapshotId) => {
1311
const response = await request(`/snapshot/delete`, {
1412
method: 'POST',
1513
body: JSON.stringify({
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*--------------------------------------------------------------------------
2+
* Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov [email protected]
3+
* All Rights Reserved. Proprietary and confidential.
4+
* Unauthorized copying of this file, via any medium is strictly prohibited
5+
*--------------------------------------------------------------------------
6+
*/
7+
8+
import { request } from 'helpers/request'
9+
10+
export const getBranchSnapshots = async (branch: string) => {
11+
const response = await request(`/branch/snapshots/${branch}`)
12+
13+
return {
14+
response: response.ok ? await response.json() : null,
15+
error: response.ok ? null : response,
16+
}
17+
}

ui/packages/shared/components/DestroyCloneModal/index.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,12 @@ export const DestroyCloneModal = (props: Props) => {
2828
}
2929

3030
return (
31-
<Modal
32-
title={`Destroy clone ${cloneId}`}
33-
onClose={onClose}
34-
isOpen={isOpen}
35-
>
31+
<Modal title={`Destroy clone ${cloneId}`} onClose={onClose} isOpen={isOpen}>
3632
<Text>
3733
Are you sure you want to destroy clone{' '}
38-
<ImportantText>{cloneId}</ImportantText>?
34+
<ImportantText>{cloneId}</ImportantText>? This action cannot be undone.
3935
</Text>
40-
36+
4137
<SimpleModalControls
4238
items={[
4339
{
@@ -48,7 +44,7 @@ export const DestroyCloneModal = (props: Props) => {
4844
text: 'Destroy clone',
4945
variant: 'primary',
5046
onClick: handleClickDestroy,
51-
}
47+
},
5248
]}
5349
/>
5450
</Modal>

ui/packages/shared/pages/Branches/Branch/index.tsx

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040

4141
import { useCreatedStores } from './useCreatedStores'
4242
import { Host } from './context'
43+
import { DeleteBranch } from 'types/api/endpoints/deleteBranch'
4344

4445
type Props = Host
4546

@@ -152,15 +153,9 @@ export const BranchesPage = observer((props: Props) => {
152153
isBranchesLoading,
153154
getBranchesError,
154155
snapshotListError,
155-
deleteBranchError,
156156
getBranchError,
157157
} = stores.main
158158

159-
const handleDestroyBranch = async () => {
160-
const isSuccess = await deleteBranch(props.branchId)
161-
if (isSuccess) history.push(props.routes.branch())
162-
}
163-
164159
const hasBranchError = getBranchesError || getBranchError || snapshotListError
165160

166161
const branchLogLength = snapshotList?.reduce((acc, snapshot) => {
@@ -359,11 +354,11 @@ export const BranchesPage = observer((props: Props) => {
359354
className={classes.marginTop}
360355
tag="h2"
361356
level={2}
362-
text={'Delete branch using CLI'}
357+
text={'Destroy branch using CLI'}
363358
/>
364359
<p className={classes.cliText}>
365-
You can delete this branch using CLI. To do this, run the
366-
command below:
360+
You can destroy this branch using CLI. To do this, run the command
361+
below:
367362
</p>
368363
<SyntaxHighlight content={`dblab branch delete ${props.branchId}`} />
369364

@@ -374,8 +369,8 @@ export const BranchesPage = observer((props: Props) => {
374369
text={'Get branches using CLI'}
375370
/>
376371
<p className={classes.marginTop}>
377-
You can get a list of all branches using CLI. Copy the command
378-
below and paste it into your terminal.
372+
To list all branches using CLI, copy
373+
and paste it into your terminal.
379374
</p>
380375
<SyntaxHighlight content={getCliBranchListCommand()} />
381376

@@ -394,8 +389,7 @@ export const BranchesPage = observer((props: Props) => {
394389
<DeleteBranchModal
395390
isOpen={isOpenDestroyModal}
396391
onClose={() => setIsOpenDestroyModal(false)}
397-
deleteBranchError={deleteBranchError}
398-
deleteBranch={handleDestroyBranch}
392+
deleteBranch={deleteBranch as DeleteBranch}
399393
branchName={props.branchId}
400394
/>
401395
</div>

ui/packages/shared/pages/Branches/Branch/stores/Main.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
import { makeAutoObservable } from 'mobx'
99

1010
import { GetBranches } from '@postgres.ai/shared/types/api/endpoints/getBranches'
11-
import { GetBranchesResponseType } from '@postgres.ai/shared/types/api/endpoints/getBranches'
11+
import { Branch } from '@postgres.ai/shared/types/api/endpoints/getBranches'
1212
import { DeleteBranch } from '@postgres.ai/shared/types/api/endpoints/deleteBranch'
1313
import {
14+
SnapshotList,
1415
GetSnapshotList,
15-
GetSnapshotListResponseType,
1616
} from '@postgres.ai/shared/types/api/endpoints/getSnapshotList'
1717

1818
type Error = {
@@ -29,15 +29,14 @@ export type Api = {
2929
export class MainStore {
3030
getBranchError: Error | null = null
3131
snapshotListError: Error | null = null
32-
deleteBranchError: Error | null = null
3332
getBranchesError: Error | null = null
3433

3534
isReloading = false
3635
isBranchesLoading = false
3736

38-
branches: GetBranchesResponseType[] = []
39-
branch: GetBranchesResponseType | null = null
40-
snapshotList: GetSnapshotListResponseType[] | null = null
37+
branches: Branch[] | null = null
38+
branch: Branch | null = null
39+
snapshotList: SnapshotList[] | null = null
4140

4241
private readonly api: Api
4342

@@ -100,15 +99,10 @@ export class MainStore {
10099
deleteBranch = async (branchName: string) => {
101100
if (!branchName) return
102101

103-
this.deleteBranchError = null
104-
105102
const { response, error } = await this.api.deleteBranch(branchName)
106103

107-
if (error) {
108-
this.deleteBranchError = await error.json().then((err) => err)
109-
}
110104

111-
return response
105+
return { response, error }
112106
}
113107

114108
getSnapshotList = async (branchName: string) => {

0 commit comments

Comments
 (0)