From 533871d64abc21b5fead10cf4827734f6bc4a535 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Wed, 9 Oct 2019 11:30:01 +0530 Subject: [PATCH 1/5] Fix null value issue in scheduled install/uninstall operation in APPM UI --- .../react-app/src/components/apps/release/ReleaseView.js | 1 + .../react-app/src/components/apps/release/install/UserInstall.js | 1 + 2 files changed, 2 insertions(+) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/ReleaseView.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/ReleaseView.js index e1fbfbfc70..56135c4fb8 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/ReleaseView.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/ReleaseView.js @@ -43,6 +43,7 @@ class ReleaseView extends React.Component { } appOperation = (type, payload, operation, timestamp=null) => { + console.log(timestamp); const config = this.props.context; const release = this.props.app.applicationReleases[0]; const {uuid} = release; 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 82f91bddff..b90fdab7c1 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 @@ -83,6 +83,7 @@ class UserInstall extends React.Component { }; install = (timestamp=null) => { + console.log(7); const {value} = this.state; const data = []; value.map(val => { From b21de79151a46c27eaf5ebdfd61a5a3ed9e29c0f Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Wed, 9 Oct 2019 12:25:43 +0530 Subject: [PATCH 2/5] Remove unnecessary console log lines in APPM UI --- .../react-app/src/components/apps/release/ReleaseView.js | 1 - .../react-app/src/components/apps/release/install/UserInstall.js | 1 - 2 files changed, 2 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/ReleaseView.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/ReleaseView.js index 56135c4fb8..e1fbfbfc70 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/ReleaseView.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/ReleaseView.js @@ -43,7 +43,6 @@ class ReleaseView extends React.Component { } appOperation = (type, payload, operation, timestamp=null) => { - console.log(timestamp); const config = this.props.context; const release = this.props.app.applicationReleases[0]; const {uuid} = release; 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 b90fdab7c1..82f91bddff 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 @@ -83,7 +83,6 @@ class UserInstall extends React.Component { }; install = (timestamp=null) => { - console.log(7); const {value} = this.state; const data = []; value.map(val => { From 6d16259aafe8ef468f35a83a725d9aa7a128fb78 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Wed, 9 Oct 2019 17:22:34 +0530 Subject: [PATCH 3/5] Improve schedule install/ uninstall component's UI in APPM store --- .../components/apps/release/ReleaseView.js | 4 + .../components/apps/release/ReleaseView.js | 83 +++++++++-------- .../installModalFooter/InstallModalFooter.js | 93 ++++++++----------- 3 files changed, 87 insertions(+), 93 deletions(-) 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 99f7d8055c..dcf97a2204 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 @@ -35,6 +35,10 @@ class ReleaseView extends React.Component { } } + componentDidMount() { + console.log("mounted: Release view"); + } + render() { const {app, release} = this.props; const config = this.props.context; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/ReleaseView.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/ReleaseView.js index e1fbfbfc70..18624ffbfa 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/ReleaseView.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/ReleaseView.js @@ -17,7 +17,7 @@ */ import React from "react"; -import {Divider, Row, Col, Typography, Button, Rate, notification} from "antd"; +import {Divider, Row, Col, Typography, Button, Dropdown, notification, Menu, Icon} from "antd"; import "../../../App.css"; import ImgViewer from "../../apps/release/images/ImgViewer"; import StarRatings from "react-star-ratings"; @@ -42,7 +42,7 @@ class ReleaseView extends React.Component { } } - appOperation = (type, payload, operation, timestamp=null) => { + appOperation = (type, payload, operation, timestamp = null) => { const config = this.props.context; const release = this.props.app.applicationReleases[0]; const {uuid} = release; @@ -50,9 +50,9 @@ class ReleaseView extends React.Component { this.setState({ loading: true, }); - let url = window.location.origin+ config.serverConfig.invoker.uri + + let url = window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/subscription/" + uuid + "/" + type + "/" + operation; - if(timestamp!= null){ + if (timestamp != null) { url += `?timestamp=${timestamp}`; } axios.post( @@ -81,18 +81,11 @@ class ReleaseView extends React.Component { message: "There was a problem", duration: 0, description: - "Error occurred while "+operation+"ing app", + "Error occurred while " + operation + "ing app", }); } }).catch((error) => { - handleApiError(error,"Error occurred while "+operation+"ing the app."); - }); - }; - - - showAppInstallModal = () => { - this.setState({ - appInstallModalVisible: true + handleApiError(error, "Error occurred while " + operation + "ing the app."); }); }; @@ -103,37 +96,50 @@ class ReleaseView extends React.Component { }); }; - showAppUninstallModal = () => { - this.setState({ - appUninstallModalVisible: true - }); + handleSubscribeClick = (e) => { + if (e.key === "install") { + this.setState({ + appInstallModalVisible: true // display app install modal + }) + } else if (e.key === "uninstall") { + this.setState({ + appUninstallModalVisible: true // display app uninstall modal + }) + } }; render() { - const {app,deviceType} = this.props; + const {app, deviceType} = this.props; const release = app.applicationReleases[0]; let metaData = []; - try{ + try { metaData = JSON.parse(release.metaData); - }catch (e) { + } catch (e) { } + const menu = ( + + Install + Uninstall + + ); + return (
+ uuid={release.uuid} + visible={this.state.appUninstallModalVisible} + deviceType={deviceType} + onClose={this.closeAppOperationModal} + onUninstall={this.appOperation}/>
@@ -152,17 +158,14 @@ class ReleaseView extends React.Component { /> -
- - - -
-
- - - +
+ + +
@@ -178,16 +181,16 @@ class ReleaseView extends React.Component { META DATA { - metaData.map((data, index)=>{ + metaData.map((data, index) => { return ( - + {data.key}
{data.value} ) }) } - {(metaData.length===0) && (No meta data available.)} + {(metaData.length === 0) && (No meta data available.)}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/installModalFooter/InstallModalFooter.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/installModalFooter/InstallModalFooter.js index f3b257c263..056ba57802 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/installModalFooter/InstallModalFooter.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/installModalFooter/InstallModalFooter.js @@ -17,12 +17,12 @@ */ import React from "react"; -import {Button, DatePicker} from "antd"; +import {Button, DatePicker, Checkbox} from "antd"; -class InstallModalFooter extends React.Component{ +class InstallModalFooter extends React.Component { constructor(props) { super(props); - this.state={ + this.state = { scheduledTime: null, isScheduledInstallVisible: false } @@ -34,65 +34,52 @@ class InstallModalFooter extends React.Component{ }); }; - showScheduledInstall = ()=>{ + toggleScheduledInstall = () => { this.setState({ - isScheduledInstallVisible: true + isScheduledInstallVisible: !this.state.isScheduledInstallVisible }) }; - hideScheduledInstall = ()=>{ - this.setState({ - isScheduledInstallVisible: false - }) - }; - - triggerInstallOperation = () =>{ - this.props.operation(); - }; - triggerScheduledInstallOperation = () =>{ - const {scheduledTime} =this.state; - this.props.operation(scheduledTime); + triggerInstallOperation = () => { + const {scheduledTime, isScheduledInstallVisible} = this.state; + if (isScheduledInstallVisible && scheduledTime != null) { + this.props.operation(scheduledTime); + } else { + this.props.operation(); + } }; render() { - const {scheduledTime,isScheduledInstallVisible} =this.state; + const {scheduledTime, isScheduledInstallVisible} = this.state; const {disabled, type} = this.props; return ( -
-
- - -
-
- - - -
-
+
+
+
+ + Schedule {type} + +
+ + + + +
+ +
); } } From 5153feae40ca7fa875c13ac200a30be65c46769e Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Thu, 10 Oct 2019 11:04:43 +0530 Subject: [PATCH 4/5] Fix login redirection issue in APPM Store UI --- .../react-app/src/pages/Login.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/Login.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/Login.js index 354ef62167..3f1ff09306 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/Login.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/Login.js @@ -98,13 +98,18 @@ class NormalLoginForm extends React.Component { const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&'); - axios.post(window.location.origin+ config.serverConfig.loginUri, request + axios.post(window.location.origin + config.serverConfig.loginUri, request ).then(res => { if (res.status === 200) { - window.location = window.location.origin+ "/store"; + let redirectUrl = window.location.origin + "/store"; + const searchParams = new URLSearchParams(window.location.search); + if (searchParams.has("redirect")) { + redirectUrl = searchParams.get("redirect"); + } + window.location = redirectUrl; } }).catch(function (error) { - handleApiError(error,"Error occurred while trying to load groups."); + handleApiError(error, "Error occurred while trying to load groups."); if (error.hasOwnProperty("response") && error.response.status === 400) { thisForm.setState({ inValid: true, @@ -158,7 +163,8 @@ class NormalLoginForm extends React.Component { )}
Forgot password - From 3c9d20077015a08b13c045ce9301a7f8dcd47168 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Thu, 10 Oct 2019 14:29:11 +0530 Subject: [PATCH 5/5] Validate supported OS versions in 'Add new app' form in APPM Publisher UI --- .../react-app/package.json | 2 +- .../new-app/subForms/NewAppUploadForm.js | 70 ++++++++++++++----- 2 files changed, 54 insertions(+), 18 deletions(-) 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 cdac823d7a..565064db72 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,7 +13,7 @@ "@ant-design/dark-theme": "^0.2.2", "@babel/polyfill": "^7.6.0", "acorn": "^6.2.0", - "antd": "^3.22.2", + "antd": "^3.23.6", "axios": "^0.19.0", "d3": "^5.9.7", "dagre": "^0.8.4", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/new-app/subForms/NewAppUploadForm.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/new-app/subForms/NewAppUploadForm.js index af7a9ec85e..d8e52bc2be 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/new-app/subForms/NewAppUploadForm.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/new-app/subForms/NewAppUploadForm.js @@ -61,6 +61,8 @@ class NewAppUploadForm extends React.Component { binaryFileHelperText: '', iconHelperText: '', screenshotHelperText: '', + osVersionsHelperText: '', + osVersionsValidateStatus: 'validating', metaData: [] }; this.lowerOsVersion = null; @@ -95,10 +97,6 @@ class NewAppUploadForm extends React.Component { releaseType: releaseType }; - if (formConfig.installationType !== "WEB_CLIP" && formConfig.installationType !== "CUSTOM") { - release.supportedOsVersions = `${this.lowerOsVersion}-${this.upperOsVersion}`; - } - if (specificElements.hasOwnProperty("version")) { release.version = values.version; } @@ -110,20 +108,51 @@ class NewAppUploadForm extends React.Component { } const data = new FormData(); + let isFormValid = true; // flag to check if this form is valid + + if (formConfig.installationType !== "WEB_CLIP" && formConfig.installationType !== "CUSTOM") { + if(this.lowerOsVersion==null || this.upperOsVersion==null){ + isFormValid = false; + this.setState({ + osVersionsHelperText: 'Please select supported OS versions', + osVersionsValidateStatus: 'error', + }); + }else if(this.lowerOsVersion>=this.upperOsVersion){ + isFormValid = false; + this.setState({ + osVersionsHelperText: 'Please select valid range', + osVersionsValidateStatus: 'error', + }); + }else{ + release.supportedOsVersions = `${this.lowerOsVersion}-${this.upperOsVersion}`; + } + } if (specificElements.hasOwnProperty("binaryFile") && this.state.binaryFiles.length !== 1) { + isFormValid = false; this.setState({ binaryFileHelperText: 'Please select the application' }); - } else if (this.state.icons.length !== 1) { + } + if (this.state.icons.length !== 1) { + isFormValid = false; this.setState({ iconHelperText: 'Please select an icon' }); - } else if (this.state.screenshots.length !== 3) { + } + if (this.state.screenshots.length !== 3) { + isFormValid = false; + this.setState({ + screenshotHelperText: 'Please select 3 screenshots' + }); + } + if (this.state.screenshots.length !== 3) { + isFormValid = false; this.setState({ screenshotHelperText: 'Please select 3 screenshots' }); - } else { + } + if(isFormValid) { data.append('icon', icon[0].originFileObj); data.append('screenshot1', screenshots[0].originFileObj); data.append('screenshot2', screenshots[1].originFileObj); @@ -193,10 +222,18 @@ class NewAppUploadForm extends React.Component { handleLowerOsVersionChange = (lowerOsVersion) => { this.lowerOsVersion = lowerOsVersion; + this.setState({ + osVersionsValidateStatus: 'validating', + osVersionsHelperText: '' + }); }; handleUpperOsVersionChange = (upperOsVersion) => { this.upperOsVersion = upperOsVersion; + this.setState({ + osVersionsValidateStatus: 'validating', + osVersionsHelperText: '' + }); }; render() { @@ -212,7 +249,9 @@ class NewAppUploadForm extends React.Component { binaryFileHelperText, iconHelperText, screenshotHelperText, - metaData + metaData, + osVersionsHelperText, + osVersionsValidateStatus } = this.state; const uploadButton = (
@@ -361,7 +400,11 @@ class NewAppUploadForm extends React.Component { {(formConfig.installationType !== "WEB_CLIP" && formConfig.installationType !== "CUSTOM") && ( - + {getFieldDecorator('supportedOS')(
@@ -436,7 +479,6 @@ class NewAppUploadForm extends React.Component { required: true, message: 'Please select' }], - initialValue: false })( } unCheckedChildren={} @@ -444,13 +486,7 @@ class NewAppUploadForm extends React.Component { )} - {getFieldDecorator('meta', { - rules: [{ - required: true, - message: 'Please fill empty fields' - }], - initialValue: false - })( + {getFieldDecorator('meta', {})(
{ metaData.map((data, index) => {