From 31ce3fb9d09cca17d383712cbd527c5cffce4719 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Tue, 30 Apr 2019 16:54:36 +0530 Subject: [PATCH] changed action types to single object --- .../react-app/package.json | 1 + .../react-app/src/js/actions/index.js | 4 ++-- .../react-app/src/js/constants/ActionTypes.js | 16 ++++++++++++++++ .../react-app/src/js/constants/action-types.js | 3 --- .../react-app/src/js/reducers/index.js | 4 ++-- 5 files changed, 21 insertions(+), 7 deletions(-) create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/constants/ActionTypes.js delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/constants/action-types.js diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/package.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/package.json index ba015d08d1..2abcaecd71 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/package.json +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/package.json @@ -13,6 +13,7 @@ "acorn": "^6.1.1", "antd": "^3.15.0", "axios": "^0.18.0", + "keymirror": "^0.1.1", "react": "^16.8.4", "react-dom": "^16.8.4", "react-highlight-words": "^0.16.0", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js index 05da75eb70..b589331769 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js @@ -1,5 +1,5 @@ import axios from "axios"; -import {GET_APPS} from "../constants/action-types"; +import ActionTypes from "../constants/ActionTypes"; import config from "../../../public/conf/config.json"; export function getApps() { @@ -16,7 +16,7 @@ export function getApps() { apps = res.data.data.applications; } console.log(res.data); - dispatch({type: GET_APPS, payload: apps}); + dispatch({type: ActionTypes.GET_APPS, payload: apps}); } }).catch(function (error) { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/constants/ActionTypes.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/constants/ActionTypes.js new file mode 100644 index 0000000000..036e0e595f --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/constants/ActionTypes.js @@ -0,0 +1,16 @@ +import keyMirror from 'keymirror'; + +// export const LOGIN = "LOGIN"; +// export const GET_APPS = "GET_APPS"; +// export const OPEN_RELEASES_MODAL = "OPEN_RELEASES_MODAL"; +// export const CLOSE_RELEASES_MODAL = "CLOSE_RELEASES_MODAL"; + +const ActionTypes = keyMirror({ + LOGIN: null, + GET_APPS: null, + OPEN_RELEASES_MODAL: null, + CLOSE_RELEASES_MODAL: null + +}); + +export default ActionTypes; \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/constants/action-types.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/constants/action-types.js deleted file mode 100644 index e270ea0c6a..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/constants/action-types.js +++ /dev/null @@ -1,3 +0,0 @@ -export const LOGIN = "LOGIN"; -export const GET_APPS = "GET_APPS"; - diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/reducers/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/reducers/index.js index 3093402642..5dcda40c8b 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/reducers/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/reducers/index.js @@ -1,11 +1,11 @@ -import {GET_APPS} from "../constants/action-types"; +import ActionTypes from "../constants/ActionTypes"; const initialState = { apps: [] }; function rootReducer(state = initialState, action) { - if (action.type === GET_APPS) { + if (action.type === ActionTypes.GET_APPS) { console.log(11); return Object.assign({}, state, { apps: action.payload