Remove redux from release in APPM Store See merge request entgra/carbon-device-mgt!132merge-requests/136/head
commit
f92e208720
@ -1,60 +0,0 @@
|
||||
import {
|
||||
Skeleton, Switch, Card, Icon, Avatar, Typography
|
||||
} from 'antd';
|
||||
import React from "react";
|
||||
import config from "../../../public/conf/config.json";
|
||||
import {openReleasesModal} from "../../js/actions";
|
||||
import {connect} from "react-redux";
|
||||
|
||||
const { Meta } = Card;
|
||||
const { Text } = Typography;
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
openReleasesModal: (app) => dispatch(openReleasesModal(app))
|
||||
});
|
||||
|
||||
class ConnectedAppCard extends React.Component {
|
||||
|
||||
constructor(props){
|
||||
super(props);
|
||||
this.handleReleasesClick = this.handleReleasesClick.bind(this);
|
||||
}
|
||||
|
||||
handleReleasesClick(){
|
||||
this.props.openReleasesModal(this.props.app);
|
||||
}
|
||||
|
||||
|
||||
render() {
|
||||
const defaultPlatformIcons = config.defaultPlatformIcons;
|
||||
let icon = defaultPlatformIcons.default;
|
||||
if(defaultPlatformIcons.hasOwnProperty(this.props.platform)){
|
||||
icon = defaultPlatformIcons[this.props.platform];
|
||||
}
|
||||
let descriptionText = this.props.description;
|
||||
if(descriptionText.length>50){
|
||||
descriptionText = descriptionText.substring(0,50)+"...";
|
||||
}
|
||||
const description = (
|
||||
<div>
|
||||
<p>{descriptionText}</p>
|
||||
<Text code>{this.props.type}</Text>
|
||||
<Text> {this.props.subType}</Text>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<Card style={{marginTop: 16 }} actions={[<Icon type="edit" />, <Icon type="delete" />, <Icon type="appstore" theme="twoTone" onClick={this.handleReleasesClick} />]}>
|
||||
<Meta
|
||||
avatar={<Avatar src={icon} />}
|
||||
title={this.props.name}
|
||||
description={description}
|
||||
/>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const AppCard = connect(null,mapDispatchToProps)(ConnectedAppCard);
|
||||
|
||||
export default AppCard;
|
@ -1,42 +0,0 @@
|
||||
import React from "react";
|
||||
import AppCard from "./AppCard";
|
||||
import {Col, Row} from "antd";
|
||||
import {connect} from "react-redux";
|
||||
import {getApps} from "../../js/actions";
|
||||
|
||||
// connecting state.apps with the component
|
||||
const mapStateToProps= state => {
|
||||
return {apps : state.apps}
|
||||
};
|
||||
|
||||
|
||||
class ConnectedAppList extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
componentDidMount() {
|
||||
this.props.getApps();
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Row gutter={16}>
|
||||
{this.props.apps.map(app => (
|
||||
<Col key={app.id} xs={24} sm={12} md={6} lg={6}>
|
||||
<AppCard key={app.id}
|
||||
app = {app}
|
||||
name={app.name}
|
||||
platform={app.deviceType}
|
||||
type={app.type}
|
||||
subType={app.subType}
|
||||
description={app.description}/>
|
||||
</Col>
|
||||
))}
|
||||
</Row>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const AppList = connect(mapStateToProps,{getApps})(ConnectedAppList);
|
||||
|
||||
export default AppList;
|
@ -1,60 +0,0 @@
|
||||
import React from "react";
|
||||
import "antd/dist/antd.css";
|
||||
import {PageHeader, Typography,Input, Button, Row, Col} from "antd";
|
||||
import AppList from "../../../components/apps/AppList";
|
||||
import ReleaseModal from "../../../components/apps/ReleaseModal";
|
||||
|
||||
const Search = Input.Search;
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: 'index',
|
||||
breadcrumbName: 'Publisher',
|
||||
},
|
||||
{
|
||||
path: 'first',
|
||||
breadcrumbName: 'Dashboard',
|
||||
},
|
||||
{
|
||||
path: 'second',
|
||||
breadcrumbName: 'Apps',
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
class Apps extends React.Component {
|
||||
routes;
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.routes = props.routes;
|
||||
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<PageHeader
|
||||
breadcrumb={{routes}}
|
||||
/>
|
||||
<div style={{background: '#f0f2f5', padding: 24, minHeight: 780}}>
|
||||
<Row style={{padding:10}}>
|
||||
<Col span={6} offset={18}>
|
||||
<Search
|
||||
placeholder="search"
|
||||
onSearch={value => console.log(value)}
|
||||
style={{ width: 200}}
|
||||
/>
|
||||
<Button style={{margin:5}}>Advanced Search</Button>
|
||||
</Col>
|
||||
</Row>
|
||||
<ReleaseModal/>
|
||||
<AppList/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Apps;
|
@ -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;
|
@ -0,0 +1,225 @@
|
||||
import React from "react";
|
||||
import axios from "axios";
|
||||
import config from "../../../../../public/conf/config.json";
|
||||
import {Button, message, Table, Typography} from "antd";
|
||||
import TimeAgo from 'javascript-time-ago'
|
||||
|
||||
// Load locale-specific relative date/time formatting rules.
|
||||
import en from 'javascript-time-ago/locale/en'
|
||||
const {Text} = Typography;
|
||||
const columns = [
|
||||
{
|
||||
title: 'Device',
|
||||
dataIndex: 'name',
|
||||
fixed: 'left',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
title: 'Modal',
|
||||
dataIndex: 'deviceInfo',
|
||||
key:'modal',
|
||||
render: deviceInfo => `${deviceInfo.vendor} ${deviceInfo.deviceModel}`
|
||||
// todo add filtering options
|
||||
},
|
||||
{
|
||||
title: 'Owner',
|
||||
dataIndex: 'enrolmentInfo',
|
||||
key: 'owner',
|
||||
render: enrolmentInfo => enrolmentInfo.owner
|
||||
// todo add filtering options
|
||||
},
|
||||
{
|
||||
title: 'Last Updated',
|
||||
dataIndex: 'enrolmentInfo',
|
||||
key: 'dateOfLastUpdate',
|
||||
render: (data) => {
|
||||
return (getTimeAgo(data.dateOfLastUpdate));
|
||||
}
|
||||
// todo add filtering options
|
||||
},
|
||||
{
|
||||
title: 'Status',
|
||||
dataIndex: 'enrolmentInfo',
|
||||
key: 'status',
|
||||
render: enrolmentInfo => enrolmentInfo.status
|
||||
// todo add filtering options
|
||||
},
|
||||
{
|
||||
title: 'Ownership',
|
||||
dataIndex: 'enrolmentInfo',
|
||||
key: 'ownership',
|
||||
render: enrolmentInfo => enrolmentInfo.ownership
|
||||
// todo add filtering options
|
||||
},
|
||||
{
|
||||
title: 'OS Version',
|
||||
dataIndex: 'deviceInfo',
|
||||
key:'osVersion',
|
||||
render: deviceInfo => deviceInfo.osVersion
|
||||
// todo add filtering options
|
||||
},
|
||||
{
|
||||
title: 'IMEI',
|
||||
dataIndex: 'properties',
|
||||
key:'imei',
|
||||
render: properties => {
|
||||
let imei = "not-found";
|
||||
for (let i = 0; i < properties.length; i++) {
|
||||
if(properties[i].name==="IMEI"){
|
||||
imei = properties[i].value;
|
||||
}
|
||||
}
|
||||
return imei;
|
||||
}
|
||||
// todo add filtering options
|
||||
},
|
||||
];
|
||||
|
||||
const getTimeAgo = (time) => {
|
||||
const timeAgo = new TimeAgo('en-US');
|
||||
return timeAgo.format(time);
|
||||
};
|
||||
|
||||
|
||||
class DeviceInstall extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
TimeAgo.addLocale(en);
|
||||
this.state = {
|
||||
data: [],
|
||||
pagination: {},
|
||||
loading: false,
|
||||
selectedRows:[]
|
||||
};
|
||||
}
|
||||
|
||||
rowSelection = {
|
||||
onChange: (selectedRowKeys, selectedRows) => {
|
||||
console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
|
||||
this.setState({
|
||||
selectedRows: selectedRows
|
||||
})
|
||||
},
|
||||
getCheckboxProps: record => ({
|
||||
disabled: record.name === 'Disabled User', // Column configuration not to be checked
|
||||
name: record.name,
|
||||
}),
|
||||
};
|
||||
|
||||
componentDidMount() {
|
||||
this.fetch();
|
||||
}
|
||||
|
||||
//fetch data from api
|
||||
fetch = (params = {}) => {
|
||||
this.setState({loading: true});
|
||||
|
||||
// get current page
|
||||
const currentPage = (params.hasOwnProperty("page")) ? params.page : 1;
|
||||
|
||||
const extraParams = {
|
||||
offset: 10 * (currentPage - 1), //calculate the offset
|
||||
limit: 10,
|
||||
status: "INACTIVE",
|
||||
requireDeviceInfo: true
|
||||
};
|
||||
|
||||
// note: encode with '%26' not '&'
|
||||
const encodedExtraParams = Object.keys(extraParams).map(key => key + '=' + extraParams[key]).join('%26');
|
||||
|
||||
const parameters = {
|
||||
method: "get",
|
||||
'content-type': "application/json",
|
||||
payload: "{}",
|
||||
'api-endpoint': "/device-mgt/v1.0/devices?" + encodedExtraParams
|
||||
};
|
||||
|
||||
//url-encode parameters
|
||||
const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&');
|
||||
|
||||
//send request to the invoker
|
||||
axios.post(config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request
|
||||
).then(res => {
|
||||
if (res.status === 200) {
|
||||
const pagination = {...this.state.pagination};
|
||||
console.log(res.data.data.devices);
|
||||
this.setState({
|
||||
loading: false,
|
||||
data: res.data.data.devices,
|
||||
pagination,
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}).catch((error) => {
|
||||
if (error.hasOwnProperty("status") && error.response.status === 401) {
|
||||
//todo display a popop with error
|
||||
message.error('You are not logged in');
|
||||
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/store/login';
|
||||
} else {
|
||||
message.error('Something went wrong... :(');
|
||||
}
|
||||
|
||||
this.setState({loading: false});
|
||||
});
|
||||
};
|
||||
|
||||
handleTableChange = (pagination, filters, sorter) => {
|
||||
const pager = {...this.state.pagination};
|
||||
pager.current = pagination.current;
|
||||
this.setState({
|
||||
pagination: pager,
|
||||
});
|
||||
this.fetch({
|
||||
results: pagination.pageSize,
|
||||
page: pagination.current,
|
||||
sortField: sorter.field,
|
||||
sortOrder: sorter.order,
|
||||
...filters,
|
||||
});
|
||||
};
|
||||
|
||||
install = () => {
|
||||
const {selectedRows} = this.state;
|
||||
const payload = [];
|
||||
selectedRows.map(device => {
|
||||
payload.push({
|
||||
deviceIdentifier: device.deviceIdentifier,
|
||||
type: device.type
|
||||
});
|
||||
});
|
||||
this.props.onInstall("device", payload);
|
||||
};
|
||||
|
||||
|
||||
render() {
|
||||
const {data,pagination,loading,selectedRows} = this.state;
|
||||
return (
|
||||
<div>
|
||||
<Text>Start installing the application for one or more users by entering the corresponding user name. Select install to automatically start downloading the application for the respective user/users. </Text>
|
||||
<Table
|
||||
style={{paddingTop:20}}
|
||||
columns={columns}
|
||||
rowKey={record => record.deviceIdentifier}
|
||||
dataSource={data}
|
||||
pagination={{
|
||||
...pagination,
|
||||
size: "small",
|
||||
// position: "top",
|
||||
showTotal: (total, range) => `showing ${range[0]}-${range[1]} of ${total} devices`
|
||||
// showQuickJumper: true
|
||||
}}
|
||||
loading={loading}
|
||||
onChange={this.handleTableChange}
|
||||
rowSelection={this.rowSelection}
|
||||
scroll={{x: 1000}}
|
||||
/>
|
||||
<div style={{paddingTop: 10, textAlign: "right"}}>
|
||||
<Button disabled={selectedRows.length===0} htmlType="button" type="primary" onClick={this.install}>Install</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default DeviceInstall;
|
@ -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