11import React from 'react' ;
2+ import { connect } from "react-redux" ;
23import { Card , CardBody , CardHeader , Col , Container , Form , FormGroup , Input , Label , Row } from "reactstrap" ;
34import axiosInstance from "../../utils/API/API" ;
45import ErrorBoundary from "../../ErrorHandling/ErrorBoundary" ;
56import urls from "../../utils/API/endpoint" ;
67
7-
8- function RCloneVersion ( { data, hasError} ) {
9- if ( hasError ) {
8+ function RCloneVersion ( { data} ) {
9+ if ( data . hasError ) {
1010 return ( < p > Error loading.</ p > ) ;
1111 }
12+
1213 return (
1314 < Col sm = { 12 } lg = { 4 } md = { 6 } >
1415 < Card >
1516 < CardHeader > Version</ CardHeader >
1617 < CardBody >
17- < p > < strong > Arch:</ strong > { data . arch } </ p >
18- < p > < strong > goVersion:</ strong > { data . goVersion } </ p >
19- < p > < strong > OS:</ strong > { data . os } </ p >
20- < p > < strong > Rclone version:</ strong > { data . version } </ p >
21- < p > < strong > isGit:</ strong > { data . isGit } </ p >
18+ < p > < strong > Arch: </ strong > { data . arch } </ p >
19+ < p > < strong > goVersion: </ strong > { data . goVersion } </ p >
20+ < p > < strong > OS: </ strong > { data . os } </ p >
21+ < p > < strong > Rclone version: </ strong > { data . version } </ p >
22+ < p > < strong > isGit: </ strong > { ` ${ data . isGit } ` } </ p >
2223 </ CardBody >
2324 </ Card >
2425 </ Col >
@@ -27,19 +28,6 @@ function RCloneVersion({data, hasError}) {
2728
2829
2930class RCloneDashboard extends React . Component {
30-
31- getRcloneStatus = ( ) => {
32- axiosInstance . post ( urls . getRcloneVersion ) . then ( ( res ) => {
33- this . setState ( {
34- version : res . data ,
35- hasError : false
36- } )
37- } , ( ) => {
38- this . setState ( {
39- hasError : true
40- } )
41- } )
42- } ;
4331 getMemStats = ( ) => {
4432 axiosInstance . post ( urls . getRcloneMemStats ) . then ( ( res ) => {
4533 this . setState ( {
@@ -124,14 +112,12 @@ class RCloneDashboard extends React.Component {
124112 } ;
125113
126114 componentDidMount ( ) {
127- this . getRcloneStatus ( ) ;
128115 this . getOptions ( ) ;
129116 }
130117
131118 constructor ( props , context ) {
132119 super ( props , context ) ;
133120 this . state = {
134- version : { } ,
135121 hasError : false ,
136122 memStats : { } ,
137123 options : { }
@@ -145,8 +131,7 @@ class RCloneDashboard extends React.Component {
145131 < ErrorBoundary >
146132 < Container fluid = { true } >
147133 < Row >
148- < RCloneVersion data = { this . state . version } hasError = { this . state . hasError } />
149-
134+ < RCloneVersion data = { this . props . version } />
150135 </ Row >
151136 { this . getOptionsView ( ) }
152137 </ Container >
@@ -155,8 +140,9 @@ class RCloneDashboard extends React.Component {
155140 }
156141}
157142
158- // const mapStateToProps = state => ({
159- //
160- // });
143+ const mapStateToProps = state => ( {
144+ version : state . version ,
145+ } ) ;
146+
147+ export default connect ( mapStateToProps ) ( RCloneDashboard ) ;
161148
162- export default RCloneDashboard ;
0 commit comments