mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Remove redux from APPM store
This commit is contained in:
parent
d188b18bc5
commit
ff7158bf00
@ -31,7 +31,6 @@
|
|||||||
"react-scripts": "2.1.8",
|
"react-scripts": "2.1.8",
|
||||||
"react-star-ratings": "^2.3.0",
|
"react-star-ratings": "^2.3.0",
|
||||||
"react-virtualized": "^9.21.1",
|
"react-virtualized": "^9.21.1",
|
||||||
"redux-thunk": "^2.3.0",
|
|
||||||
"reqwest": "^2.0.5",
|
"reqwest": "^2.0.5",
|
||||||
"storm-react-diagrams": "^5.2.1"
|
"storm-react-diagrams": "^5.2.1"
|
||||||
},
|
},
|
||||||
@ -66,8 +65,6 @@
|
|||||||
"react": "^15.6.2",
|
"react": "^15.6.2",
|
||||||
"react-dom": "^15.6.2",
|
"react-dom": "^15.6.2",
|
||||||
"react-intl": "^2.4.0",
|
"react-intl": "^2.4.0",
|
||||||
"react-redux": "^7.0.2",
|
|
||||||
"redux": "^4.0.1",
|
|
||||||
"sass-loader": "^6.0.7",
|
"sass-loader": "^6.0.7",
|
||||||
"style-loader": "^0.18.2",
|
"style-loader": "^0.18.2",
|
||||||
"url-loader": "^1.1.2",
|
"url-loader": "^1.1.2",
|
||||||
|
|||||||
@ -1,21 +1,13 @@
|
|||||||
import {
|
import {Card, Typography, Col, Row} from 'antd';
|
||||||
Skeleton, Switch, Card, Icon, Avatar, Typography, Col, Row, Rate
|
|
||||||
} from 'antd';
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import {openReleasesModal} from "../../js/actions";
|
|
||||||
import {connect} from "react-redux";
|
|
||||||
import {Link} from "react-router-dom";
|
import {Link} from "react-router-dom";
|
||||||
import "../../App.css";
|
import "../../App.css";
|
||||||
import StarRatings from 'react-star-ratings';
|
import StarRatings from 'react-star-ratings';
|
||||||
|
|
||||||
const {Meta} = Card;
|
const {Meta} = Card;
|
||||||
const {Text, Title} = Typography;
|
const {Text} = Typography;
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => ({
|
class AppCard extends React.Component {
|
||||||
openReleasesModal: (app) => dispatch(openReleasesModal(app))
|
|
||||||
});
|
|
||||||
|
|
||||||
class ConnectedAppCard extends React.Component {
|
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
@ -65,6 +57,4 @@ class ConnectedAppCard extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const AppCard = connect(null, mapDispatchToProps)(ConnectedAppCard);
|
|
||||||
|
|
||||||
export default AppCard;
|
export default AppCard;
|
||||||
@ -1,85 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
import {Modal, Typography,List, Avatar} from 'antd';
|
|
||||||
import {connect} from 'react-redux';
|
|
||||||
import {Link} from "react-router-dom";
|
|
||||||
|
|
||||||
// connecting state.releaseView with the component
|
|
||||||
const mapStateToProps = state => {
|
|
||||||
return {releaseView: state.releaseView}
|
|
||||||
};
|
|
||||||
|
|
||||||
const Text = Typography;
|
|
||||||
|
|
||||||
class ConnectedReleaseModal extends React.Component {
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
visible: false,
|
|
||||||
app: null
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
|
||||||
if (nextProps !== this.props) {
|
|
||||||
this.setState({
|
|
||||||
visible: nextProps.releaseView.visible,
|
|
||||||
app: nextProps.releaseView.app
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
showModal = () => {
|
|
||||||
this.setState({
|
|
||||||
visible: true,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
handleOk = (e) => {
|
|
||||||
this.setState({
|
|
||||||
visible: false,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
handleCancel = (e) => {
|
|
||||||
this.setState({
|
|
||||||
visible: false,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
|
||||||
if (this.props.releaseView.app != null) {
|
|
||||||
const app = this.props.releaseView.app;
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<Modal
|
|
||||||
title={app.name}
|
|
||||||
visible={this.state.visible}
|
|
||||||
onOk={this.handleOk}
|
|
||||||
onCancel={this.handleCancel}
|
|
||||||
>
|
|
||||||
<p>Some contents...</p>
|
|
||||||
<List
|
|
||||||
itemLayout="horizontal"
|
|
||||||
dataSource={app.applicationReleases}
|
|
||||||
renderItem={release => (
|
|
||||||
<List.Item>
|
|
||||||
<List.Item.Meta
|
|
||||||
avatar={<Avatar src={release.iconPath} />}
|
|
||||||
title={<Link to={"/store/apps/"+release.uuid}>{release.version}</Link>}
|
|
||||||
description={release.description}
|
|
||||||
/>
|
|
||||||
</List.Item>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</Modal>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const ReleaseModal = connect(mapStateToProps, null)(ConnectedReleaseModal);
|
|
||||||
|
|
||||||
export default ReleaseModal;
|
|
||||||
@ -7,9 +7,6 @@ import Dashboard from "./pages/dashboard/Dashboard";
|
|||||||
import Apps from "./pages/dashboard/apps/Apps";
|
import Apps from "./pages/dashboard/apps/Apps";
|
||||||
import Release from "./pages/dashboard/apps/release/Release";
|
import Release from "./pages/dashboard/apps/release/Release";
|
||||||
import './index.css';
|
import './index.css';
|
||||||
import store from "./js/store/index";
|
|
||||||
import {Provider} from "react-redux";
|
|
||||||
|
|
||||||
|
|
||||||
const routes = [
|
const routes = [
|
||||||
{
|
{
|
||||||
@ -38,9 +35,7 @@ const routes = [
|
|||||||
|
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<Provider store={store}>
|
<App routes={routes}/>,
|
||||||
<App routes={routes}/>
|
|
||||||
</Provider>,
|
|
||||||
document.getElementById('root'));
|
document.getElementById('root'));
|
||||||
|
|
||||||
// If you want your app to work offline and load faster, you can change
|
// If you want your app to work offline and load faster, you can change
|
||||||
|
|||||||
@ -1,168 +0,0 @@
|
|||||||
import axios from "axios";
|
|
||||||
import ActionTypes from "../constants/ActionTypes";
|
|
||||||
import config from "../../../public/conf/config.json";
|
|
||||||
|
|
||||||
export const getApps = () => dispatch => {
|
|
||||||
|
|
||||||
const request = "method=post&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/applications";
|
|
||||||
|
|
||||||
return axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
|
|
||||||
).then(res => {
|
|
||||||
if (res.status === 200) {
|
|
||||||
let apps = [];
|
|
||||||
|
|
||||||
if (res.data.data.hasOwnProperty("applications")) {
|
|
||||||
apps = res.data.data.applications;
|
|
||||||
}
|
|
||||||
dispatch({type: ActionTypes.GET_APPS, payload: apps});
|
|
||||||
}
|
|
||||||
|
|
||||||
}).catch(function (error) {
|
|
||||||
if (error.response.status === 401) {
|
|
||||||
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getRelease = (uuid) => dispatch => {
|
|
||||||
|
|
||||||
const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/applications/" + uuid;
|
|
||||||
|
|
||||||
return axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
|
|
||||||
).then(res => {
|
|
||||||
if (res.status === 200) {
|
|
||||||
let release = res.data.data.applicationReleases[0];
|
|
||||||
dispatch({
|
|
||||||
type: ActionTypes.GET_RELEASE,
|
|
||||||
payload: {
|
|
||||||
release: release,
|
|
||||||
releaseLoading: false
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}).catch(function (error) {
|
|
||||||
if (error.response.status === 401) {
|
|
||||||
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login';
|
|
||||||
}else if(error.response.status===404){
|
|
||||||
dispatch({
|
|
||||||
type: ActionTypes.GET_RELEASE,
|
|
||||||
payload: {
|
|
||||||
release: null,
|
|
||||||
releaseLoading: false
|
|
||||||
}});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
export const openReleasesModal = (app) => dispatch => {
|
|
||||||
dispatch({
|
|
||||||
type: ActionTypes.OPEN_RELEASES_MODAL,
|
|
||||||
payload: {
|
|
||||||
app: app
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
export const openLifecycleModal = (nextState) => dispatch => {
|
|
||||||
dispatch({
|
|
||||||
type: ActionTypes.OPEN_LIFECYCLE_MODAL,
|
|
||||||
payload: {
|
|
||||||
nextState: nextState
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export const closeLifecycleModal = () => dispatch => {
|
|
||||||
dispatch({
|
|
||||||
type: ActionTypes.CLOSE_LIFECYCLE_MODAL
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export const setLoading = (stateToLoad) => dispatch => {
|
|
||||||
dispatch({
|
|
||||||
type: ActionTypes.SET_LOADING_STATE,
|
|
||||||
payload: {
|
|
||||||
stateToLoad: stateToLoad
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getLifecycle = () => dispatch => {
|
|
||||||
const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/applications/lifecycle-config";
|
|
||||||
|
|
||||||
return axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
|
|
||||||
).then(res => {
|
|
||||||
if (res.status === 200) {
|
|
||||||
let lifecycle = res.data.data;
|
|
||||||
dispatch({type: ActionTypes.GET_LIFECYCLE, payload: lifecycle});
|
|
||||||
}
|
|
||||||
|
|
||||||
}).catch(function (error) {
|
|
||||||
if (error.response.status === 401) {
|
|
||||||
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export const updateLifecycleState = (uuid, nextState, reason) => dispatch => {
|
|
||||||
|
|
||||||
const payload = {
|
|
||||||
action: nextState,
|
|
||||||
reason: reason
|
|
||||||
};
|
|
||||||
|
|
||||||
const request = "method=post&content-type=application/json&payload=" + JSON.stringify(payload) + "&api-endpoint=/application-mgt-store/v1.0/applications/life-cycle/" + uuid;
|
|
||||||
|
|
||||||
|
|
||||||
return axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
|
|
||||||
).then(res => {
|
|
||||||
if (res.status === 201) {
|
|
||||||
let release = res.data.data;
|
|
||||||
dispatch({type: ActionTypes.UPDATE_LIFECYCLE_STATE, payload: release});
|
|
||||||
}else {
|
|
||||||
alert("error");
|
|
||||||
dispatch({
|
|
||||||
type: ActionTypes.CLOSE_LIFECYCLE_MODAL
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}).catch(function (error) {
|
|
||||||
if (error.response.status === 401) {
|
|
||||||
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login';
|
|
||||||
} else if (error.response.status === 500) {
|
|
||||||
alert("error");
|
|
||||||
dispatch({
|
|
||||||
type: ActionTypes.CLOSE_LIFECYCLE_MODAL
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getDetailedRating = (uuid) => dispatch => {
|
|
||||||
const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-store/v1.0/reviews/"+uuid+"/rating";
|
|
||||||
|
|
||||||
return axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
|
|
||||||
).then(res => {
|
|
||||||
if (res.status === 200) {
|
|
||||||
let detailedRating = res.data.data;
|
|
||||||
dispatch({type: ActionTypes.GET_DETAILED_RATING, payload: detailedRating});
|
|
||||||
}
|
|
||||||
|
|
||||||
}).catch(function (error) {
|
|
||||||
if (error.response.status === 401) {
|
|
||||||
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort+'/store/login';
|
|
||||||
} else{
|
|
||||||
dispatch({
|
|
||||||
type: ActionTypes.GET_DETAILED_RATING, payload: null
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
import keyMirror from 'keymirror';
|
|
||||||
|
|
||||||
const ActionTypes = keyMirror({
|
|
||||||
LOGIN: null,
|
|
||||||
GET_APPS: null,
|
|
||||||
OPEN_RELEASES_MODAL: null,
|
|
||||||
CLOSE_RELEASES_MODAL: null,
|
|
||||||
GET_RELEASE: null,
|
|
||||||
GET_LIFECYCLE: null,
|
|
||||||
OPEN_LIFECYCLE_MODAL: null,
|
|
||||||
CLOSE_LIFECYCLE_MODAL: null,
|
|
||||||
UPDATE_LIFECYCLE_STATE: null,
|
|
||||||
SET_LOADING_STATE: null,
|
|
||||||
GET_DETAILED_RATING: null
|
|
||||||
});
|
|
||||||
|
|
||||||
export default ActionTypes;
|
|
||||||
@ -1,83 +0,0 @@
|
|||||||
import ActionTypes from "../constants/ActionTypes";
|
|
||||||
|
|
||||||
const initialState = {
|
|
||||||
apps: [],
|
|
||||||
releaseView: {
|
|
||||||
visible: false,
|
|
||||||
app: null
|
|
||||||
},
|
|
||||||
release: null,
|
|
||||||
lifecycle: null,
|
|
||||||
lifecycleModal: {
|
|
||||||
visible: false,
|
|
||||||
nextState: null
|
|
||||||
},
|
|
||||||
loadingState: {
|
|
||||||
release: true
|
|
||||||
},
|
|
||||||
detailedRating: null
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
function rootReducer(state = initialState, action) {
|
|
||||||
if (action.type === ActionTypes.GET_APPS) {
|
|
||||||
return Object.assign({}, state, {
|
|
||||||
apps: action.payload
|
|
||||||
});
|
|
||||||
} else if (action.type === ActionTypes.OPEN_RELEASES_MODAL) {
|
|
||||||
return Object.assign({}, state, {
|
|
||||||
releaseView: {
|
|
||||||
visible: true,
|
|
||||||
app: action.payload.app
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (action.type === ActionTypes.GET_RELEASE) {
|
|
||||||
let loadingState = {...state.loadingState};
|
|
||||||
loadingState.release = action.payload.releaseLoading;
|
|
||||||
return Object.assign({}, state, {
|
|
||||||
release: action.payload.release,
|
|
||||||
loadingState: loadingState
|
|
||||||
});
|
|
||||||
} else if (action.type === ActionTypes.GET_LIFECYCLE) {
|
|
||||||
return Object.assign({}, state, {
|
|
||||||
lifecycle: action.payload
|
|
||||||
});
|
|
||||||
} else if (action.type === ActionTypes.OPEN_LIFECYCLE_MODAL) {
|
|
||||||
return Object.assign({}, state, {
|
|
||||||
lifecycleModal: {
|
|
||||||
visible: true,
|
|
||||||
nextState: action.payload.nextState
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (action.type === ActionTypes.CLOSE_LIFECYCLE_MODAL) {
|
|
||||||
return Object.assign({}, state, {
|
|
||||||
lifecycleModal: {
|
|
||||||
visible: false,
|
|
||||||
nextState: null
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (action.type === ActionTypes.UPDATE_LIFECYCLE_STATE) {
|
|
||||||
return Object.assign({}, state, {
|
|
||||||
lifecycleModal: {
|
|
||||||
visible: false,
|
|
||||||
nextState: null,
|
|
||||||
},
|
|
||||||
release: action.payload
|
|
||||||
});
|
|
||||||
} else if (action.type === ActionTypes.SET_LOADING_STATE) {
|
|
||||||
let loadingState = {...state.loadingState};
|
|
||||||
loadingState[action.payload.stateToLoad] = true;
|
|
||||||
return Object.assign({}, state, {
|
|
||||||
loadingState: loadingState
|
|
||||||
});
|
|
||||||
} else if (action.type === ActionTypes.GET_DETAILED_RATING) {
|
|
||||||
return Object.assign({}, state, {
|
|
||||||
detailedRating: action.payload
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export default rootReducer;
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
import { createStore, applyMiddleware } from "redux";
|
|
||||||
import rootReducer from "../reducers/index";
|
|
||||||
import thunk from "redux-thunk";
|
|
||||||
const store = createStore(rootReducer, applyMiddleware(thunk));
|
|
||||||
export default store;
|
|
||||||
Loading…
Reference in New Issue
Block a user