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
index 00d89a7df4c..a8a12a029cd 100644
--- 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
@@ -14,7 +14,6 @@ const formItemLayout = {
},
};
-
class EditReleaseModal extends React.Component {
constructor(props) {
@@ -27,10 +26,62 @@ class EditReleaseModal extends React.Component {
icons: [],
screenshots: [],
loading: false,
- binaryFiles: []
+ binaryFiles: [],
+ formConfig: {
+ specificElements: {}
+ }
};
}
+ componentDidMount = () => {
+ this.generateConfig();
+ };
+
+ generateConfig = () => {
+ const {type} = this.props;
+ const formConfig = {
+ type
+ };
+
+ switch (type) {
+ case "ENTERPRISE":
+ formConfig.endpoint = "/ent-app-release";
+ formConfig.specificElements = {
+ binaryFile: {
+ required: true
+ }
+ };
+ break;
+ case "PUBLIC":
+ formConfig.endpoint = "/public-app-release";
+ formConfig.specificElements = {
+ packageName: {
+ required: true
+ },
+ version: {
+ required: true
+ }
+ };
+ break;
+ case "WEB_CLIP":
+ formConfig.endpoint = "/web-app-release";
+ formConfig.specificElements = {
+ version: {
+ required: true
+ },
+ url: {
+ required: true
+ }
+ };
+ break;
+ }
+
+ this.setState({
+ formConfig
+ });
+ };
+
+
showModal = () => {
this.setState({
visible: true,
@@ -38,21 +89,18 @@ class EditReleaseModal extends React.Component {
};
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;
}
@@ -67,15 +115,19 @@ class EditReleaseModal extends React.Component {
handleSubmit = e => {
e.preventDefault();
- const {appId} = this.props;
+ const {uuid} = this.props;
+
+ const {formConfig} = this.state;
+ const {specificElements} = formConfig;
this.props.form.validateFields((err, values) => {
if (!err) {
this.setState({
loading: true
});
- const {price, isSharedWithAllTenants, icon, screenshots, releaseDescription, releaseType, binaryFile} = values;
+ const {price, isSharedWithAllTenants, releaseDescription, releaseType} = values;
+ const {icons, screenshots, binaryFiles} = this.state;
const data = new FormData();
@@ -89,11 +141,37 @@ class EditReleaseModal extends React.Component {
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);
+ if (specificElements.hasOwnProperty("binaryFile") && binaryFiles.length === 1) {
+ data.append('binaryFile', binaryFiles[0].originFileObj);
+ }
+
+ if (specificElements.hasOwnProperty("version")) {
+ release.version = values.version;
+ }
+
+ if (specificElements.hasOwnProperty("url")) {
+ release.url = values.url;
+ }
+
+ if (specificElements.hasOwnProperty("packageName")) {
+ release.packageName = values.packageName;
+ }
+
+ if (icons.length === 1) {
+ data.append('icon', icons[0].originFileObj);
+ }
+
+ if(screenshots.length>0){
+ data.append('screenshot1', screenshots[0].originFileObj);
+ }
+
+ if(screenshots.length>1){
+ data.append('screenshot2', screenshots[1].originFileObj);
+ }
+
+ if(screenshots.length>2){
+ data.append('screenshot3', screenshots[2].originFileObj);
+ }
const json = JSON.stringify(release);
const blob = new Blob([json], {
@@ -102,20 +180,16 @@ class EditReleaseModal extends React.Component {
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;
+ const url = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications" + formConfig.endpoint + "/" + uuid;
axios.put(
url,
- data,
- {
- headers: {
- 'X-Platform': config.serverConfig.platform
- },
- }
+ data
).then(res => {
- if (res.status === 201) {
+ if (res.status === 200) {
this.setState({
loading: false,
+ visible: false,
});
notification["success"]({
@@ -124,15 +198,12 @@ class EditReleaseModal extends React.Component {
"Saved!",
});
- console.log(res);
-
const uuid = res.data.data.uuid;
- this.props.history.push('/publisher/apps/releases/' + 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 {
@@ -146,7 +217,6 @@ class EditReleaseModal extends React.Component {
this.setState({
loading: false
});
- console.log(error);
});
}
});
@@ -154,7 +224,7 @@ class EditReleaseModal extends React.Component {
render() {
- const {categories, tags, icons, screenshots, loading, binaryFiles} = this.state;
+ const {formConfig, icons, screenshots, loading, binaryFiles} = this.state;
const {getFieldDecorator} = this.props.form;
return (
@@ -172,26 +242,67 @@ class EditReleaseModal extends React.Component {
- {getFieldDecorator('binaryFile', {
- valuePropName: 'binaryFile',
- getValueFromEvent: this.normFile,
- required: true,
- message: 'Please select application'
- })(
- false}
- >
- {binaryFiles.length !== 1 && (
-
- )}
- ,
- )}
-
+ {formConfig.specificElements.hasOwnProperty("binaryFile") && (
+
+ {getFieldDecorator('binaryFile', {
+ valuePropName: 'binaryFile',
+ getValueFromEvent: this.normFile,
+ required: true,
+ message: 'Please select application'
+ })(
+ false}
+ >
+ {binaryFiles.length !== 1 && (
+
+ )}
+ ,
+ )}
+
+ )}
+
+ {formConfig.specificElements.hasOwnProperty("packageName") && (
+
+ {getFieldDecorator('packageName', {
+ rules: [{
+ required: true,
+ message: 'Please input the package name'
+ }],
+ })(
+
+ )}
+
+ )}
+
+ {formConfig.specificElements.hasOwnProperty("url") && (
+
+ {getFieldDecorator('url', {
+ rules: [{
+ required: true,
+ message: 'Please input the url'
+ }],
+ })(
+
+ )}
+
+ )}
+
+ {formConfig.specificElements.hasOwnProperty("version") && (
+
+ {getFieldDecorator('version', {
+ rules: [{
+ required: true,
+ message: 'Please input the version'
+ }],
+ })(
+
+ )}
+
+ )}
{getFieldDecorator('icon', {
@@ -207,18 +318,13 @@ class EditReleaseModal extends React.Component {
>
{icons.length !== 1 && (
)}
,
)}
-
-
-
-
-
{getFieldDecorator('screenshots', {
@@ -304,7 +410,6 @@ class EditReleaseModal extends React.Component {
);
}
-
}
const EditRelease = Form.create({name: 'add-new-release'})(EditReleaseModal);
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/lifeCycle/LifeCycle.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/lifeCycle/LifeCycle.js
index 24f721a0c4e..1b4203daea1 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/lifeCycle/LifeCycle.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/release/lifeCycle/LifeCycle.js
@@ -61,7 +61,6 @@ class LifeCycle extends React.Component {
}).then(res => {
if (res.status === 200) {
const lifecycle = res.data.data;
- console.log(lifecycle);
this.setState({
lifecycle: lifecycle
})
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/new-app/AddNewAppForm.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/new-app/AddNewAppForm.js
index 60446cb3277..c8f67e8b456 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/new-app/AddNewAppForm.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/new-app/AddNewAppForm.js
@@ -108,7 +108,7 @@ class AddNewAppFormComponent extends React.Component {
};
handleCategoryChange = (value) => {
- console.log(`selected ${value}`);
+ // console.log(`selected ${value}`);
};
handleSubmit = e => {
@@ -181,8 +181,6 @@ class AddNewAppFormComponent extends React.Component {
});
data.append(formConfig.jsonPayloadName, blob);
- console.log(application);
-
const url = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications" + formConfig.endpoint;
axios.post(
@@ -231,7 +229,6 @@ class AddNewAppFormComponent extends React.Component {
};
normFile = e => {
- console.log('Upload event:', e);
if (Array.isArray(e)) {
return e;
}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/new-release/AddReleaseForm.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/new-release/AddReleaseForm.js
index 7cae042f051..c537d8698ab 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/new-release/AddReleaseForm.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/new-release/AddReleaseForm.js
@@ -110,15 +110,12 @@ class AddNewReleaseFormComponent extends React.Component {
"New release was added successfully",
});
- 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 {
@@ -132,14 +129,12 @@ class AddNewReleaseFormComponent extends React.Component {
this.setState({
loading: false
});
- console.log(error);
});
}
});
};
normFile = e => {
- console.log('Upload event:', e);
if (Array.isArray(e)) {
return e;
}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/Dashboard.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/Dashboard.js
index 32803b36a5b..c0018e4fee1 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/Dashboard.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/Dashboard.js
@@ -14,7 +14,7 @@ class Dashboard extends React.Component {
super(props);
this.state = {
routes: props.routes
- }
+ };
}
render() {
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/Step1.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/Step1.js
index 24d71944311..f40c79060be 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/Step1.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/Step1.js
@@ -24,7 +24,6 @@ class EditableTagGroup extends React.Component {
handleClose = (removedTag) => {
const tags = this.state.tags.filter(tag => tag !== removedTag);
- console.log(tags);
this.setState({ tags });
}
@@ -42,7 +41,6 @@ class EditableTagGroup extends React.Component {
if (inputValue && tags.indexOf(inputValue) === -1) {
tags = [...tags, inputValue];
}
- console.log(tags);
this.setState({
tags,
inputVisible: false,
@@ -92,7 +90,6 @@ class EditableTagGroup extends React.Component {
class Step1 extends React.Component {
render() {
- console.log("hhhoohh");
return (