From 5738ff7b9edc03495d3c5da04a31aa3b64650f59 Mon Sep 17 00:00:00 2001
From: Kai Reinhard <K.Reinhard@micromata.de>
Date: Sun, 10 Feb 2019 15:56:25 +0000
Subject: [PATCH] Test button...

---
 borgbutler-webapp/src/components/views/repos/RepoConfigPanel.jsx |   29 ++++++++++++++++++++++-------
 1 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/borgbutler-webapp/src/components/views/repos/RepoConfigPanel.jsx b/borgbutler-webapp/src/components/views/repos/RepoConfigPanel.jsx
index 4603d4b..dba3f44 100644
--- a/borgbutler-webapp/src/components/views/repos/RepoConfigPanel.jsx
+++ b/borgbutler-webapp/src/components/views/repos/RepoConfigPanel.jsx
@@ -1,6 +1,6 @@
 import React from 'react';
 import {Alert, FormGroup} from 'reactstrap';
-import {FormButton, FormField} from '../../general/forms/FormComponents';
+import {FormButton, FormField, FormLabel} from '../../general/forms/FormComponents';
 import {getRestServiceUrl} from '../../../utilities/global';
 import I18n from "../../general/translation/I18n";
 import LoadingOverlay from '../../general/loading/LoadingOverlay';
@@ -66,7 +66,11 @@
 
     setRepoValue(variable, value) {
         //console.log(variable + "=" + value);
-        this.setState({repoConfig: {...this.state.repoConfig, [variable]: value}})
+        this.setState({
+            repoConfig: {...this.state.repoConfig, [variable]: value},
+            // reset testStatus only, if test status is OK (config values are changed, new test required):
+            testStatus: this.state.testStatus === 'OK' ? undefined : this.state.testStatus
+        })
     }
 
     async onSave(event) {
@@ -128,7 +132,7 @@
                 description={'Repo not available or mis-configured (please refer the log files for more details).'}
             />
         }
-        let testResult = '';
+        let testResult = undefined;
         if (!this.state.testStatus) {
             // No test available.
         } else if (this.state.testStatus === 'exception') {
@@ -147,6 +151,15 @@
                 description={this.state.testResult}
             />
         }
+        let testResultGroup = '';
+        if (testResult) {
+            testResultGroup = <FormGroup row={true}>
+                <FormLabel length={2}>{'Test result'}</FormLabel>
+                <FormField length={10}>
+                    {testResult}
+                </FormField>
+            </FormGroup>;
+        }
         if (this.state.isFetching) {
             content = <React.Fragment>Loading...</React.Fragment>;
         } else if (this.state.failed) {
@@ -171,12 +184,13 @@
                                          repoConfig={repoConfig}
                                          handleRepoConfigChange={this.handleRepoConfigChange}
                                          setRepoValue={this.setRepoValue}/>
-                <FormGroup>
-                    <FormField length={12}>
+                <FormGroup row={true}>
+                    <FormLabel length={2} />
+                    <FormField length={10}>
                         <FormButton onClick={this.onCancel}
                                     hintKey="configuration.cancel.hint"><I18n name={'common.cancel'}/>
                         </FormButton>
-                        <FormButton onClick={this.onTest} disabled={this.state.testResult === 'fetching'} bsStyle="info"
+                        <FormButton onClick={this.onTest} disabled={this.state.testStatus === 'fetching'} bsStyle="info"
                                     hint={'Tries to connect to the repo and to get info from.'}>Test
                         </FormButton>
                         <FormButton onClick={this.onSave} bsStyle="primary"
@@ -184,10 +198,11 @@
                         </FormButton>
                     </FormField>
                 </FormGroup>
+                {testResultGroup}
                 <LoadingOverlay active={this.state.loading}/>
             </React.Fragment>;
         }
-        return <React.Fragment>{content}{testResult}{repoError}</React.Fragment>;
+        return <React.Fragment>{content}{repoError}</React.Fragment>;
     }
 }
 

--
Gitblit v1.10.0