Skip to content

Commit d531372

Browse files
committed
Merge branch 'edit-page-for-instances' into 'master'
fix(ui): edit page for instances, replace history to avoid crash, fix n/a texts See merge request postgres-ai/database-lab!756
2 parents 0ef582e + 83b4113 commit d531372

File tree

7 files changed

+54
-50
lines changed

7 files changed

+54
-50
lines changed

ui/packages/platform/src/api/api.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ class Api {
519519
Authorization: 'Bearer ' + token,
520520
}
521521
let params = {
522+
url: instanceData.url,
522523
instance_id: Number(instanceData.instanceId),
523524
project_name: instanceData.project,
524525
project_label: instanceData.projectLabel,

ui/packages/platform/src/components/AddDbLabInstanceFormWrapper/AddDbLabInstanceFormWrapper.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,26 @@ export const AddDbLabInstanceFormWrapper = (props: DbLabInstanceFormProps) => {
2121
maxWidth: 400,
2222
},
2323
errorMessage: {
24+
marginTop: 10,
2425
color: 'red',
2526
},
2627
fieldBlock: {
2728
width: '100%',
2829
},
2930
urlOkIcon: {
30-
marginBottom: -5,
31-
marginLeft: 10,
3231
color: 'green',
3332
},
34-
urlOk: {
35-
color: 'green',
33+
urlOk: { display: 'flex', gap: 5, alignItems: 'center', color: 'green' },
34+
urlTextMargin: {
35+
marginTop: 10,
3636
},
3737
urlFailIcon: {
38-
marginBottom: -5,
39-
marginLeft: 10,
4038
color: 'red',
4139
},
4240
urlFail: {
41+
display: 'flex',
42+
gap: 5,
43+
alignItems: 'center',
4344
color: 'red',
4445
},
4546
warning: {

ui/packages/platform/src/components/AddDbLabInstanceFormWrapper/AddDblabInstanceForm.tsx

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,16 @@ class DbLabInstanceForm extends Component<
134134

135135
if (dbLabInstances.data) {
136136
that.setState({
137-
project_label: dbLabInstances.data[instanceID]?.project_label_or_name,
137+
project_label:
138+
that.state.project_label ||
139+
dbLabInstances.data[instanceID]?.project_label_or_name,
138140
token: dbLabInstances.data[instanceID]?.verify_token,
139-
useTunnel: dbLabInstances.data[instanceID]?.use_tunnel,
140-
url: dbLabInstances.data[instanceID]?.url,
141-
sshServerUrl: dbLabInstances.data[instanceID]?.ssh_server_url,
141+
useTunnel:
142+
that.state.useTunnel || dbLabInstances.data[instanceID]?.use_tunnel,
143+
url: that.state.url || dbLabInstances.data[instanceID]?.url,
144+
sshServerUrl:
145+
that.state.sshServerUrl ||
146+
dbLabInstances.data[instanceID]?.ssh_server_url,
142147
})
143148
}
144149

@@ -337,10 +342,6 @@ class DbLabInstanceForm extends Component<
337342
</span>
338343
)}
339344

340-
<div className={classes.errorMessage}>
341-
{data?.errorMessage ? data.errorMessage : null}
342-
</div>
343-
344345
<Grid container>
345346
<div className={classes.fieldBlock}>
346347
<TextField
@@ -562,30 +563,32 @@ class DbLabInstanceForm extends Component<
562563
Verify URL
563564
</Button>
564565

565-
{data?.isCheckProcessed &&
566-
data?.isChecked &&
567-
(isHttps(this.state.url) || this.state.useTunnel) ? (
568-
<span className={classes.urlOk}>
569-
<CheckCircleOutlineIcon className={classes.urlOkIcon} />{' '}
570-
Verified
571-
</span>
572-
) : null}
573-
574-
{data?.isCheckProcessed &&
575-
data?.isChecked &&
576-
!isHttps(this.state.url) &&
577-
!this.state.useTunnel ? (
578-
<span className={classes.urlFail}>
579-
<BlockIcon className={classes.urlFailIcon} /> Verified but is
580-
not secure
581-
</span>
582-
) : null}
583-
584-
{data?.isCheckProcessed && !data?.isChecked ? (
585-
<span className={classes.urlFail}>
586-
<BlockIcon className={classes.urlFailIcon} /> Not available
587-
</span>
588-
) : null}
566+
<div className={classes.urlTextMargin}>
567+
{data?.isCheckProcessed &&
568+
data?.isChecked &&
569+
(isHttps(this.state.url) || this.state.useTunnel) ? (
570+
<span className={classes.urlOk}>
571+
<CheckCircleOutlineIcon className={classes.urlOkIcon} />{' '}
572+
Verified
573+
</span>
574+
) : null}
575+
576+
{data?.isCheckProcessed &&
577+
data?.isChecked &&
578+
!isHttps(this.state.url) &&
579+
!this.state.useTunnel ? (
580+
<span className={classes.urlFail}>
581+
<BlockIcon className={classes.urlFailIcon} /> Verified but is
582+
not secure
583+
</span>
584+
) : null}
585+
586+
{data?.isCheckProcessed && !data?.isChecked ? (
587+
<span className={classes.urlFail}>
588+
<BlockIcon className={classes.urlFailIcon} /> Not available
589+
</span>
590+
) : null}
591+
</div>
589592
</div>
590593

591594
<div className={classes.fieldBlock} style={{ marginTop: 40 }}>
@@ -607,6 +610,9 @@ class DbLabInstanceForm extends Component<
607610
Cancel
608611
</Button>
609612
</div>
613+
<div className={classes.errorMessage}>
614+
{data?.errorMessage ? data.errorMessage : null}
615+
</div>
610616
</Grid>
611617
</div>
612618
)

