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

Kai Reinhard
12.15.2019 949b656b3d87a461feef2e7eb99d93596ab5e6f3
Redirect after save / remove...
3 files modified
57 ■■■■■ changed files
borgbutler-webapp/src/components/views/repos/ConfigureRepoPage.jsx 35 ●●●● patch | view | raw | blame | history
borgbutler-webapp/src/components/views/repos/RepoArchiveListView.jsx 13 ●●●●● patch | view | raw | blame | history
borgbutler-webapp/src/components/views/repos/RepoConfigPanel.jsx 9 ●●●● patch | view | raw | blame | history
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>;
    }
}
borgbutler-webapp/src/components/views/repos/RepoArchiveListView.jsx
@@ -75,6 +75,11 @@
        }
    }
    afterRemove() {
        this.props.history.push('/repos');
    }
    render = () => {
        let errorBadge = '';
        let content1 = undefined;
@@ -185,6 +190,8 @@
                    })}
                    </tbody>
                </Table>;
            } else {
                content1 = 'No archives available.';
            }
            content2 = <Table striped bordered hover>
                <tbody>
@@ -243,7 +250,10 @@
                    {content2}
                </TabPane>
                <TabPane tabId={'3'}>
                    <RepoConfigPanel id={this.state.id} afterCancel={this.afterCancel} afterSave={this.afterSave}
                    <RepoConfigPanel id={this.state.id}
                                     afterCancel={this.afterCancel}
                                     afterSave={this.afterSave}
                                     afterRemove={this.afterRemove}
                                     repoError={this.state.failed}/>
                </TabPane>
            </TabContent>
@@ -257,6 +267,7 @@
        this.toggleTab = this.toggleTab.bind(this);
        this.afterCancel = this.afterCancel.bind(this);
        this.afterSave = this.afterSave.bind(this);
        this.afterRemove = this.afterRemove.bind(this);
    }
}
borgbutler-webapp/src/components/views/repos/RepoConfigPanel.jsx
@@ -78,7 +78,7 @@
        })
    }
    onRemove(event) {
    async onRemove(event) {
        const response = fetch(getRestServiceUrl('repoConfig/remove', {
            id: this.props.id
        }), {
@@ -89,10 +89,17 @@
        })
            .then(response => response.text())
            .then(text => {
                if (text !== 'OK') {
                    console.log('Error while removing repo: ' + text);
                }
            })
            .catch((error) => {
                console.log("error", error);
            })
        if (response) await response;
        if (this.props.afterRemove) {
            this.props.afterRemove();
        }
    }
    async onSave(event) {