Skip to content

Commit 339ebf2

Browse files
committed
Added error boundaries.
1 parent 82e83c4 commit 339ebf2

File tree

23 files changed

+1607
-1521
lines changed

23 files changed

+1607
-1521
lines changed

CONTRIBUTING.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# Contributing to CoreUI Free React Admin Template
1+
# Contributing to Rclone web ui
22

3-
Looking to contribute something to CoreUI Free React Admin Template? **Here's how you can help.**
3+
Looking to contribute something to Rclone web UI? **Here's how you can help.**
44

55
Please take a moment to review this document in order to make the contribution process easy and effective for everyone involved.
66

77
Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. In return, they should reciprocate that respect in addressing your issue or assessing patches and features.
88

99
## Using the issue tracker
1010

11-
The [issue tracker](https://github.com/coreui/coreui-free-react-admin-template/issues) is the preferred channel for [bug reports](#bug-reports), [features requests](#feature-requests) and [submitting pull requests](#pull-requests), but please respect the following restrictions:
11+
The [issue tracker](https://github.com/negative0/rclone-webui-react/issues) is the preferred channel for [bug reports](#bug-reports), [features requests](#feature-requests) and [submitting pull requests](#pull-requests), but please respect the following restrictions:
1212

1313
* Please **do not** use the issue tracker for personal support requests.
1414

@@ -86,9 +86,9 @@ included in the project:
8686

8787
```bash
8888
# Clone your fork of the repo into the current directory
89-
git clone https://github.com/<your-username>/free-react-admin-template.git
89+
git clone https://github.com/<your-username>/rclone-webui-react.git
9090
# Navigate to the newly cloned directory
91-
cd free-react-admin-template
91+
cd rclone-webui-react
9292
# Assign the original repo to a remote called "upstream"
9393
git remote add upstream https://github.com/coreui/coreui-free-react-admin-template.git
9494
```
@@ -162,8 +162,7 @@ Inspired by Sparkbox's awesome article on [semantic commit messages](http://sees
162162
### JS
163163

164164
- No semicolons (in client-side JS)
165-
- 2 spaces (no tabs)
166-
- strict mode
165+
- 4 spaces (no tabs)
167166
- "Attractive"
168167
- Don't use [jQuery event alias convenience methods](https://github.com/jquery/jquery/blob/master/src/event/alias.js) (such as `$().focus()`). Instead, use [`$().trigger(eventType, ...)`](http://api.jquery.com/trigger/) or [`$().on(eventType, ...)`](http://api.jquery.com/on/), depending on whether you're firing an event or listening for an event. (For example, `$().trigger('focus')` or `$().on('focus', function (event) { /* handle focus event */ })`) We do this to be compatible with custom builds of jQuery where the event aliases module has been excluded.
169168

README.md

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
[![CCExtractor](https://img.shields.io/badge/CCExtractor-org-blue.svg)](https://www.ccextractor.org/) [![RClone](https://img.shields.io/badge/RClone-org-blue.svg)](https://rclone.org/)
44

5-
65
This is a reactjs based web UI for the rclone cli project @ [Rclone Website](rclone.org)
76

87
This project can be unstable and is being actively developed. Feel free to create any issues, feature requests or enhancements as you encounter them.
@@ -13,7 +12,8 @@ This project can be unstable and is being actively developed. Feel free to creat
1312
[![Coverage Status](https://coveralls.io/repos/github/negative0/rclone-webui-react/badge.svg?branch=master)](https://coveralls.io/github/negative0/rclone-webui-react?branch=master)
1413
## Getting Started
1514

16-
The project currently requires you to install and configure react and npm to run correctly
15+
The project currently requires you to install and configure react and npm to run correctly.
16+
Read more about the project details at [good2be.me](http://good2be.me/blog)
1717

1818
## Screenshots
1919
### Dashboard
@@ -36,22 +36,43 @@ The project currently requires you to install and configure react and npm to run
3636
OR download a zip from the option above.
3737

3838
### Install dependencies
39+
If you are using NPM:
40+
41+
**Make sure that you are using the latest LTS version of NPM**
42+
```
43+
cd <cloned directory>
44+
npm install
3945
```
40-
cd <cloned directory>
41-
npm install
46+
47+
Using yarn:
48+
```
49+
cd <cloned directory>
50+
yarn install
4251
```
4352

53+
4454
### Run the project
4555
```
46-
npm start
56+
npm start
4757
```
58+
OR
59+
```
60+
npm run start
61+
```
62+
63+
### Run tests
64+
```npm test```OR ```yarn test``` if you want to run all jest tests.
65+
Test specific environment can be set using setupTests.js
66+
67+
**With Coverage**: ```npm run test:cov```
68+
4869

4970
### Run Rclone
5071
You have to run rclone with the following flags:
5172
```
5273
rclone rcd --rc-user=<username> --rc-pass=<password> --rc-serve
5374
```
54-
Replace username and password with your custom username password. This will be required to login to rclone.
75+
Replace username and password with your custom username password. This will be required to login to rclone. rc-no-auth is not available due to security concerns.
5576

5677
--rc-serve: It serves the remote objects at localhost:5572/[remoteName:remotePath]/path/to/file. It enables us to download files via the RemoteExplorer through the browser.
5778

src/App.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {HashRouter, Route, Switch} from 'react-router-dom';
44
import './App.scss';
55
import {ToastContainer} from "react-toastify";
66
import 'react-toastify/dist/ReactToastify.css';
7+
import ErrorBoundary from "./ErrorHandling/ErrorBoundary";
78

89
const loading = () => <div className="animated fadeIn pt-3 text-center">Loading...</div>;
910

@@ -21,19 +22,21 @@ class App extends Component {
2122
render() {
2223
return (
2324
<div data-test="appComponent">
24-
<ToastContainer/>
25-
<HashRouter>
26-
<React.Suspense fallback={loading()}>
27-
<Switch>
28-
<Route exact path="/login" name="Login Page" render={props => <Login {...props}/>}/>
29-
<Route exact path="/register" name="Register Page"
30-
render={props => <Register {...props}/>}/>
31-
<Route exact path="/404" name="Page 404" render={props => <Page404 {...props}/>}/>
32-
<Route exact path="/500" name="Page 500" render={props => <Page500 {...props}/>}/>
33-
<Route path="/" name="Home" render={props => <DefaultLayout {...props}/>}/>
34-
</Switch>
35-
</React.Suspense>
36-
</HashRouter>
25+
<ErrorBoundary>
26+
<ToastContainer/>
27+
<HashRouter>
28+
<React.Suspense fallback={loading()}>
29+
<Switch>
30+
<Route exact path="/login" name="Login Page" render={props => <Login {...props}/>}/>
31+
<Route exact path="/register" name="Register Page"
32+
render={props => <Register {...props}/>}/>
33+
<Route exact path="/404" name="Page 404" render={props => <Page404 {...props}/>}/>
34+
<Route exact path="/500" name="Page 500" render={props => <Page500 {...props}/>}/>
35+
<Route path="/" name="Home" render={props => <DefaultLayout {...props}/>}/>
36+
</Switch>
37+
</React.Suspense>
38+
</HashRouter>
39+
</ErrorBoundary>
3740
</div>
3841
);
3942
}

src/App.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react';
2-
import {shallow} from 'enzyme/build';
32
import App from './App';
43
import {findByTestAttr, testStore} from "../Utils";
54
import {Provider} from "react-redux";
65
import toJson from 'enzyme-to-json';
6+
import {shallow} from "enzyme";
77

88
const setUp = (initialState = {}) => {
99
const store = testStore(initialState);

src/ErrorHandling/ErrorBoundary.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import React from "react";
2+
import {Col, Container, Row} from "reactstrap";
3+
4+
class ErrorBoundary extends React.Component {
5+
constructor(props) {
6+
super(props);
7+
this.state = {hasError: false};
8+
}
9+
10+
static getDerivedStateFromError(error) {
11+
// Update state so the next render will show the fallback UI.
12+
return {hasError: true};
13+
}
14+
15+
componentDidCatch(error, info) {
16+
// You can also log the error to an error reporting service
17+
// logErrorToMyService(error, info);
18+
// Send error to Rclone backend.
19+
this.setState({error, info});
20+
21+
22+
console.log("Hey");
23+
}
24+
25+
render() {
26+
if (this.state.hasError) {
27+
// You can render any custom fallback UI
28+
return (
29+
<div className="d-flex align-items-center">
30+
<Container fluid={true}>
31+
<Row>
32+
<Col lg={3} sm={12}/>
33+
<Col lg={6} sm={12}>
34+
<h3>Something went wrong. </h3>
35+
<Row>
36+
<Col>
37+
Try refreshing the page.
38+
If the issue persists, please consider opening a new issue on our Github page.
39+
</Col>
40+
</Row>
41+
<Row>
42+
<Col>
43+
<a href="https://github.com/negative0/rclone-webui-react/issues"
44+
className="btn btn-primary">
45+
Create new Issue.
46+
</a>
47+
</Col>
48+
</Row>
49+
50+
</Col>
51+
<Col lg={3} sm={12}/>
52+
</Row>
53+
</Container>
54+
</div>
55+
);
56+
}
57+
58+
return this.props.children;
59+
}
60+
}
61+
62+
export default ErrorBoundary;

src/__snapshots__/App.test.js.snap

Lines changed: 69 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -4,73 +4,75 @@ exports[`App Component should match snapshot 1`] = `
44
<div
55
data-test="appComponent"
66
>
7-
<ToastContainer
8-
autoClose={5000}
9-
bodyClassName={null}
10-
className={null}
11-
closeButton={
12-
<CloseButton
13-
ariaLabel="close"
14-
/>
15-
}
16-
closeOnClick={true}
17-
draggable={true}
18-
draggablePercent={80}
19-
hideProgressBar={false}
20-
newestOnTop={false}
21-
pauseOnFocusLoss={true}
22-
pauseOnHover={true}
23-
position="top-right"
24-
progressClassName={null}
25-
progressStyle={null}
26-
role="alert"
27-
rtl={false}
28-
style={null}
29-
toastClassName={null}
30-
transition={[Function]}
31-
/>
32-
<HashRouter>
33-
<Suspense
34-
fallback={
35-
<div
36-
className="animated fadeIn pt-3 text-center"
37-
>
38-
Loading...
39-
</div>
40-
}
41-
>
42-
<Switch>
43-
<Route
44-
exact={true}
45-
name="Login Page"
46-
path="/login"
47-
render={[Function]}
48-
/>
49-
<Route
50-
exact={true}
51-
name="Register Page"
52-
path="/register"
53-
render={[Function]}
54-
/>
55-
<Route
56-
exact={true}
57-
name="Page 404"
58-
path="/404"
59-
render={[Function]}
7+
<ErrorBoundary>
8+
<ToastContainer
9+
autoClose={5000}
10+
bodyClassName={null}
11+
className={null}
12+
closeButton={
13+
<CloseButton
14+
ariaLabel="close"
6015
/>
61-
<Route
62-
exact={true}
63-
name="Page 500"
64-
path="/500"
65-
render={[Function]}
66-
/>
67-
<Route
68-
name="Home"
69-
path="/"
70-
render={[Function]}
71-
/>
72-
</Switch>
73-
</Suspense>
74-
</HashRouter>
16+
}
17+
closeOnClick={true}
18+
draggable={true}
19+
draggablePercent={80}
20+
hideProgressBar={false}
21+
newestOnTop={false}
22+
pauseOnFocusLoss={true}
23+
pauseOnHover={true}
24+
position="top-right"
25+
progressClassName={null}
26+
progressStyle={null}
27+
role="alert"
28+
rtl={false}
29+
style={null}
30+
toastClassName={null}
31+
transition={[Function]}
32+
/>
33+
<HashRouter>
34+
<Suspense
35+
fallback={
36+
<div
37+
className="animated fadeIn pt-3 text-center"
38+
>
39+
Loading...
40+
</div>
41+
}
42+
>
43+
<Switch>
44+
<Route
45+
exact={true}
46+
name="Login Page"
47+
path="/login"
48+
render={[Function]}
49+
/>
50+
<Route
51+
exact={true}
52+
name="Register Page"
53+
path="/register"
54+
render={[Function]}
55+
/>
56+
<Route
57+
exact={true}
58+
name="Page 404"
59+
path="/404"
60+
render={[Function]}
61+
/>
62+
<Route
63+
exact={true}
64+
name="Page 500"
65+
path="/500"
66+
render={[Function]}
67+
/>
68+
<Route
69+
name="Home"
70+
path="/"
71+
render={[Function]}
72+
/>
73+
</Switch>
74+
</Suspense>
75+
</HashRouter>
76+
</ErrorBoundary>
7577
</div>
7678
`;

0 commit comments

Comments
 (0)