Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c8b1e82

Browse files
committed
Merge branch 'add-instance-validation' into 'master'
fix(ui): check for all required params, update field errors See merge request postgres-ai/database-lab!848
2 parents aeada92 + 9c5f7c1 commit c8b1e82

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

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

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class DbLabInstanceForm extends Component<
124124
const url = window.location.href.split('/')
125125
const instanceID = url[url.length - 1]
126126

127-
this.unsubscribe = (Store.listen as RefluxTypes["listen"])(function () {
127+
this.unsubscribe = (Store.listen as RefluxTypes['listen'])(function () {
128128
that.setState({ data: this.data, instanceID: instanceID })
129129

130130
const auth = this.data && this.data.auth ? this.data.auth : null
@@ -138,7 +138,8 @@ class DbLabInstanceForm extends Component<
138138
project_label:
139139
that.state.project_label ||
140140
dbLabInstances.data[instanceID]?.project_label_or_name,
141-
token: dbLabInstances.data[instanceID]?.verify_token,
141+
token:
142+
that.state.token || dbLabInstances.data[instanceID]?.verify_token,
142143
useTunnel:
143144
that.state.useTunnel || dbLabInstances.data[instanceID]?.use_tunnel,
144145
url: that.state.url || dbLabInstances.data[instanceID]?.url,
@@ -224,14 +225,30 @@ class DbLabInstanceForm extends Component<
224225
}
225226
}
226227

228+
clearFieldError = (fieldName: string) => {
229+
const errorFields = this.state.errorFields.filter((field) => {
230+
return field !== fieldName
231+
})
232+
233+
this.setState({ errorFields: errorFields })
234+
}
235+
227236
checkUrlHandler = () => {
228237
const auth =
229238
this.state.data && this.state.data.auth ? this.state.data.auth : null
230239
const data = this.state.data ? this.state.data.newDbLabInstance : null
231-
const errorFields = []
240+
const errorFields: string[] = []
232241

233242
if (!this.state.url) {
234243
errorFields.push('url')
244+
}
245+
246+
if (!this.state.token) {
247+
errorFields.push('token')
248+
}
249+
250+
if (errorFields.length > 0) {
251+
this.setState({ errorFields: errorFields })
235252
return
236253
}
237254

@@ -259,6 +276,7 @@ class DbLabInstanceForm extends Component<
259276

260277
generateTokenHandler = () => {
261278
this.setState({ token: generateToken() })
279+
this.clearFieldError('token')
262280
}
263281

264282
render() {
@@ -357,6 +375,7 @@ class DbLabInstanceForm extends Component<
357375
this.setState({
358376
project: e.target.value,
359377
})
378+
this.clearFieldError('project')
360379
Actions.resetNewDbLabInstance()
361380
}}
362381
margin="normal"
@@ -389,6 +408,7 @@ class DbLabInstanceForm extends Component<
389408
this.setState({
390409
project_label: e.target.value,
391410
})
411+
this.clearFieldError('project_label')
392412
Actions.resetNewDbLabInstance()
393413
}}
394414
margin="normal"
@@ -423,6 +443,7 @@ class DbLabInstanceForm extends Component<
423443
this.setState({
424444
token: e.target.value,
425445
})
446+
this.clearFieldError('token')
426447
Actions.resetNewDbLabInstance()
427448
}}
428449
margin="normal"
@@ -470,6 +491,7 @@ class DbLabInstanceForm extends Component<
470491
this.setState({
471492
url: e.target.value,
472493
})
494+
this.clearFieldError('url')
473495
Actions.resetNewDbLabInstance()
474496
}}
475497
margin="normal"
@@ -534,6 +556,7 @@ class DbLabInstanceForm extends Component<
534556
this.setState({
535557
sshServerUrl: e.target.value,
536558
})
559+
this.clearFieldError('token')
537560
Actions.resetNewDbLabInstance()
538561
}}
539562
margin="normal"

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /