@@ -15,6 +15,7 @@ import { useMessage } from "@/lib/feedback/message"
1515import { buildRoute , getLoginRoute } from "@/lib/routes"
1616import logoImage from "@/assets/logo.svg"
1717import { configManager } from "@/lib/config"
18+ import { checkServerHealth } from "@/lib/config-helpers"
1819
1920export default function ConfigPage ( ) {
2021 return (
@@ -32,9 +33,12 @@ function ConfigPageContent() {
3233 const [ serverHost , setServerHost ] = useState ( ( ) =>
3334 typeof window !== "undefined" ? ( localStorage . getItem ( "rustfs-server-host" ) ?? "" ) : "" ,
3435 )
36+ const [ isSaving , setIsSaving ] = useState ( false )
3537
3638 const validateAndSave = async ( e : React . FormEvent ) => {
3739 e . preventDefault ( )
40+ setIsSaving ( true )
41+
3842 try {
3943 if ( serverHost ) {
4044 let urlToValidate = serverHost . trim ( )
@@ -45,7 +49,16 @@ function ConfigPageContent() {
4549
4650 new URL ( urlToValidate )
4751
48- const urlToSave = serverHost . match ( / ^ h t t p s ? : \/ \/ / ) ? serverHost : urlToValidate
52+ const urlToSave = urlToValidate
53+
54+ const healthResult = await checkServerHealth ( urlToSave )
55+ if ( ! healthResult . healthy ) {
56+ message . error (
57+ `${ t ( "Unable to reach RustFS server health endpoint" ) } : ${ healthResult . error ?? t ( "Request failed" ) } ` ,
58+ )
59+ return
60+ }
61+
4962 localStorage . setItem ( "rustfs-server-host" , urlToSave )
5063
5164 if ( ! serverHost . match ( / ^ h t t p s ? : \/ \/ / ) ) {
@@ -64,6 +77,8 @@ function ConfigPageContent() {
6477 } , 200 )
6578 } catch ( error ) {
6679 message . error ( t ( "Invalid server address format" ) + ": " + ( error as Error ) . message )
80+ } finally {
81+ setIsSaving ( false )
6782 }
6883 }
6984
@@ -125,15 +140,15 @@ function ConfigPageContent() {
125140 </ Field >
126141
127142 < div className = "flex gap-3" >
128- < Button type = "submit" className = "flex-1" >
143+ < Button type = "submit" className = "flex-1" disabled = { isSaving } >
129144 { t ( "Save Configuration" ) }
130145 </ Button >
131146
132- < Button type = "button" variant = "outline" onClick = { resetToCurrentHost } >
147+ < Button type = "button" variant = "outline" onClick = { resetToCurrentHost } disabled = { isSaving } >
133148 { t ( "Reset" ) }
134149 </ Button >
135150
136- < Button type = "button" variant = "outline" onClick = { skipConfig } >
151+ < Button type = "button" variant = "outline" onClick = { skipConfig } disabled = { isSaving } >
137152 { t ( "Skip" ) }
138153 </ Button >
139154 </ div >
0 commit comments