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

Kai Reinhard
09.43.2018 1a21e0d3baca3870611a1fe712027a559d9a4b93
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import React from 'react';
import createBrowserHistory from 'history/createBrowserHistory';
import {Route, Router, Switch} from 'react-router';
import {connect} from 'react-redux';
import {Badge} from 'reactstrap';
 
import Menu from '../components/general/Menu';
import Start from '../components/views/Start';
import ConfigurationPage from '../components/views/config/ConfigurationPage';
import RestServices from '../components/views/develop/RestServices';
import {isDevelopmentMode} from '../utilities/global';
import LogPage from '../components/views/logging/LogPage';
import Footer from '../components/views/footer/Footer';
import {loadVersion} from '../actions';
import {getTranslation} from '../utilities/i18n';
import I18n from "../components/general/translation/I18n";
 
class WebApp extends React.Component {
 
    history = createBrowserHistory();
 
    componentDidMount = () => {
        this.props.loadVersion();
    };
 
    render() {
        let routes = [
            ['Start', '/', Start],
            [getTranslation('logviewer'), '/logging', LogPage],
            [getTranslation('configuration'), '/config', ConfigurationPage]
        ];
 
        if (this.props.version.updateVersion) {
            routes.push([getTranslation('update'), '/update', UpdatePage, {
                badge: <Badge color={'danger'}><I18n name={'common.new'}/></Badge>,
                className: 'danger'
            }]);
        }
 
        if (isDevelopmentMode()) {
            routes.push(['Rest services', '/restServices', RestServices]);
        }
 
        return (
            <Router history={this.history}>
                <div>
                    <Menu routes={routes}/>
                    <div className={'container main-view'}>
                        <Switch>
                            {
                                routes.map((route, index) => (
                                    <Route
                                        key={index}
                                        path={route[1]}
                                        component={route[2]}
                                        exact
                                    />
                                ))
                            }
                        </Switch>
                    </div>
                    <Footer versionInfo={this.props.version}/>
                </div>
            </Router>
        );
    }
}
 
const mapStateToProps = state => ({
    version: state.version
});
 
const actions = {
    loadVersion
};
 
export default connect(mapStateToProps, actions)(WebApp);