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

Kai Reinhard
12.15.2019 949b656b3d87a461feef2e7eb99d93596ab5e6f3
borgbutler-webapp/src/components/views/repos/ConfigureRepoPage.jsx
@@ -34,13 +34,23 @@
    }
    onSave(event) {
        const response = fetch(getRestServiceUrl("repoConfig"), {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json'
            },
            body: JSON.stringify(this.state.repoConfig)
        });
        this.setState(
            {repoConfig: {...this.state.repoConfig, id: this.state.mode == 'initNewRepo' ? 'init' : 'new'}},
            () => {
                const response = fetch(getRestServiceUrl("repoConfig"), {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json'
                    },
                    body: JSON.stringify(this.state.repoConfig)
                })
                    .then(json => {
                        this.props.history.push('/repos');
                    })
                    .catch(() => {
                    });
            }
        )
    }
    handleRepoConfigChange = event => {
@@ -63,6 +73,7 @@
    render() {
        const repoConfig = this.state.repoConfig;
        const saveButtonLabel = this.state.mode === 'initNewRepo' ? 'Init and save' : <I18n name={'common.save'}/>;
        return <React.Fragment>
            <PageHeader>
                Configure repository
@@ -128,20 +139,12 @@
                        <FormButton onClick={this.onSave} bsStyle="primary"
                                    disabled={repoConfig.repo && repoConfig.repo.length > 0
                                    && repoConfig.displayName && repoConfig.displayName.length > 0 ? false : true}
                                    hintKey="configuration.save.hint"><I18n name={'common.save'}/>
                                    hintKey="configuration.save.hint">{saveButtonLabel}
                        </FormButton>
                    </FormField>
                </FormGroup>
                <RepoConfigTestPanel repoConfig={this.state.repoConfig}/>
            </form>
            <code>
                <h2>Todo:</h2>
                <ul>
                    <li>Implement 'Save' button ;-)</li>
                    <li>Add own environment variables.</li>
                    <li>Remove and clone repo.</li>
                </ul>
            </code>
        </React.Fragment>;
    }
}