From 6b9d24f8860e8b7330293b351d4022dc040a5450 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Thu, 9 May 2019 17:20:56 +0530 Subject: [PATCH] Create action for change lifecycle --- .../react-app/src/js/actions/index.js | 22 ++++++++++++++++++- .../react-app/src/js/constants/ActionTypes.js | 3 ++- 2 files changed, 23 insertions(+), 2 deletions(-) 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 b64296dea97..f4604d847ec 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 @@ -23,7 +23,6 @@ export const getApps = () => dispatch => { } }); - }; export const getRelease = (uuid) => dispatch => { @@ -87,3 +86,24 @@ export const getLifecycle = ()=> dispatch =>{ } }); }; + + +export const updateLifecycleState = (uuid, nextState) => dispatch => { + + const request = "method=get&content-type=application/json&payload={}&api-endpoint=/applications/lifecycle-config/"+uuid+"?action="+nextState; + + return axios.post('https://' + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invokerUri, request + ).then(res => { + if (res.status === 200) { + let release = res.data.data; + dispatch({type: ActionTypes.GET_RELEASE, payload: release}); + } + + }).catch(function (error) { + if (error.response.status === 401) { + window.location.href = 'https://localhost:9443/publisher/login'; + } + }); + + +}; 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 index cf9dd0f39f1..76ec0da9f7f 100644 --- 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 @@ -8,7 +8,8 @@ const ActionTypes = keyMirror({ GET_RELEASE: null, GET_LIFECYCLE: null, OPEN_LIFECYCLE_MODAL: null, - CLOSE_LIFECYCLE_MODAL: null + CLOSE_LIFECYCLE_MODAL: null, + UPDATE_LIFECYCLE_STATE: null, }); export default ActionTypes; \ No newline at end of file