10000 plugins: Added plugin dashboard · corner4world/rclone-webui-react@91174f0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 91174f0

Browse files
committed
plugins: Added plugin dashboard
1 parent 7702ddf commit 91174f0

File tree

7 files changed

+89
-3
lines changed

7 files changed

+89
-3
lines changed

src/_nav.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ export default {
2020
url: '/rcloneBackend',
2121
icon: 'icon-star',
2222
},
23+
{
24+
name: 'Plugins',
25+
url: '/pluginsDashboard',
26+
icon: 'icon-plugins'
27+
},
2328
{
2429
name: 'Mounts',
2530
url: '/mountDashboard',
@@ -30,6 +35,5 @@ export default {
3035
url: '/login',
3136
icon: 'icon-logout',
3237
},
33-
3438
],
3539
};

src/actions/pluginActions.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import axiosInstance from "../utils/API/API";
22
import urls from "../utils/API/endpoint";
3-
import {GET_TEST_PLUGINS, REQUEST_ERROR, REQUEST_SUCCESS} from "./types";
3+
import {ADD_TEST_PLUGIN, GET_TEST_PLUGINS, REQUEST_ERROR, REQUEST_SUCCESS} from "./types";
44

55
/**
66
* Load test plugins
@@ -24,3 +24,15 @@ export const loadTestPlugins = () => {
2424
});
2525
}
2626
};
27+
28+
export const addTestPlugin = (pluginName, pluginUrl) => (dispatch) => {
29+
axiosInstance.post(urls.addTestPlugin, {name: pluginName, loadUrl: pluginUrl, test: true}).then(res => {
30+
dispatch(loadTestPlugins());
31+
}, (error) => {
32+
dispatch({
33+
type: ADD_TEST_PLUGIN,
34+
status: REQUEST_ERROR,
35+
payload: error
36+
})
37+
})
38+
}

src/actions/types.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ export const GET_MOUNT_LIST = "GET_MOUNT_LIST";
4242
export const REMOVE_MOUNT = "REMOVE_MOUNT";
4343
export const CREATE_MOUNT = "CREATE_MOUNT";
4444

45+
export const ADD_TEST_PLUGIN = "ADD_TEST_PLUGIN";
46+
4547
export const REQUEST_ERROR = 'ERROR';
4648
export const REQUEST_SUCCESS = 'SUCCESS';
4749
export const REQUEST_LOADING = 'LOADING';

src/reducers/pluginsReducer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {GET_TEST_PLUGINS, REQUEST_ERROR, REQUEST_SUCCESS} from "../actions/types";
1+
import {ADD_TEST_PLUGIN, GET_TEST_PLUGINS, REQUEST_ERROR, REQUEST_SUCCESS} from "../actions/types";
22

33
const initialState = {
44
loadedTestPlugins: {},
@@ -27,6 +27,8 @@ export default function (state = initialState, action) {
2727
}
2828
}
2929
break;
30+
case ADD_TEST_PLUGIN:
31+
return state;
3032
default:
3133
return state;
3234
}

src/utils/API/endpoint.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,15 @@ const urls = {
138138
*/
139139
unmountAll: "mount/unmountall",
140140

141+
/**
142+
* List the loaded test plugins
143+
*/
141144
listTestPlugins: "pluginsctl/listTestPlugins",
142145

146+
/**
147+
* Add a test plugin
148+
*/
149+
addTestPlugin: "pluginsctl/addTestPlugin",
150+
143151
};
144152
export default urls;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react';
2+
import {connect} from "react-redux";
3+
4+
class PluginsDashboard extends React.Component {
5+
render() {
6+
return (
7+
<div data-test="pluginsDashboardComponent">
8+
9+
10+
</div>);
11+
}
12+
}
13+
14+
const mapStateToProps = state => ({});
15+
16+
PluginsDashboard.propTypes = {};
17+
18+
export default connect(mapStateToProps, {})(PluginsDashboard);
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import React from "react";
2+
import {shallow} from "enzyme";
3+
import {findByTestAttr, testStore} from "../../../Utils";
4+
import toJson from "enzyme-to-json";
5+
import PluginsDashboard from "./PluginsDashboard";
6+
7+
const setUp = (intialState = {}, props = {}) => {
8+
const store = testStore(intialState);
9+
10+
const component = shallow(<PluginsDashboard {...props} store={store}/>);
11+
return component.childAt(0).dive();
12+
};
13+
14+
15+
describe('Plugins Dashboard', () => {
16+
}, function () {
17+
describe('renders', function () {
18+
let wrapper;
19+
beforeEach(() => {
20+
const initialState = {
21+
status: {
22+
checkStatus: true
23+
}
24+
};
25+
26+
const props = {};
27+
wrapper = setUp(initialState, props)
28+
});
29+
30+
it('should render without crashing', function () {
31+
const component = findByTestAttr(wrapper, "pluginsDashboardComponent");
32+
expect(component).toHaveLength(1);
33+
});
34+
35+
it('should match snapshot', function () {
36+
expect(toJson(wrapper)).toMatchSnapshot()
37+
});
38+
});
39+
40+
});

0 commit comments

Comments
 (0)
0