mirror of https://github.com/micromata/borgbackup-butler.git

Kai Reinhard
10.56.2019 5738ff7b9edc03495d3c5da04a31aa3b64650f59
Test button...
1 files modified
29 ■■■■ changed files
borgbutler-webapp/src/components/views/repos/RepoConfigPanel.jsx 29 ●●●● patch | view | raw | blame | history
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>;
    }
}