ui/packages/platform/src/components/AddMemberForm/AddMemberForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class InviteForm extends Component<InviteFormWithStylesProps, InviteFormState> {
5858
that.setState({ data: this.data })
5959

6060
if (this.data.inviteUser.isProcessed && !this.data.inviteUser.error) {
61-
that.props.history.push('/' + org + '/members')
61+
window.location.href = '/' + org + '/members'
6262
}
6363

6464
const auth: InviteFormState['data']['auth'] =

ui/packages/platform/src/components/DbLabInstances/DbLabInstances.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ class DbLabInstances extends Component<
469469
<TableCell className={classes.cell}>
470470
{data.data[index].state && data.data[index].url
471471
? data.data[index].url
472-
: ''}
472+
: 'N/A'}
473473
{!isHttps(data.data[index].url) &&
474474
data.data[index].url &&
475475
!data.data[index].use_tunnel ? (
@@ -480,9 +480,7 @@ class DbLabInstances extends Component<
480480
>
481481
<WarningIcon className={classes.warningIcon} />
482482
</Tooltip>
483-
) : (
484-
'N/A'
485-
)}
483+
) : null}
486484
</TableCell>
487485
<TableCell className={classes.cell}>
488486
{data.data[index]?.state?.cloning?.numClones ??

ui/packages/platform/src/components/IndexPage/IndexPage.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ function ProjectWrapper(parentProps: Omit<ProjectWrapperProps, 'classes'>) {
166166
<Route
167167
path="/:org/:project/instances/edit/:instanceId"
168168
render={(props) => (
169-
<DbLabInstanceFormWrapper edit {...props} {...customProps} />
169+
<AddDbLabInstanceFormWrapper edit {...props} {...customProps} />
170170
)}
171171
/>
172172
<Route
@@ -921,14 +921,14 @@ class IndexPage extends Component<IndexPageWithStylesProps, IndexPageState> {
921921
env.data &&
922922
env.data.orgs[orgProfile.data.alias]
923923
) {
924-
that.props.history.push('/' + orgProfile.data.alias + '/settings')
924+
window.location.href = '/' + orgProfile.data.alias + '/settings'
925925
}
926926

927927
if (
928928
(env.isConfirmProcessed || (env.data && env.data.info.is_active)) &&
929929
Urls.isRequestedPath('confirm')
930930
) {
931-
that.props.history.push(ROUTES.ROOT.path)
931+
window.location.href = ROUTES.ROOT.path
932932
}
933933
})
934934

ui/packages/platform/src/components/JoeInstances/JoeInstances.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ class JoeInstances extends Component<
403403
</TableCell>
404404

405405
<TableCell className={classes.cell}>
406-
{data.data[i].url ? data.data[i].url : ''}
406+
{data.data[i].url ? data.data[i].url : 'N/A'}
407407
{data.data[i].url &&
408408
!isHttps(data.data[i].url) &&
409409
!data.data[i].use_tunnel ? (
@@ -414,9 +414,7 @@ class JoeInstances extends Component<
414414
>
415415
<WarningIcon className={classes.warningIcon} />
416416
</Tooltip>
417-
) : (
418-
'N/A'
419-
)}
417+
) : null}
420418
</TableCell>
421419

422420
<TableCell align={'right'}>

0 commit comments

Comments
 (0)