From f3a4abb1903a752039474e6195c865482a7e4336 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Thu, 27 Jun 2019 21:59:14 +0530 Subject: [PATCH 1/2] Change invoker uri and remove headers --- .../react-app/public/conf/config.json | 2 +- .../apps/detailed-rating/DetailedRating.js | 8 ++------ .../src/components/apps/list-apps/AppsTable.js | 4 +--- .../components/apps/release/review/Reviews.js | 2 +- .../manage/categories/ManageCategories.js | 16 ++++------------ .../components/manage/categories/ManageTags.js | 12 +++--------- .../react-app/public/conf/config.json | 4 ++-- .../react-app/src/components/apps/AppList.js | 4 +--- .../components/apps/release/DetailedRating.js | 4 +--- .../apps/release/install/DeviceInstall.js | 4 +--- .../apps/release/install/GroupInstall.js | 4 +--- .../apps/release/install/RoleInstall.js | 4 +--- .../apps/release/install/UserInstall.js | 4 +--- .../components/apps/release/review/AddReview.js | 4 +--- .../src/pages/dashboard/apps/release/Release.js | 4 +--- 15 files changed, 22 insertions(+), 58 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/conf/config.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/conf/config.json index cbcb56cb63..0ea6c3218c 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/conf/config.json +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/conf/config.json @@ -8,7 +8,7 @@ "hostname": "localhost", "httpsPort": "9443", "invoker": { - "uri": "/ui-request-handler/invoke", + "uri": "/publisher-ui-request-handler/invoke", "publisher": "/application-mgt-publisher/v1.0", "store": "/application-mgt-store/v1.0", "admin" : "" diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/detailed-rating/DetailedRating.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/detailed-rating/DetailedRating.js index 9742266cf3..d7a4056c30 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/detailed-rating/DetailedRating.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/detailed-rating/DetailedRating.js @@ -30,13 +30,9 @@ class DetailedRating extends React.Component{ } getData = (type, uuid)=>{ - console.log(); - return axios.get( - config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.store+"/reviews/"+uuid+"/"+type+"-rating", - { - headers: { 'X-Platform': config.serverConfig.platform } - }).then(res => { + config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher+"/admin/reviews/"+uuid+"/"+type+"-rating", + ).then(res => { if (res.status === 200) { let detailedRating = res.data.data; this.setState({ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppsTable.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppsTable.js index ce8145c454..56d5b5a70d 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppsTable.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/list-apps/AppsTable.js @@ -108,9 +108,7 @@ class AppsTable extends React.Component { axios.post( config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher+"/applications", data, - { - headers: { 'X-Platform': config.serverConfig.platform } - } + ).then(res => { if (res.status === 200) { let apps = []; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/review/Reviews.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/review/Reviews.js index bc3726ba01..743be28680 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/review/Reviews.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/review/Reviews.js @@ -31,7 +31,7 @@ class Reviews extends React.Component { const {uuid, type} = this.props; axios.get( - config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.store+"/reviews/"+type+"/"+uuid, + config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher+"/admin/reviews/"+type+"/"+uuid, { headers: {'X-Platform': config.serverConfig.platform} }).then(res => { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/manage/categories/ManageCategories.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/manage/categories/ManageCategories.js index 072ad720c5..7b6fe35f75 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/manage/categories/ManageCategories.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/manage/categories/ManageCategories.js @@ -22,9 +22,7 @@ class ManageCategories extends React.Component { componentDidMount() { axios.get( config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher+"/applications/categories", - { - headers: { 'X-Platform': config.serverConfig.platform } - }).then(res => { + ).then(res => { if (res.status === 200) { let categories = JSON.parse(res.data.data); this.setState({ @@ -59,9 +57,7 @@ class ManageCategories extends React.Component { }); axios.delete( config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher+"/admin/applications/categories/"+id, - { - headers: { 'X-Platform': config.serverConfig.platform } - } + ).then(res => { if (res.status === 200) { notification["success"]({ @@ -202,9 +198,7 @@ class ManageCategories extends React.Component { axios.post( config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher+"/admin/applications/categories", data, - { - headers: { 'X-Platform': config.serverConfig.platform } - } + ).then(res => { if (res.status === 200) { notification["success"]({ @@ -267,9 +261,7 @@ class ManageCategories extends React.Component { axios.put( config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher+"/admin/applications/categories/rename?from="+currentlyEditingId+"&to="+editingValue, {}, - { - headers: { 'X-Platform': config.serverConfig.platform } - } + ).then(res => { if (res.status === 200) { notification["success"]({ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/manage/categories/ManageTags.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/manage/categories/ManageTags.js index c525152707..a815bdb78d 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/manage/categories/ManageTags.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/manage/categories/ManageTags.js @@ -22,9 +22,7 @@ class ManageTags extends React.Component { componentDidMount() { axios.get( config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher+"/applications/tags", - { - headers: { 'X-Platform': config.serverConfig.platform } - }).then(res => { + ).then(res => { if (res.status === 200) { let tags = JSON.parse(res.data.data); this.setState({ @@ -202,9 +200,7 @@ class ManageTags extends React.Component { axios.post(config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher+"/applications/tags", data, - { - headers: { 'X-Platform': config.serverConfig.platform } - }).then(res => { + ).then(res => { if (res.status === 200) { notification["success"]({ message: "Done!", @@ -266,9 +262,7 @@ class ManageTags extends React.Component { axios.put( config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.publisher+"/applications/tags/rename?from="+currentlyEditingId+"&to="+editingValue, {}, - { - headers: { 'X-Platform': config.serverConfig.platform } - } + ).then(res => { if (res.status === 200) { notification["success"]({ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/conf/config.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/conf/config.json index 87f1691530..b9c5fe6266 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/conf/config.json +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/conf/config.json @@ -9,13 +9,13 @@ "httpsPort": "9443", "invokerUri": "/ui-request-handler/invoke/application-mgt-store/v1.0", "invoker": { - "uri": "/ui-request-handler/invoke", + "uri": "/store-ui-request-handler/invoke", "publisher": "/application-mgt-publisher/v1.0", "store": "/application-mgt-store/v1.0", "admin" : "", "deviceMgt" : "/device-mgt/v1.0" }, - "loginUri": "/ui-request-handler/login", + "loginUri": "/store-ui-request-handler/login", "platform": "store" }, "defaultPlatformIcons": { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/AppList.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/AppList.js index 5bfbea3572..7087e49ab1 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/AppList.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/AppList.js @@ -43,9 +43,7 @@ class AppList extends React.Component { axios.post( config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.store+"/applications/", payload, - { - headers: { 'X-Platform': config.serverConfig.platform } - } + ).then(res => { if (res.status === 200) { //todo remove this property check after backend improvement diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/DetailedRating.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/DetailedRating.js index 6b054fbf34..90fc93b5cf 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/DetailedRating.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/DetailedRating.js @@ -33,9 +33,7 @@ class DetailedRating extends React.Component{ return axios.get( config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.store+"/reviews/"+uuid+"/"+type+"-rating", - { - headers: { 'X-Platform': config.serverConfig.platform } - }).then(res => { + ).then(res => { if (res.status === 200) { let detailedRating = res.data.data; this.setState({ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js index d89eba8f1c..54eb95b5b5 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js @@ -140,9 +140,7 @@ class DeviceInstall extends React.Component { //send request to the invoker axios.get( config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"devices?" + encodedExtraParams, - { - headers: { 'X-Platform': config.serverConfig.platform } - } + ).then(res => { if (res.status === 200) { const pagination = {...this.state.pagination}; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/GroupInstall.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/GroupInstall.js index 25bf748694..eef70f8836 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/GroupInstall.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/GroupInstall.js @@ -29,9 +29,7 @@ class GroupInstall extends React.Component { axios.post( config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/groups?name=" + value, - { - headers: { 'X-Platform': config.serverConfig.platform } - } + ).then(res => { if (res.status === 200) { if (fetchId !== this.lastFetchId) { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/RoleInstall.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/RoleInstall.js index 851d506e40..04bfb2cd6d 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/RoleInstall.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/RoleInstall.js @@ -29,9 +29,7 @@ class RoleInstall extends React.Component { axios.get( config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/roles?filter=" + value, - { - headers: { 'X-Platform': config.serverConfig.platform } - } + ).then(res => { if (res.status === 200) { if (fetchId !== this.lastFetchId) { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/UserInstall.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/UserInstall.js index 8d38b9287f..89afa7cdec 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/UserInstall.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/UserInstall.js @@ -31,9 +31,7 @@ class UserInstall extends React.Component { //send request to the invoker axios.get( config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt+"/users/search?username=" + value, - { - headers: { 'X-Platform': config.serverConfig.platform } - } + ).then(res => { if (res.status === 200) { if (fetchId !== this.lastFetchId) { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/AddReview.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/AddReview.js index ea6368457e..5d666e1a5d 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/AddReview.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/AddReview.js @@ -57,9 +57,7 @@ class AddReview extends React.Component { axios.post( config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri +config.serverConfig.invoker.store+"/reviews/"+uuid, payload, - { - headers: { 'X-Platform': config.serverConfig.platform } - }).then(res => { + ).then(res => { if (res.status === 201) { this.setState({ loading: false, diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/apps/release/Release.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/apps/release/Release.js index 2882d19b15..cf1ea1f126 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/apps/release/Release.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/apps/release/Release.js @@ -39,9 +39,7 @@ class Release extends React.Component { //send request to the invoker axios.get( config.serverConfig.protocol + "://"+config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.store+"/applications/"+uuid, - { - headers: { 'X-Platform': config.serverConfig.platform } - } + ).then(res => { if (res.status === 200) { let app = res.data.data; From afa6b54c42833c0a114a3309424b10724499904e Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Thu, 27 Jun 2019 23:35:44 +0530 Subject: [PATCH 2/2] Create component to edir release --- .../react-app/public/conf/config.json | 2 +- .../src/components/apps/ReleaseModal.js | 85 ----- .../components/apps/release/ReleaseView.js | 29 +- .../apps/release/edit-release/EditRelease.js | 312 ++++++++++++++++++ .../components/new-release/AddReleaseForm.js | 4 +- .../src/pages/dashboard/apps/Apps-old.js | 4 +- .../src/pages/dashboard/apps/Apps.js | 1 - 7 files changed, 331 insertions(+), 106 deletions(-) delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/ReleaseModal.js create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/edit-release/EditRelease.js diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/conf/config.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/conf/config.json index 0ea6c3218c..5d9f074d94 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/conf/config.json +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/conf/config.json @@ -13,7 +13,7 @@ "store": "/application-mgt-store/v1.0", "admin" : "" }, - "loginUri": "/ui-request-handler/login", + "loginUri": "/publisher-ui-request-handler/login", "platform": "publisher" }, "defaultPlatformIcons": { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/ReleaseModal.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/ReleaseModal.js deleted file mode 100644 index 661ba1efbd..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/ReleaseModal.js +++ /dev/null @@ -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 ( -
- -

Some contents...

- ( - - } - title={{release.version}} - description={release.description} - /> - - )} - /> -
-
- ); - } else { - return null; - } - } -} - -const ReleaseModal = connect(mapStateToProps, null)(ConnectedReleaseModal); - -export default ReleaseModal; \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/ReleaseView.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/ReleaseView.js index 31290b0a89..17b3f7364e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/ReleaseView.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/ReleaseView.js @@ -5,6 +5,7 @@ import Reviews from "./review/Reviews"; import "../../../App.css"; import config from "../../../../public/conf/config.json"; import DetailedRating from "../detailed-rating/DetailedRating"; +import EditRelease from "./edit-release/EditRelease"; const {Title, Text, Paragraph} = Typography; @@ -12,7 +13,7 @@ class ReleaseView extends React.Component { render() { const app = this.props.app; const release = (app !== null) ? app.applicationReleases[0] : null; - if(release == null){ + if (release == null) { return null; } return ( @@ -24,7 +25,7 @@ class ReleaseView extends React.Component { {app.name} - Version : {release.version}

+ Version : {release.version}
+
- - - - +
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/edit-release/EditRelease.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/edit-release/EditRelease.js new file mode 100644 index 0000000000..00d89a7df4 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/edit-release/EditRelease.js @@ -0,0 +1,312 @@ +import React from "react"; +import {Modal, Button, Icon, notification, Spin, Row, Col, Card, Upload, Input, Switch, Form} from 'antd'; +import config from "../../../../../public/conf/config.json"; +import axios from "axios"; + +const {TextArea} = Input; + +const formItemLayout = { + labelCol: { + span: 8, + }, + wrapperCol: { + span: 16, + }, +}; + + +class EditReleaseModal extends React.Component { + + constructor(props) { + super(props); + this.state = { + visible: false, + current: 0, + categories: [], + tags: [], + icons: [], + screenshots: [], + loading: false, + binaryFiles: [] + }; + } + + showModal = () => { + this.setState({ + visible: true, + }); + }; + + handleOk = e => { + console.log(e); + this.setState({ + visible: false, + }); + }; + + handleCancel = e => { + console.log(e); + this.setState({ + visible: false, + }); + }; + + normFile = e => { + console.log('Upload event:', e); + if (Array.isArray(e)) { + return e; + } + return e && e.fileList; + }; + + handleIconChange = ({fileList}) => this.setState({icons: fileList}); + handleBinaryFileChange = ({fileList}) => this.setState({binaryFiles: fileList}); + + handleScreenshotChange = ({fileList}) => this.setState({screenshots: fileList}); + + + handleSubmit = e => { + e.preventDefault(); + const {appId} = this.props; + + this.props.form.validateFields((err, values) => { + if (!err) { + this.setState({ + loading: true + }); + const {price, isSharedWithAllTenants, icon, screenshots, releaseDescription, releaseType, binaryFile} = values; + + + const data = new FormData(); + + //add release data + const release = { + description: releaseDescription, + price: (price === undefined) ? 0 : parseInt(price), + isSharedWithAllTenants, + metaData: "string", + releaseType: releaseType, + supportedOsVersions: "4.0-10.0" + }; + + data.append('binaryFile', binaryFile[0].originFileObj); + data.append('icon', icon[0].originFileObj); + data.append('screenshot1', screenshots[0].originFileObj); + data.append('screenshot2', screenshots[1].originFileObj); + data.append('screenshot3', screenshots[2].originFileObj); + + const json = JSON.stringify(release); + const blob = new Blob([json], { + type: 'application/json' + }); + + data.append("applicationRelease", blob); + + const url = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/ent-app/" + appId; + + axios.put( + url, + data, + { + headers: { + 'X-Platform': config.serverConfig.platform + }, + } + ).then(res => { + if (res.status === 201) { + this.setState({ + loading: false, + }); + + notification["success"]({ + message: "Done!", + description: + "Saved!", + }); + + console.log(res); + + const uuid = res.data.data.uuid; + + this.props.history.push('/publisher/apps/releases/' + uuid); + } + + }).catch((error) => { + console.log(error); + if (error.hasOwnProperty("response") && error.response.status === 401) { + window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/publisher/login'; + } else { + notification["error"]({ + message: "Something went wrong!", + description: + "Sorry, we were unable to complete your request.", + }); + + } + this.setState({ + loading: false + }); + console.log(error); + }); + } + }); + }; + + + render() { + const {categories, tags, icons, screenshots, loading, binaryFiles} = this.state; + const {getFieldDecorator} = this.props.form; + return ( +
+ + +
+ +
+ + {getFieldDecorator('binaryFile', { + valuePropName: 'binaryFile', + getValueFromEvent: this.normFile, + required: true, + message: 'Please select application' + })( + false} + > + {binaryFiles.length !== 1 && ( + + )} + , + )} + + + + {getFieldDecorator('icon', { + valuePropName: 'icon', + getValueFromEvent: this.normFile, + required: true, + message: 'Please select a icon' + })( + false} + > + {icons.length !== 1 && ( + + )} + , + )} + + + + + + + + + + {getFieldDecorator('screenshots', { + valuePropName: 'icon', + getValueFromEvent: this.normFile, + required: true, + message: 'Please select a icon' + })( + false} + multiple + > + + {screenshots.length < 3 && ( + + )} + + + , + )} + + + + {getFieldDecorator('releaseType', { + rules: [{ + required: true, + message: 'Please input the Release Type' + }], + })( + + )} + + + + {getFieldDecorator('releaseDescription', { + rules: [{ + required: true, + message: 'Please enter a description for release' + }], + })( +