Improve the form config object of the add release component

merge-requests/306/head
nipun 5 years ago
parent 2961c1d21c
commit 2978f6f032

@ -24,17 +24,23 @@ import {withConfigContext} from "../../context/ConfigContext";
import {handleApiError} from "../../js/Utils"; import {handleApiError} from "../../js/Utils";
import NewAppUploadForm from "../new-app/subForms/NewAppUploadForm"; import NewAppUploadForm from "../new-app/subForms/NewAppUploadForm";
const formConfig = {
specificElements: {
binaryFile: {
required: true
}
}
};
class AddNewReleaseFormComponent extends React.Component { class AddNewReleaseFormComponent extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
loading: false, loading: false,
isFree: true,
supportedOsVersions: [], supportedOsVersions: [],
application: null, application: null,
release: null, release: null,
isError: false,
deviceType: null deviceType: null
}; };
} }
@ -68,20 +74,18 @@ class AddNewReleaseFormComponent extends React.Component {
const config = this.props.context; const config = this.props.context;
const {appId, deviceType} = this.props; const {appId, deviceType} = this.props;
this.setState({ this.setState({
loading: true, loading: true
isError: false
}); });
const {data, release} = releaseData; const {data, release} = releaseData;
const {formConfig} = this.props;
const json = JSON.stringify(release); const json = JSON.stringify(release);
const blob = new Blob([json], { const blob = new Blob([json], {
type: 'application/json' type: 'application/json'
}); });
data.append(formConfig.jsonPayloadName, blob); data.append("applicationRelease", blob);
const url = window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + const url = window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher +
"/applications/" + deviceType + formConfig.endpoint + "/" + appId; "/applications/" + deviceType + "/ent-app/" + appId;
axios.post( axios.post(
url, url,
data data
@ -101,15 +105,13 @@ class AddNewReleaseFormComponent extends React.Component {
} else { } else {
this.setState({ this.setState({
loading: false, loading: false
isError: true,
}); });
} }
}).catch((error) => { }).catch((error) => {
handleApiError(error, "Sorry, we were unable to complete your request."); handleApiError(error, "Sorry, we were unable to complete your request.");
this.setState({ this.setState({
loading: false, loading: false
isError: true,
}); });
}); });
@ -121,11 +123,10 @@ class AddNewReleaseFormComponent extends React.Component {
render() { render() {
const {loading, supportedOsVersions} = this.state; const {loading, supportedOsVersions} = this.state;
const {formConfig} = this.props;
return ( return (
<div> <div>
<Spin tip="Uploading..." spinning={loading}> <Spin tip="Uploading..." spinning={loading}>
<Card> <Card style={{ width: "65%", marginLeft: "18%" }}>
<NewAppUploadForm <NewAppUploadForm
formConfig={formConfig} formConfig={formConfig}
supportedOsVersions={supportedOsVersions} supportedOsVersions={supportedOsVersions}

@ -28,18 +28,6 @@ import {Link} from "react-router-dom";
const Paragraph = Typography; const Paragraph = Typography;
const formConfig = {
installationType: "ENTERPRISE",
endpoint: "/ent-app",
jsonPayloadName: "applicationRelease",
releaseWrapperName: "entAppReleaseWrappers",
specificElements: {
binaryFile: {
required: true
}
}
};
class AddNewRelease extends React.Component { class AddNewRelease extends React.Component {
constructor(props) { constructor(props) {
@ -67,7 +55,7 @@ class AddNewRelease extends React.Component {
</div> </div>
</PageHeader> </PageHeader>
<div style={{background: '#f0f2f5', padding: 24, minHeight: 720}}> <div style={{background: '#f0f2f5', padding: 24, minHeight: 720}}>
<AddNewReleaseForm deviceType={deviceType} appId={appId} formConfig={formConfig}/> <AddNewReleaseForm deviceType={deviceType} appId={appId} />
</div> </div>
</div> </div>

Loading…
Cancel
Save