Completed edit ent app basic functionality

feature/appm-store/pbac
Jayasanka 5 years ago
parent 792e52445e
commit f76e6c9411

@ -218,8 +218,6 @@ class AppDetailsDrawer extends React.Component {
const {id} = this.props.app; const {id} = this.props.app;
const {temporaryCategories, categories} = this.state; const {temporaryCategories, categories} = this.state;
console.log(temporaryCategories);
const difference = temporaryCategories const difference = temporaryCategories
.filter(x => !categories.includes(x)) .filter(x => !categories.includes(x))
.concat(categories.filter(x => !temporaryCategories.includes(x))); .concat(categories.filter(x => !temporaryCategories.includes(x)));
@ -280,7 +278,6 @@ class AppDetailsDrawer extends React.Component {
const {id} = this.props.app; const {id} = this.props.app;
const {temporaryTags, tags} = this.state; const {temporaryTags, tags} = this.state;
console.log(temporaryTags);
const difference = temporaryTags const difference = temporaryTags
.filter(x => !tags.includes(x)) .filter(x => !tags.includes(x))

@ -34,7 +34,7 @@ class ReleaseView extends React.Component {
numberOfStars={5} numberOfStars={5}
name='rating' name='rating'
/> />
<EditRelease/> <EditRelease uuid={release.uuid} type={app.type}/>
</Col> </Col>
<Col xl={8} md={10} sm={24} xs={24} style={{float: "right"}}> <Col xl={8} md={10} sm={24} xs={24} style={{float: "right"}}>
<div> <div>

@ -14,7 +14,6 @@ const formItemLayout = {
}, },
}; };
class EditReleaseModal extends React.Component { class EditReleaseModal extends React.Component {
constructor(props) { constructor(props) {
@ -27,10 +26,62 @@ class EditReleaseModal extends React.Component {
icons: [], icons: [],
screenshots: [], screenshots: [],
loading: false, 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 = () => { showModal = () => {
this.setState({ this.setState({
visible: true, visible: true,
@ -38,21 +89,18 @@ class EditReleaseModal extends React.Component {
}; };
handleOk = e => { handleOk = e => {
console.log(e);
this.setState({ this.setState({
visible: false, visible: false,
}); });
}; };
handleCancel = e => { handleCancel = e => {
console.log(e);
this.setState({ this.setState({
visible: false, visible: false,
}); });
}; };
normFile = e => { normFile = e => {
console.log('Upload event:', e);
if (Array.isArray(e)) { if (Array.isArray(e)) {
return e; return e;
} }
@ -67,15 +115,19 @@ class EditReleaseModal extends React.Component {
handleSubmit = e => { handleSubmit = e => {
e.preventDefault(); e.preventDefault();
const {appId} = this.props; const {uuid} = this.props;
const {formConfig} = this.state;
const {specificElements} = formConfig;
this.props.form.validateFields((err, values) => { this.props.form.validateFields((err, values) => {
if (!err) { if (!err) {
this.setState({ this.setState({
loading: true 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(); const data = new FormData();
@ -89,11 +141,37 @@ class EditReleaseModal extends React.Component {
supportedOsVersions: "4.0-10.0" supportedOsVersions: "4.0-10.0"
}; };
data.append('binaryFile', binaryFile[0].originFileObj); if (specificElements.hasOwnProperty("binaryFile") && binaryFiles.length === 1) {
data.append('icon', icon[0].originFileObj); 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); data.append('screenshot1', screenshots[0].originFileObj);
}
if(screenshots.length>1){
data.append('screenshot2', screenshots[1].originFileObj); data.append('screenshot2', screenshots[1].originFileObj);
}
if(screenshots.length>2){
data.append('screenshot3', screenshots[2].originFileObj); data.append('screenshot3', screenshots[2].originFileObj);
}
const json = JSON.stringify(release); const json = JSON.stringify(release);
const blob = new Blob([json], { const blob = new Blob([json], {
@ -102,20 +180,16 @@ class EditReleaseModal extends React.Component {
data.append("applicationRelease", blob); 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.post( axios.put(
url, url,
data, data
{
headers: {
'X-Platform': config.serverConfig.platform
},
}
).then(res => { ).then(res => {
if (res.status === 201) { if (res.status === 200) {
this.setState({ this.setState({
loading: false, loading: false,
visible: false,
}); });
notification["success"]({ notification["success"]({
@ -124,15 +198,12 @@ class EditReleaseModal extends React.Component {
"Saved!", "Saved!",
}); });
console.log(res);
const uuid = res.data.data.uuid; const uuid = res.data.data.uuid;
this.props.history.push('/publisher/apps/releases/' + uuid); // this.props.history.push('/publisher/apps/releases/' + uuid);
} }
}).catch((error) => { }).catch((error) => {
console.log(error);
if (error.hasOwnProperty("response") && error.response.status === 401) { if (error.hasOwnProperty("response") && error.response.status === 401) {
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/publisher/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/publisher/login';
} else { } else {
@ -146,7 +217,6 @@ class EditReleaseModal extends React.Component {
this.setState({ this.setState({
loading: false loading: false
}); });
console.log(error);
}); });
} }
}); });
@ -154,7 +224,7 @@ class EditReleaseModal extends React.Component {
render() { render() {
const {categories, tags, icons, screenshots, loading, binaryFiles} = this.state; const {formConfig, icons, screenshots, loading, binaryFiles} = this.state;
const {getFieldDecorator} = this.props.form; const {getFieldDecorator} = this.props.form;
return ( return (
<div> <div>
@ -172,6 +242,7 @@ class EditReleaseModal extends React.Component {
<Form labelAlign="left" layout="horizontal" <Form labelAlign="left" layout="horizontal"
hideRequiredMark hideRequiredMark
onSubmit={this.handleSubmit}> onSubmit={this.handleSubmit}>
{formConfig.specificElements.hasOwnProperty("binaryFile") && (
<Form.Item {...formItemLayout} label="Application"> <Form.Item {...formItemLayout} label="Application">
{getFieldDecorator('binaryFile', { {getFieldDecorator('binaryFile', {
valuePropName: 'binaryFile', valuePropName: 'binaryFile',
@ -186,12 +257,52 @@ class EditReleaseModal extends React.Component {
> >
{binaryFiles.length !== 1 && ( {binaryFiles.length !== 1 && (
<Button> <Button>
<Icon type="upload"/> Click to upload <Icon type="upload"/> Change
</Button> </Button>
)} )}
</Upload>, </Upload>,
)} )}
</Form.Item> </Form.Item>
)}
{formConfig.specificElements.hasOwnProperty("packageName") && (
<Form.Item {...formItemLayout} label="Package Name">
{getFieldDecorator('packageName', {
rules: [{
required: true,
message: 'Please input the package name'
}],
})(
<Input placeholder="Package Name"/>
)}
</Form.Item>
)}
{formConfig.specificElements.hasOwnProperty("url") && (
<Form.Item {...formItemLayout} label="URL">
{getFieldDecorator('url', {
rules: [{
required: true,
message: 'Please input the url'
}],
})(
<Input placeholder="url"/>
)}
</Form.Item>
)}
{formConfig.specificElements.hasOwnProperty("version") && (
<Form.Item {...formItemLayout} label="Version">
{getFieldDecorator('version', {
rules: [{
required: true,
message: 'Please input the version'
}],
})(
<Input placeholder="Version"/>
)}
</Form.Item>
)}
<Form.Item {...formItemLayout} label="Icon"> <Form.Item {...formItemLayout} label="Icon">
{getFieldDecorator('icon', { {getFieldDecorator('icon', {
@ -207,18 +318,13 @@ class EditReleaseModal extends React.Component {
> >
{icons.length !== 1 && ( {icons.length !== 1 && (
<Button> <Button>
<Icon type="upload"/> Click to upload <Icon type="upload"/> Change
</Button> </Button>
)} )}
</Upload>, </Upload>,
)} )}
</Form.Item> </Form.Item>
<Row style={{marginTop: 40}}>
<Col span={24}>
</Col>
</Row>
<Form.Item {...formItemLayout} label="Screenshots"> <Form.Item {...formItemLayout} label="Screenshots">
{getFieldDecorator('screenshots', { {getFieldDecorator('screenshots', {
@ -304,7 +410,6 @@ class EditReleaseModal extends React.Component {
</div> </div>
); );
} }
} }
const EditRelease = Form.create({name: 'add-new-release'})(EditReleaseModal); const EditRelease = Form.create({name: 'add-new-release'})(EditReleaseModal);

@ -61,7 +61,6 @@ class LifeCycle extends React.Component {
}).then(res => { }).then(res => {
if (res.status === 200) { if (res.status === 200) {
const lifecycle = res.data.data; const lifecycle = res.data.data;
console.log(lifecycle);
this.setState({ this.setState({
lifecycle: lifecycle lifecycle: lifecycle
}) })

@ -108,7 +108,7 @@ class AddNewAppFormComponent extends React.Component {
}; };
handleCategoryChange = (value) => { handleCategoryChange = (value) => {
console.log(`selected ${value}`); // console.log(`selected ${value}`);
}; };
handleSubmit = e => { handleSubmit = e => {
@ -181,8 +181,6 @@ class AddNewAppFormComponent extends React.Component {
}); });
data.append(formConfig.jsonPayloadName, blob); 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; const url = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications" + formConfig.endpoint;
axios.post( axios.post(
@ -231,7 +229,6 @@ class AddNewAppFormComponent extends React.Component {
}; };
normFile = e => { normFile = e => {
console.log('Upload event:', e);
if (Array.isArray(e)) { if (Array.isArray(e)) {
return e; return e;
} }

@ -110,15 +110,12 @@ class AddNewReleaseFormComponent extends React.Component {
"New release was added successfully", "New release was added successfully",
}); });
console.log(res);
const uuid = res.data.data.uuid; const uuid = res.data.data.uuid;
this.props.history.push('/publisher/apps/releases/'+uuid); this.props.history.push('/publisher/apps/releases/'+uuid);
} }
}).catch((error) => { }).catch((error) => {
console.log(error);
if (error.hasOwnProperty("response") && error.response.status === 401) { if (error.hasOwnProperty("response") && error.response.status === 401) {
window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/publisher/login'; window.location.href = config.serverConfig.protocol + "://" + config.serverConfig.hostname + ':' + config.serverConfig.httpsPort + '/publisher/login';
} else { } else {
@ -132,14 +129,12 @@ class AddNewReleaseFormComponent extends React.Component {
this.setState({ this.setState({
loading: false loading: false
}); });
console.log(error);
}); });
} }
}); });
}; };
normFile = e => { normFile = e => {
console.log('Upload event:', e);
if (Array.isArray(e)) { if (Array.isArray(e)) {
return e; return e;
} }

@ -14,7 +14,7 @@ class Dashboard extends React.Component {
super(props); super(props);
this.state = { this.state = {
routes: props.routes routes: props.routes
} };
} }
render() { render() {

@ -24,7 +24,6 @@ class EditableTagGroup extends React.Component {
handleClose = (removedTag) => { handleClose = (removedTag) => {
const tags = this.state.tags.filter(tag => tag !== removedTag); const tags = this.state.tags.filter(tag => tag !== removedTag);
console.log(tags);
this.setState({ tags }); this.setState({ tags });
} }
@ -42,7 +41,6 @@ class EditableTagGroup extends React.Component {
if (inputValue && tags.indexOf(inputValue) === -1) { if (inputValue && tags.indexOf(inputValue) === -1) {
tags = [...tags, inputValue]; tags = [...tags, inputValue];
} }
console.log(tags);
this.setState({ this.setState({
tags, tags,
inputVisible: false, inputVisible: false,
@ -92,7 +90,6 @@ class EditableTagGroup extends React.Component {
class Step1 extends React.Component { class Step1 extends React.Component {
render() { render() {
console.log("hhhoohh");
return ( return (
<div> <div>
<Form layout="horizontal" className={styles.stepForm} hideRequiredMark> <Form layout="horizontal" className={styles.stepForm} hideRequiredMark>

@ -2,7 +2,6 @@ import React from "react"
class Step2 extends React.Component { class Step2 extends React.Component {
render() { render() {
console.log("hhhoohh");
return ( return (
<p>tttoooeeee</p> <p>tttoooeeee</p>
); );

@ -1,6 +1,6 @@
import React from "react"; import React from "react";
import '../../../../App.css'; import '../../../../App.css';
import {PageHeader, Typography, Row, Col, message, Card} from "antd"; import {Typography, Row, Col, message, Card} from "antd";
import axios from 'axios'; import axios from 'axios';
import config from "../../../../../public/conf/config.json"; import config from "../../../../../public/conf/config.json";
import ReleaseView from "../../../../components/apps/release/ReleaseView"; import ReleaseView from "../../../../components/apps/release/ReleaseView";

Loading…
Cancel
Save