Skip to content

Commit 90cfc42

Browse files
author
Bogdan Tsechoev
committed
Merge branch '572-dle-4-0-ui-feature-requests' into 'dle-4-0'
feat(ui): UI feature requests, dle-4-0 for EE UI (Platform) See merge request postgres-ai/database-lab!974
2 parents 2b2f8f0 + 5a7eb93 commit 90cfc42

File tree

86 files changed

+3583
-2236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+3583
-2236
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,15 @@ export const Branch = () => {
4040
return (
4141
<PageContainer>
4242
<BranchesPage
43+
instanceId=""
4344
api={api}
4445
elements={elements}
4546
branchId={branchId}
4647
routes={{
4748
branch: () => ROUTES.INSTANCE.BRANCHES.BRANCHES.path,
49+
branches: () => ROUTES.INSTANCE.BRANCHES.BRANCHES.path,
50+
snapshot: (snapshotId: string) =>
51+
ROUTES.INSTANCE.SNAPSHOTS.SNAPSHOT.createPath(snapshotId),
4852
}}
4953
/>
5054
</PageContainer>

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ import { NavPath } from 'components/NavPath'
99
import { ROUTES } from 'config/routes'
1010

1111
export const CreateBranch = () => {
12+
const routes = {
13+
branch: (branchName: string) =>
14+
ROUTES.INSTANCE.BRANCHES.BRANCH.createPath(branchName),
15+
}
16+
1217
const api = {
1318
getBranches,
1419
createBranch,
@@ -29,7 +34,12 @@ export const CreateBranch = () => {
2934

3035
return (
3136
<PageContainer>
32-
<CreateBranchPage instanceId={''} api={api} elements={elements} />
37+
<CreateBranchPage
38+
instanceId={''}
39+
routes={routes}
40+
api={api}
41+
elements={elements}
42+
/>
3343
</PageContainer>
3444
)
3545
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { createSnapshot } from 'api/snapshots/createSnapshot'
1414
import { PageContainer } from 'components/PageContainer'
1515
import { NavPath } from 'components/NavPath'
1616
import { ROUTES } from 'config/routes'
17+
import { destroySnapshot } from 'api/snapshots/destroySnapshot'
1718

1819
type Params = {
1920
cloneId: string
@@ -29,6 +30,7 @@ export const Clone = () => {
2930
getClone,
3031
resetClone,
3132
destroyClone,
33+
destroySnapshot,
3234
updateClone,
3335
createSnapshot,
3436
}
@@ -55,6 +57,8 @@ export const Clone = () => {
5557
cloneId={cloneId}
5658
routes={{
5759
instance: () => ROUTES.INSTANCE.path,
60+
snapshot: (snapshotId: string) =>
61+
ROUTES.INSTANCE.SNAPSHOTS.SNAPSHOT.createPath(snapshotId),
5862
}}
5963
api={api}
6064
elements={elements}

ui/packages/ce/src/App/Instance/Page/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import { Instance } from '@postgres.ai/shared/pages/Instance'
32

43
import { PageContainer } from 'components/PageContainer'
@@ -30,6 +29,12 @@ export const Page = ({ renderCurrentTab }: { renderCurrentTab?: number }) => {
3029
createSnapshot: () => ROUTES.INSTANCE.SNAPSHOTS.CREATE.path,
3130
clone: (cloneId: string) =>
3231
ROUTES.INSTANCE.CLONES.CLONE.createPath(cloneId),
32+
branch: (branchId: string) =>
33+
ROUTES.INSTANCE.BRANCHES.BRANCH.createPath(branchId),
34+
branches: () => ROUTES.INSTANCE.BRANCHES.path,
35+
snapshots: () => ROUTES.INSTANCE.SNAPSHOTS.path,
36+
snapshot: (snapshotId: string) =>
37+
ROUTES.INSTANCE.SNAPSHOTS.SNAPSHOT.createPath(snapshotId),
3338
}
3439

3540
const api = {
@@ -50,7 +55,7 @@ export const Page = ({ renderCurrentTab }: { renderCurrentTab?: number }) => {
5055
createBranch,
5156
getBranches,
5257
getSnapshotList,
53-
deleteBranch
58+
deleteBranch,
5459
}
5560

5661
const elements = {

ui/packages/ce/src/App/Instance/Snapshots/CreateSnapshot/index.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,15 @@ export const CreateSnapshot = () => {
2727

2828
return (
2929
<PageContainer>
30-
<CreateSnapshotPage api={api} elements={elements} />
30+
<CreateSnapshotPage
31+
instanceId=""
32+
api={api}
33+
elements={elements}
34+
routes={{
35+
snapshot: (snapshotId: string) =>
36+
ROUTES.INSTANCE.SNAPSHOTS.SNAPSHOT.createPath(snapshotId),
37+
}}
38+
/>
3139
</PageContainer>
3240
)
3341
}

ui/packages/ce/src/App/Instance/Snapshots/Snapshot/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ export const Snapshot = () => {
4545
snapshotId={snapshotId}
4646
routes={{
4747
snapshot: () => ROUTES.INSTANCE.SNAPSHOTS.SNAPSHOTS.path,
48+
branch: (branchName: string) =>
49+
ROUTES.INSTANCE.BRANCHES.BRANCH.createPath(branchName),
50+
clone: (cloneId: string) =>
51+
ROUTES.INSTANCE.CLONES.CLONE.createPath(cloneId),
4852
}}
4953
api={api}
5054
elements={elements}

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77

88
import { request } from 'helpers/request'
99

10-
export const destroySnapshot = async (
11-
snapshotId: string,
12-
forceDelete: boolean,
13-
) => {
10+
export const destroySnapshot = async (snapshotId, forceDelete) => {
1411
const response = await request(`/snapshot/delete`, {
1512
method: 'POST',
1613
body: JSON.stringify({
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*--------------------------------------------------------------------------
2+
* Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai
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+
import { CreateBranchFormValues } from '@postgres.ai/shared/types/api/endpoints/createBranch'
11+
12+
export const createBranch = async (req: CreateBranchFormValues) => {
13+
const response = await request('/rpc/dblab_api_call', {
14+
method: 'POST',
15+
body: JSON.stringify({
16+
instance_id: req.instanceId,
17+
action: '/branch/create',
18+
method: 'post',
19+
data: {
20+
branchName: req.branchName,
21+
...(req.baseBranch && { baseBranch: req.baseBranch }),
22+
...(req.snapshotID && { snapshotID: req.snapshotID }),
23+
},
24+
}),
25+
})
26+
27+
return {
28+
response: response.ok ? await response.json() : null,
29+
error: response.ok ? null : response,
30+
}
31+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*--------------------------------------------------------------------------
2+
* Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai
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 deleteBranch = async (branchName: string, instanceId: string) => {
11+
const response = await request('/rpc/dblab_api_call', {
12+
method: 'POST',
13+
body: JSON.stringify({
14+
action: '/branch/delete',
15+
instance_id: instanceId,
16+
method: 'post',
17+
data: {
18+
branchName,
19+
},
20+
}),
21+
})
22+
23+
return {
24+
response: response.ok ? await response.json() : null,
25+
error: response.ok ? null : await response.json(),
26+
}
27+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*--------------------------------------------------------------------------
2+
* Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai
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+
import { formatBranchesDto } from '@postgres.ai/shared/types/api/endpoints/getBranches'
10+
11+
export const getBranches = async (instanceId: string) => {
12+
const response = await request('/rpc/dblab_api_call', {
13+
method: 'POST',
14+
body: JSON.stringify({
15+
instance_id: instanceId,
16+
action: '/branches',
17+
method: 'get',
18+
}),
19+
})
20+
21+
return {
22+
response: response.ok ? formatBranchesDto(await response.json()) : null,
23+
error: response.ok ? null : response,
24+
}
25+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*--------------------------------------------------------------------------
2+
* Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai
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 getSnapshotList = async (
11+
branchName: string,
12+
instanceId: string,
13+
) => {
14+
const response = await request('/rpc/dblab_api_call', {
15+
method: 'POST',
16+
body: JSON.stringify({
17+
instance_id: instanceId,
18+
action: '/branch/log',
19+
method: 'post',
20+
data: {
21+
branchName: branchName,
22+
},
23+
}),
24+
})
25+
26+
return {
27+
response: response.ok ? await response.json() : null,
28+
error: response.ok ? null : response,
29+
}
30+
}

ui/packages/platform/src/api/configs/getConfig.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
import { formatConfig } from '@postgres.ai/shared/types/api/entities/config'
22
import { request } from 'helpers/request'
33

4-
export const getConfig = async () => {
5-
const response = await request('/admin/config')
4+
export const getConfig = async (instanceId: string) => {
5+
const response = await request('/rpc/dblab_api_call', {
6+
method: 'POST',
7+
body: JSON.stringify({
8+
instance_id: instanceId,
9+
action: '/admin/config',
10+
method: 'get',
11+
}),
12+
})
613

714
return {
815
response: response.ok ? formatConfig(await response.json()) : null,

ui/packages/platform/src/api/configs/getFullConfig.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
import { request } from 'helpers/request'
2-
export const getFullConfig = async () => {
3-
const response = await request('/admin/config.yaml')
2+
3+
export const getFullConfig = async (instanceId: string) => {
4+
const response = await request('/rpc/dblab_api_call', {
5+
method: 'POST',
6+
body: JSON.stringify({
7+
instance_id: instanceId,
8+
action: '/admin/config.yaml',
9+
method: 'get',
10+
}),
11+
})
412
.then((res) => res.blob())
513
.then((blob) => blob.text())
614
.then((yamlAsString) => {

ui/packages/platform/src/api/configs/testDbSource.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,25 @@ import { dbSource } from '@postgres.ai/shared/types/api/entities/dbSource'
22
import { request } from 'helpers/request'
33

44
export const testDbSource = async (req: dbSource) => {
5-
const response = await request('/admin/test-db-source', {
5+
const response = await request('/rpc/dblab_api_call', {
66
method: 'POST',
77
body: JSON.stringify({
8-
host: req.host,
9-
port: req.port.toString(),
10-
dbname: req.dbname,
11-
username: req.username,
12-
password: req.password,
13-
db_list: req.db_list
8+
instance_id: req.instanceId,
9+
action: '/admin/test-db-source',
10+
method: 'post',
11+
data: {
12+
host: req.host,
13+
port: req.port.toString(),
14+
dbname: req.dbname,
15+
username: req.username,
16+
password: req.password,
17+
db_list: req.db_list,
18+
},
1419
}),
1520
})
1621

1722
return {
18-
response: response.ok ? await response.json(): null,
19-
error: response.ok ? null : await response.json()
23+
response: response.ok ? await response.json() : null,
24+
error: response.ok ? null : await response.json(),
2025
}
2126
}

0 commit comments

Comments
 (0)