Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0f36c48

Browse files
committed
feat(defaultlayout): dispatch getVersion action for sidebar. remove action from dashboard view
1 parent 7ba559d commit 0f36c48

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

src/containers/DefaultLayout/DefaultLayout.js

+24-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, {Component, Suspense} from 'react';
22
import {Redirect, Route, Switch} from 'react-router-dom';
33
import {Container} from 'reactstrap';
4+
import {getVersion} from "../../actions/versionActions";
45

56
import {
67
AppAside,
@@ -26,14 +27,34 @@ const DefaultAside = React.lazy(() => import('./DefaultAside'));
2627
const DefaultFooter = React.lazy(() => import('./DefaultFooter'));
2728
const DefaultHeader = React.lazy(() => import('./DefaultHeader'));
2829

30+
const VERSION_NAV_ITEM_ATTRS = {
31+
attributes: { target: '_blank' },
32+
class: 'mt-auto',
33+
icon: 'cui-cog',
34+
url: 'https://rclone.org/changelog',
35+
variant: 'success'
36+
}
2937
class DefaultLayout extends Component {
3038

3139
loading = () => <div className="animated fadeIn pt-1 text-center">Loading...</div>;
3240

41+
get navConfig() {
42+
return {
43+
items: [
44+
...navigation.items,
45+
{
46+
name: this.props.version.version,
47+
...VERSION_NAV_ITEM_ATTRS
48+
}
49+
]
50+
}
51+
}
3352

3453
componentWillMount() {
3554
if (!localStorage.getItem(AUTH_KEY)) {
3655
this.props.history.push('/login');
56+
} else {
57+
this.props.getVersion();
3758
}
3859
}
3960

@@ -54,7 +75,7 @@ class DefaultLayout extends Component {
5475
<AppSidebarHeader/>
5576
<AppSidebarForm/>
5677
<Suspense fallback={this.loading()}>
57-
<AppSidebarNav navConfig={navigation} {...this.props} />
78+
<AppSidebarNav navConfig={this.navConfig} />
5879
</Suspense>
5980
<AppSidebarFooter/>
6081
<AppSidebarMinimizer/>
@@ -102,6 +123,7 @@ class DefaultLayout extends Component {
102123

103124
const mapStateToProps = (state) => ({
104125
isConnected: state.status.isConnected,
126+
version: state.version,
105127
});
106128

107-
export default connect(mapStateToProps, {})(DefaultLayout);
129+
export default connect(mapStateToProps, { getVersion })(DefaultLayout);

src/views/RCloneDashboard/RCloneDashboard.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {Card, CardBody, CardHeader, Col, Container, Form, FormGroup, Input, Labe
44
import axiosInstance from "../../utils/API/API";
55
import ErrorBoundary from "../../ErrorHandling/ErrorBoundary";
66
import urls from "../../utils/API/endpoint";
7-
import {getVersion} from "../../actions/versionActions";
87

98
function RCloneVersion({data}) {
109
if (data.hasError) {
@@ -113,7 +112,6 @@ class RCloneDashboard extends React.Component {
113112
};
114113

115114
componentDidMount() {
116-
this.props.getVersion();
117115
this.getOptions();
118116
}
119117

@@ -146,5 +144,5 @@ const mapStateToProps = state => ({
146144
version: state.version,
147145
});
148146

149-
export default connect(mapStateToProps, { getVersion })(RCloneDashboard);
147+
export default connect(mapStateToProps)(RCloneDashboard);
150148

0 commit comments

Comments
 (0)