+ });
+ };
+
+ handleEditInputChange = e => {
+ this.setState({
+ editingValue: e.target.value,
+ });
+ };
+
+ render() {
+ const {
+ categories,
+ inputVisible,
+ inputValue,
+ tempElements,
+ isAddNewVisible,
+ forbiddenErrors,
+ } = this.state;
+ const categoriesElements = categories.map(this.renderElement);
+ const temporaryElements = tempElements.map(this.renderTempElement);
+ return (
+
+ );
+ }
}
export default withConfigContext(ManageCategories);
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 8b9ed800b1..7123aadf7e 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
@@ -16,450 +16,499 @@
* under the License.
*/
-import React from "react";
+import React from 'react';
import {
- Card,
- Tag,
- message,
- Icon,
- Input,
- notification,
- Divider,
- Button,
- Spin,
- Tooltip,
- Popconfirm,
- Modal,
- Row, Col,
- Typography, Alert
-} from "antd";
-import axios from "axios";
-import {TweenOneGroup} from 'rc-tween-one';
-import {withConfigContext} from "../../../context/ConfigContext";
-import {handleApiError} from "../../../js/Utils";
-
-const {Title} = Typography;
+ Card,
+ Tag,
+ message,
+ Icon,
+ Input,
+ notification,
+ Divider,
+ Button,
+ Spin,
+ Tooltip,
+ Popconfirm,
+ Modal,
+ Row,
+ Col,
+ Typography,
+ Alert,
+} from 'antd';
+import axios from 'axios';
+import { TweenOneGroup } from 'rc-tween-one';
+import { withConfigContext } from '../../../context/ConfigContext';
+import { handleApiError } from '../../../js/Utils';
+
+const { Title } = Typography;
class ManageTags extends React.Component {
- state = {
- loading: false,
- searchText: '',
- tags: [],
- tempElements: [],
- inputVisible: false,
- inputValue: '',
- isAddNewVisible: false,
- isEditModalVisible: false,
- currentlyEditingId: null,
- editingValue: null,
- forbiddenErrors: {
- tags: false
+ state = {
+ loading: false,
+ searchText: '',
+ tags: [],
+ tempElements: [],
+ inputVisible: false,
+ inputValue: '',
+ isAddNewVisible: false,
+ isEditModalVisible: false,
+ currentlyEditingId: null,
+ editingValue: null,
+ forbiddenErrors: {
+ tags: false,
+ },
+ };
+
+ componentDidMount() {
+ const config = this.props.context;
+ axios
+ .get(
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ config.serverConfig.invoker.publisher +
+ '/applications/tags',
+ )
+ .then(res => {
+ if (res.status === 200) {
+ let tags = JSON.parse(res.data.data);
+ this.setState({
+ tags: tags,
+ loading: false,
+ });
}
- };
-
- componentDidMount() {
- const config = this.props.context;
- axios.get(
- window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/tags",
- ).then(res => {
- if (res.status === 200) {
- let tags = JSON.parse(res.data.data);
- this.setState({
- tags: tags,
- loading: false
- });
- }
-
- }).catch((error) => {
- handleApiError(error, "Error occurred while trying to load tags.", true);
- if (error.hasOwnProperty("response") && error.response.status === 403) {
- const {forbiddenErrors} = this.state;
- forbiddenErrors.tags = true;
- this.setState({
- forbiddenErrors,
- loading: false
- })
- } else {
- this.setState({
- loading: false
- });
- }
- });
- }
-
- handleCloseButton = () => {
- this.setState({
- tempElements: [],
- isAddNewVisible: false
- });
- };
-
- deleteTag = (id) => {
- const config = this.props.context;
-
- this.setState({
- loading: true
- });
-
- axios.delete(
- window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/admin/applications/tags/" + id
- ).then(res => {
- if (res.status === 200) {
- notification["success"]({
- message: "Done!",
- description:
- "Tag Removed Successfully!",
- });
-
- const {tags} = this.state;
- const remainingElements = tags.filter(function (value) {
- return value.tagName !== id;
-
- });
-
- this.setState({
- loading: false,
- tags: remainingElements
- });
- }
-
- }).catch((error) => {
- handleApiError(error, "Error occurred while trying to delete the tag.");
- this.setState({
- loading: false
- });
- });
- };
-
- renderElement = (tag) => {
- const tagName = tag.tagName;
- const tagElem = (
-
- );
- };
-
- renderTempElement = (tag) => {
- const {tempElements} = this.state;
- const tagElem = (
-
+ })
+ .catch(error => {
+ handleApiError(
+ error,
+ 'Error occurred while trying to load tags.',
+ true,
);
- };
-
- showInput = () => {
- this.setState({inputVisible: true}, () => this.input.focus());
- };
-
- handleInputChange = e => {
- this.setState({inputValue: e.target.value});
- };
-
- handleInputConfirm = () => {
- const {inputValue, tags} = this.state;
- let {tempElements} = this.state;
- if (inputValue) {
- if ((tags.findIndex(i => i.tagName === inputValue) === -1) && (tempElements.findIndex(i => i.tagName === inputValue) === -1)) {
- tempElements = [...tempElements, {tagName: inputValue, isTagDeletable: true}];
- } else {
- message.warning('Tag already exists');
- }
+ if (error.hasOwnProperty('response') && error.response.status === 403) {
+ const { forbiddenErrors } = this.state;
+ forbiddenErrors.tags = true;
+ this.setState({
+ forbiddenErrors,
+ loading: false,
+ });
+ } else {
+ this.setState({
+ loading: false,
+ });
}
-
- this.setState({
- tempElements,
- inputVisible: false,
- inputValue: '',
- });
- };
-
- handleSave = () => {
- const config = this.props.context;
- const {tempElements, tags} = this.state;
+ });
+ }
+
+ handleCloseButton = () => {
+ this.setState({
+ tempElements: [],
+ isAddNewVisible: false,
+ });
+ };
+
+ deleteTag = id => {
+ const config = this.props.context;
+
+ this.setState({
+ loading: true,
+ });
+
+ axios
+ .delete(
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ config.serverConfig.invoker.publisher +
+ '/admin/applications/tags/' +
+ id,
+ )
+ .then(res => {
+ if (res.status === 200) {
+ notification.success({
+ message: 'Done!',
+ description: 'Tag Removed Successfully!',
+ });
+
+ const { tags } = this.state;
+ const remainingElements = tags.filter(function(value) {
+ return value.tagName !== id;
+ });
+
+ this.setState({
+ loading: false,
+ tags: remainingElements,
+ });
+ }
+ })
+ .catch(error => {
+ handleApiError(error, 'Error occurred while trying to delete the tag.');
this.setState({
- loading: true
+ loading: false,
});
-
- const data = tempElements.map(tag => tag.tagName);
-
- axios.post(window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/tags",
- data,
- ).then(res => {
- if (res.status === 200) {
- notification["success"]({
- message: "Done!",
- description:
- "New tags were added successfully",
- });
-
- this.setState({
- tags: [...tags, ...tempElements],
- tempElements: [],
- inputVisible: false,
- inputValue: '',
- loading: false,
- isAddNewVisible: false
+ });
+ };
+
+ renderElement = tag => {
+ const tagName = tag.tagName;
+ const tagElem = (
+
+ );
+ };
+
+ renderTempElement = tag => {
+ const { tempElements } = this.state;
+ const tagElem = (
+
+ );
+ };
+
+ showInput = () => {
+ this.setState({ inputVisible: true }, () => this.input.focus());
+ };
+
+ handleInputChange = e => {
+ this.setState({ inputValue: e.target.value });
+ };
+
+ handleInputConfirm = () => {
+ const { inputValue, tags } = this.state;
+ let { tempElements } = this.state;
+ if (inputValue) {
+ if (
+ tags.findIndex(i => i.tagName === inputValue) === -1 &&
+ tempElements.findIndex(i => i.tagName === inputValue) === -1
+ ) {
+ tempElements = [
+ ...tempElements,
+ { tagName: inputValue, isTagDeletable: true },
+ ];
+ } else {
+ message.warning('Tag already exists');
+ }
+ }
+ this.setState({
+ tempElements,
+ inputVisible: false,
+ inputValue: '',
+ });
+ };
+
+ handleSave = () => {
+ const config = this.props.context;
+ const { tempElements, tags } = this.state;
+ this.setState({
+ loading: true,
+ });
+
+ const data = tempElements.map(tag => tag.tagName);
+
+ axios
+ .post(
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ config.serverConfig.invoker.publisher +
+ '/applications/tags',
+ data,
+ )
+ .then(res => {
+ if (res.status === 200) {
+ notification.success({
+ message: 'Done!',
+ description: 'New tags were added successfully',
+ });
+
+ this.setState({
+ tags: [...tags, ...tempElements],
+ tempElements: [],
+ inputVisible: false,
+ inputValue: '',
+ loading: false,
+ isAddNewVisible: false,
+ });
+ }
+ })
+ .catch(error => {
+ handleApiError(error, 'Error occurred while trying to delete tag.');
this.setState({
- loading: true,
- isEditModalVisible: false,
- });
-
- axios.put(
- window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/tags/rename?from=" + currentlyEditingId + "&to=" + editingValue,
- {},
- ).then(res => {
- if (res.status === 200) {
- notification["success"]({
- message: "Done!",
- description:
- "Tag was edited successfully",
- });
-
- tags[tags.findIndex(i => i.tagName === currentlyEditingId)].tagName = editingValue;
-
- this.setState({
- tags: tags,
- loading: false,
- editingValue: null
- });
- }
-
- }).catch((error) => {
- handleApiError(error, "Error occurred while trying to edit tag.");
- this.setState({
- loading: false,
- editingValue: null
- });
+ loading: false,
});
-
-
- };
-
- handleEditInputChange = (e) => {
+ });
+ };
+
+ saveInputRef = input => (this.input = input);
+
+ closeEditModal = e => {
+ this.setState({
+ isEditModalVisible: false,
+ currentlyEditingId: null,
+ });
+ };
+
+ openEditModal = id => {
+ this.setState({
+ isEditModalVisible: true,
+ currentlyEditingId: id,
+ editingValue: id,
+ });
+ };
+
+ editItem = () => {
+ const config = this.props.context;
+
+ const { editingValue, currentlyEditingId, tags } = this.state;
+
+ this.setState({
+ loading: true,
+ isEditModalVisible: false,
+ });
+
+ axios
+ .put(
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ config.serverConfig.invoker.publisher +
+ '/applications/tags/rename?from=' +
+ currentlyEditingId +
+ '&to=' +
+ editingValue,
+ {},
+ )
+ .then(res => {
+ if (res.status === 200) {
+ notification.success({
+ message: 'Done!',
+ description: 'Tag was edited successfully',
+ });
+
+ tags[
+ tags.findIndex(i => i.tagName === currentlyEditingId)
+ ].tagName = editingValue;
+
+ this.setState({
+ tags: tags,
+ loading: false,
+ editingValue: null,
+ });
+ }
+ })
+ .catch(error => {
+ handleApiError(error, 'Error occurred while trying to edit tag.');
this.setState({
- editingValue: e.target.value
+ loading: false,
+ editingValue: null,
});
- };
-
- render() {
- const {tags, inputVisible, inputValue, tempElements, isAddNewVisible, forbiddenErrors} = this.state;
- const tagsElements = tags.map(this.renderElement);
- const temporaryElements = tempElements.map(this.renderTempElement);
- return (
-
- {(forbiddenErrors.tags) && (
-
+ });
+ };
+
+ handleEditInputChange = e => {
+ this.setState({
+ editingValue: e.target.value,
+ });
+ };
+
+ render() {
+ const {
+ tags,
+ inputVisible,
+ inputValue,
+ tempElements,
+ isAddNewVisible,
+ forbiddenErrors,
+ } = this.state;
+ const tagsElements = tags.map(this.renderElement);
+ const temporaryElements = tempElements.map(this.renderTempElement);
+ return (
+
+ {forbiddenErrors.tags && (
+
+ )}
+
+
+
+
+ Tags
+
+
+ {!isAddNewVisible && (
+
+ {
+ this.setState(
+ {
+ isAddNewVisible: true,
+ inputVisible: true,
+ },
+ () => this.input.focus(),
+ );
+ }}
+ htmlType="button"
+ >
+ Add
+
+
)}
-
-
-
-
- Tags
-
-
- {!isAddNewVisible &&
-
- {
- this.setState({
- isAddNewVisible: true,
- inputVisible: true
- }, () => this.input.focus())
- }} htmlType="button">Add
-
-
- }
-
-
- {isAddNewVisible &&
-
-
-
- {
- e.target.style = '';
- },
- }}
- leave={{opacity: 0, width: 0, scale: 0, duration: 200}}
- appear={false}>
- {temporaryElements}
-
- {inputVisible && (
-
- )}
- {!inputVisible && (
-
- New Tag
-
- )}
-
-
-
- {tempElements.length > 0 && (
-
-
- Save
-
-
-
- )}
- < Button
- onClick={this.handleCloseButton}
- size="small">
- Cancel
-
-
-
- }
-
-
- {
- e.target.style = '';
- },
- }}
- leave={{opacity: 0, width: 0, scale: 0, duration: 200}}
- appear={false}
- >
- {tagsElements}
-
-
-
-
- < Modal
- title="Edit"
- visible={this.state.isEditModalVisible}
- onCancel={this.closeEditModal}
- onOk={this.editItem}
- >
- this.editingInput = input}
- onChange={this.handleEditInputChange}/>
-
+
+
+ {isAddNewVisible && (
+
+
+
+ {
+ e.target.style = '';
+ },
+ }}
+ leave={{ opacity: 0, width: 0, scale: 0, duration: 200 }}
+ appear={false}
+ >
+ {temporaryElements}
+
+ {inputVisible && (
+
+ )}
+ {!inputVisible && (
+
+ New Tag
+
+ )}
+
+
+
+ {tempElements.length > 0 && (
+
+
+ Save
+
+
+
+ )}
+
+ Cancel
+
+
+
+ )}
+
+
+ {
+ e.target.style = '';
+ },
+ }}
+ leave={{ opacity: 0, width: 0, scale: 0, duration: 200 }}
+ appear={false}
+ >
+ {tagsElements}
+
- );
- }
+
+
+
+ (this.editingInput = input)}
+ onChange={this.handleEditInputChange}
+ />
+
+
+ );
+ }
}
export default withConfigContext(ManageTags);
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 39dc99ddb1..6be5ab1653 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
@@ -16,209 +16,231 @@
* under the License.
*/
-import React from "react";
-import {
- Card,
- Button,
- Steps,
- Row,
- Col,
- Form,
- Result,
- notification,
- Spin
-} from "antd";
-import axios from "axios";
-import {withRouter} from 'react-router-dom';
-import NewAppDetailsForm from "./subForms/NewAppDetailsForm";
-import NewAppUploadForm from "./subForms/NewAppUploadForm";
-import {withConfigContext} from "../../context/ConfigContext";
-import {handleApiError} from "../../js/Utils";
-
-const {Step} = Steps;
+import React from 'react';
+import { Card, Button, Steps, Row, Col, Form, Result, Spin } from 'antd';
+import axios from 'axios';
+import { withRouter } from 'react-router-dom';
+import NewAppDetailsForm from './subForms/NewAppDetailsForm';
+import NewAppUploadForm from './subForms/NewAppUploadForm';
+import { withConfigContext } from '../../context/ConfigContext';
+import { handleApiError } from '../../js/Utils';
+const { Step } = Steps;
class AddNewAppFormComponent extends React.Component {
-
- constructor(props) {
- super(props);
- this.state = {
- current: 0,
- categories: [],
- tags: [],
- icons: [],
- screenshots: [],
- loading: false,
- binaryFiles: [],
- application: null,
- release: null,
- isError: false,
- deviceType: null,
- supportedOsVersions: [],
- errorText: "",
- forbiddenErrors: {
- supportedOsVersions: false
- }
- };
+ constructor(props) {
+ super(props);
+ this.state = {
+ current: 0,
+ categories: [],
+ tags: [],
+ icons: [],
+ screenshots: [],
+ loading: false,
+ binaryFiles: [],
+ application: null,
+ release: null,
+ isError: false,
+ deviceType: null,
+ supportedOsVersions: [],
+ errorText: '',
+ forbiddenErrors: {
+ supportedOsVersions: false,
+ },
+ };
+ }
+
+ onSuccessApplicationData = application => {
+ const { formConfig } = this.props;
+ if (
+ application.hasOwnProperty('deviceType') &&
+ formConfig.installationType !== 'WEB_CLIP' &&
+ formConfig.installationType !== 'CUSTOM'
+ ) {
+ this.getSupportedOsVersions(application.deviceType);
}
-
- onSuccessApplicationData = (application) => {
- const {formConfig} = this.props;
- if (application.hasOwnProperty("deviceType") &&
- formConfig.installationType !== "WEB_CLIP" &&
- formConfig.installationType !== "CUSTOM") {
- this.getSupportedOsVersions(application.deviceType);
+ this.setState({
+ application,
+ current: 1,
+ });
+ };
+
+ onSuccessReleaseData = releaseData => {
+ const config = this.props.context;
+ this.setState({
+ loading: true,
+ isError: false,
+ });
+ const { application } = this.state;
+ const { data, release } = releaseData;
+ const { formConfig } = this.props;
+ const { price } = release;
+
+ application.subMethod = price === 0 ? 'FREE' : 'PAID';
+ // add release wrapper
+ application[formConfig.releaseWrapperName] = [release];
+
+ const json = JSON.stringify(application);
+ const blob = new Blob([json], {
+ type: 'application/json',
+ });
+ data.append(formConfig.jsonPayloadName, blob);
+
+ const url =
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ config.serverConfig.invoker.publisher +
+ '/applications' +
+ formConfig.endpoint;
+
+ axios
+ .post(url, data)
+ .then(res => {
+ if (res.status === 201) {
+ this.setState({
+ loading: false,
+ current: 2,
+ });
+ } else {
+ this.setState({
+ loading: false,
+ isError: true,
+ current: 2,
+ });
}
+ })
+ .catch(error => {
+ handleApiError(error, error.response.data.data);
this.setState({
- application,
- current: 1
- });
- };
-
- onSuccessReleaseData = (releaseData) => {
- const config = this.props.context;
- this.setState({
- loading: true,
- isError: false
- });
- const {application} = this.state;
- const {data, release} = releaseData;
- const {formConfig} = this.props;
- const {price} = release;
-
- application.subMethod = (price === 0) ? "FREE" : "PAID";
- //add release wrapper
- application[formConfig.releaseWrapperName] = [release];
-
- const json = JSON.stringify(application);
- const blob = new Blob([json], {
- type: 'application/json'
- });
- data.append(formConfig.jsonPayloadName, blob);
-
- const url = window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications" + formConfig.endpoint;
-
- axios.post(
- url,
- data
- ).then(res => {
- if (res.status === 201) {
- this.setState({
- loading: false,
- current: 2
- });
- } else {
- this.setState({
- loading: false,
- isError: true,
- current: 2
- });
- }
-
- }).catch((error) => {
- handleApiError(error, error.response.data.data);
- this.setState({
- loading: false,
- isError: true,
- current: 2,
- errorText: error.response.data.data
- });
+ loading: false,
+ isError: true,
+ current: 2,
+ errorText: error.response.data.data,
});
-
- };
-
- onClickBackButton = () => {
- const current = this.state.current - 1;
- this.setState({current});
- };
-
- getSupportedOsVersions = (deviceType) => {
- const config = this.props.context;
- axios.get(
- window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt +
- `/admin/device-types/${deviceType}/versions`
- ).then(res => {
- if (res.status === 200) {
- let supportedOsVersions = JSON.parse(res.data.data);
- this.setState({
- supportedOsVersions,
- loading: false,
- });
- }
- }).catch((error) => {
- handleApiError(error, "Error occurred while trying to load supported OS versions.", true);
- if (error.hasOwnProperty("response") && error.response.status === 403) {
- const {forbiddenErrors} = this.state;
- forbiddenErrors.supportedOsVersions = true;
- this.setState({
- forbiddenErrors,
- loading: false
- })
- } else {
- this.setState({
- loading: false
- });
- }
- });
- };
-
- render() {
- const {loading, current, isError, supportedOsVersions, errorText, forbiddenErrors} = this.state;
- const {formConfig} = this.props;
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {!isError && ( this.props.history.push('/publisher/apps')}>
- Go to applications
-
- ]}
- />)}
-
- {isError && (Back}
- />)}
-
-
-
-
-
-
-
+ });
+ };
+
+ onClickBackButton = () => {
+ const current = this.state.current - 1;
+ this.setState({ current });
+ };
+
+ getSupportedOsVersions = deviceType => {
+ const config = this.props.context;
+ axios
+ .get(
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ config.serverConfig.invoker.deviceMgt +
+ `/admin/device-types/${deviceType}/versions`,
+ )
+ .then(res => {
+ if (res.status === 200) {
+ let supportedOsVersions = JSON.parse(res.data.data);
+ this.setState({
+ supportedOsVersions,
+ loading: false,
+ });
+ }
+ })
+ .catch(error => {
+ handleApiError(
+ error,
+ 'Error occurred while trying to load supported OS versions.',
+ true,
);
- }
+ if (error.hasOwnProperty('response') && error.response.status === 403) {
+ const { forbiddenErrors } = this.state;
+ forbiddenErrors.supportedOsVersions = true;
+ this.setState({
+ forbiddenErrors,
+ loading: false,
+ });
+ } else {
+ this.setState({
+ loading: false,
+ });
+ }
+ });
+ };
+
+ render() {
+ const {
+ loading,
+ current,
+ isError,
+ supportedOsVersions,
+ errorText,
+ forbiddenErrors,
+ } = this.state;
+ const { formConfig } = this.props;
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {!isError && (
+
+ this.props.history.push('/publisher/apps')
+ }
+ >
+ Go to applications
+ ,
+ ]}
+ />
+ )}
+
+ {isError && (
+ Back
+ }
+ />
+ )}
+
+
+
+
+
+
+ );
+ }
}
-const AddNewAppForm = withRouter(Form.create({name: 'add-new-app'})(AddNewAppFormComponent));
+const AddNewAppForm = withRouter(
+ Form.create({ name: 'add-new-app' })(AddNewAppFormComponent),
+);
export default withConfigContext(AddNewAppForm);
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/new-app/subForms/NewAppDetailsForm.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/new-app/subForms/NewAppDetailsForm.js
index 36b5d4e79b..689a7436e3 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/new-app/subForms/NewAppDetailsForm.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/new-app/subForms/NewAppDetailsForm.js
@@ -16,430 +16,481 @@
* under the License.
*/
-import React from "react";
-import {Alert, Button, Col, Divider, Form, Icon, Input, notification, Row, Select, Spin, Switch, Upload} from "antd";
-import axios from "axios";
-import {withConfigContext} from "../../../context/ConfigContext";
-import {handleApiError} from "../../../js/Utils";
+import React from 'react';
+import { Alert, Button, Col, Form, Input, Row, Select, Spin } from 'antd';
+import axios from 'axios';
+import { withConfigContext } from '../../../context/ConfigContext';
+import { handleApiError } from '../../../js/Utils';
import debounce from 'lodash.debounce';
const formItemLayout = {
- labelCol: {
- xs: {span: 24},
- sm: {span: 5},
- },
- wrapperCol: {
- xs: {span: 24},
- sm: {span: 19},
- },
+ labelCol: {
+ xs: { span: 24 },
+ sm: { span: 5 },
+ },
+ wrapperCol: {
+ xs: { span: 24 },
+ sm: { span: 19 },
+ },
};
-const {Option} = Select;
-const {TextArea} = Input;
+const { Option } = Select;
+const { TextArea } = Input;
class NewAppDetailsForm extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ categories: [],
+ tags: [],
+ deviceTypes: [],
+ fetching: false,
+ roleSearchValue: [],
+ unrestrictedRoles: [],
+ forbiddenErrors: {
+ categories: false,
+ tags: false,
+ deviceTypes: false,
+ roles: false,
+ },
+ };
+ this.lastFetchId = 0;
+ this.fetchRoles = debounce(this.fetchRoles, 800);
+ }
- constructor(props) {
- super(props);
- this.state = {
- categories: [],
- tags: [],
- deviceTypes: [],
- fetching: false,
- roleSearchValue: [],
- unrestrictedRoles: [],
- forbiddenErrors: {
- categories: false,
- tags: false,
- deviceTypes: false,
- roles: false
- }
- };
- this.lastFetchId = 0;
- this.fetchRoles = debounce(this.fetchRoles, 800);
- }
-
- handleSubmit = e => {
- e.preventDefault();
- const {formConfig} = this.props;
- const {specificElements} = formConfig;
-
- this.props.form.validateFields((err, values) => {
- if (!err) {
- this.setState({
- loading: true
- });
- const {name, description, categories, tags, unrestrictedRoles} = values;
- const unrestrictedRolesData = [];
- unrestrictedRoles.map(val => {
- unrestrictedRolesData.push(val.key);
- });
- const application = {
- name,
- description,
- categories,
- tags,
- unrestrictedRoles: unrestrictedRolesData,
- };
-
- if (formConfig.installationType !== "WEB_CLIP") {
- application.deviceType = values.deviceType;
- } else {
- application.type = "WEB_CLIP";
- application.deviceType = "ALL";
- }
+ handleSubmit = e => {
+ e.preventDefault();
+ const { formConfig } = this.props;
- this.props.onSuccessApplicationData(application);
- }
+ this.props.form.validateFields((err, values) => {
+ if (!err) {
+ this.setState({
+ loading: true,
});
- };
+ const {
+ name,
+ description,
+ categories,
+ tags,
+ unrestrictedRoles,
+ } = values;
+ const unrestrictedRolesData = [];
+ unrestrictedRoles.map(val => {
+ unrestrictedRolesData.push(val.key);
+ });
+ const application = {
+ name,
+ description,
+ categories,
+ tags,
+ unrestrictedRoles: unrestrictedRolesData,
+ };
- componentDidMount() {
- this.getCategories();
- this.getTags();
- this.getDeviceTypes();
- }
+ if (formConfig.installationType !== 'WEB_CLIP') {
+ application.deviceType = values.deviceType;
+ } else {
+ application.type = 'WEB_CLIP';
+ application.deviceType = 'ALL';
+ }
- getCategories = () => {
- const config = this.props.context;
- axios.get(
- window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/categories"
- ).then(res => {
- if (res.status === 200) {
- let categories = JSON.parse(res.data.data);
- this.setState({
- categories: categories,
- loading: false
- });
- }
- }).catch((error) => {
- handleApiError(error, "Error occurred while trying to load categories.", true);
- if (error.hasOwnProperty("response") && error.response.status === 403) {
- const {forbiddenErrors} = this.state;
- forbiddenErrors.categories = true;
- this.setState({
- forbiddenErrors,
- loading: false
- })
- } else {
- this.setState({
- loading: false
- });
- }
- });
- };
+ this.props.onSuccessApplicationData(application);
+ }
+ });
+ };
- getTags = () => {
- const config = this.props.context;
- axios.get(
- window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/tags"
- ).then(res => {
- if (res.status === 200) {
- let tags = JSON.parse(res.data.data);
- this.setState({
- tags: tags,
- loading: false,
- });
- }
- }).catch((error) => {
- handleApiError(error, "Error occurred while trying to load tags.", true);
- if (error.hasOwnProperty("response") && error.response.status === 403) {
- const {forbiddenErrors} = this.state;
- forbiddenErrors.tags = true;
- this.setState({
- forbiddenErrors,
- loading: false
- })
- } else {
- this.setState({
- loading: false
- });
- }
- });
- };
+ componentDidMount() {
+ this.getCategories();
+ this.getTags();
+ this.getDeviceTypes();
+ }
- getDeviceTypes = () => {
- const config = this.props.context;
- const {formConfig} = this.props;
- const {installationType} = formConfig;
+ getCategories = () => {
+ const config = this.props.context;
+ axios
+ .get(
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ config.serverConfig.invoker.publisher +
+ '/applications/categories',
+ )
+ .then(res => {
+ if (res.status === 200) {
+ let categories = JSON.parse(res.data.data);
+ this.setState({
+ categories: categories,
+ loading: false,
+ });
+ }
+ })
+ .catch(error => {
+ handleApiError(
+ error,
+ 'Error occurred while trying to load categories.',
+ true,
+ );
+ if (error.hasOwnProperty('response') && error.response.status === 403) {
+ const { forbiddenErrors } = this.state;
+ forbiddenErrors.categories = true;
+ this.setState({
+ forbiddenErrors,
+ loading: false,
+ });
+ } else {
+ this.setState({
+ loading: false,
+ });
+ }
+ });
+ };
- axios.get(
- window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt + "/device-types"
- ).then(res => {
- if (res.status === 200) {
- const allDeviceTypes = JSON.parse(res.data.data);
- const mobileDeviceTypes = config.deviceTypes.mobileTypes;
- const allowedDeviceTypes = [];
+ getTags = () => {
+ const config = this.props.context;
+ axios
+ .get(
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ config.serverConfig.invoker.publisher +
+ '/applications/tags',
+ )
+ .then(res => {
+ if (res.status === 200) {
+ let tags = JSON.parse(res.data.data);
+ this.setState({
+ tags: tags,
+ loading: false,
+ });
+ }
+ })
+ .catch(error => {
+ handleApiError(
+ error,
+ 'Error occurred while trying to load tags.',
+ true,
+ );
+ if (error.hasOwnProperty('response') && error.response.status === 403) {
+ const { forbiddenErrors } = this.state;
+ forbiddenErrors.tags = true;
+ this.setState({
+ forbiddenErrors,
+ loading: false,
+ });
+ } else {
+ this.setState({
+ loading: false,
+ });
+ }
+ });
+ };
- // exclude mobile device types if installation type is custom
- if (installationType === "CUSTOM") {
- allDeviceTypes.forEach(deviceType => {
- if (!mobileDeviceTypes.includes(deviceType.name)) {
- allowedDeviceTypes.push(deviceType);
- }
- });
- } else {
- allDeviceTypes.forEach(deviceType => {
- if (mobileDeviceTypes.includes(deviceType.name)) {
- allowedDeviceTypes.push(deviceType);
- }
- });
- }
+ getDeviceTypes = () => {
+ const config = this.props.context;
+ const { formConfig } = this.props;
+ const { installationType } = formConfig;
- this.setState({
- deviceTypes: allowedDeviceTypes,
- loading: false,
- });
- }
- }).catch((error) => {
- handleApiError(error, "Error occurred while trying to load device types.", true);
- if (error.hasOwnProperty("response") && error.response.status === 403) {
- const {forbiddenErrors} = this.state;
- forbiddenErrors.deviceTypes = true;
- this.setState({
- forbiddenErrors,
- loading: false
- })
- } else {
- this.setState({
- loading: false
- });
- }
- });
- };
+ axios
+ .get(
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ config.serverConfig.invoker.deviceMgt +
+ '/device-types',
+ )
+ .then(res => {
+ if (res.status === 200) {
+ const allDeviceTypes = JSON.parse(res.data.data);
+ const mobileDeviceTypes = config.deviceTypes.mobileTypes;
+ const allowedDeviceTypes = [];
- fetchRoles = value => {
- const config = this.props.context;
- this.lastFetchId += 1;
- const fetchId = this.lastFetchId;
- this.setState({data: [], fetching: true});
+ // exclude mobile device types if installation type is custom
+ if (installationType === 'CUSTOM') {
+ allDeviceTypes.forEach(deviceType => {
+ if (!mobileDeviceTypes.includes(deviceType.name)) {
+ allowedDeviceTypes.push(deviceType);
+ }
+ });
+ } else {
+ allDeviceTypes.forEach(deviceType => {
+ if (mobileDeviceTypes.includes(deviceType.name)) {
+ allowedDeviceTypes.push(deviceType);
+ }
+ });
+ }
- axios.get(
- window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt + "/roles?filter=" + value,
- ).then(res => {
- if (res.status === 200) {
- if (fetchId !== this.lastFetchId) {
- // for fetch callback order
- return;
- }
+ this.setState({
+ deviceTypes: allowedDeviceTypes,
+ loading: false,
+ });
+ }
+ })
+ .catch(error => {
+ handleApiError(
+ error,
+ 'Error occurred while trying to load device types.',
+ true,
+ );
+ if (error.hasOwnProperty('response') && error.response.status === 403) {
+ const { forbiddenErrors } = this.state;
+ forbiddenErrors.deviceTypes = true;
+ this.setState({
+ forbiddenErrors,
+ loading: false,
+ });
+ } else {
+ this.setState({
+ loading: false,
+ });
+ }
+ });
+ };
- const data = res.data.data.roles.map(role => ({
- text: role,
- value: role,
- }));
+ fetchRoles = value => {
+ const config = this.props.context;
+ this.lastFetchId += 1;
+ const fetchId = this.lastFetchId;
+ this.setState({ data: [], fetching: true });
- this.setState({
- unrestrictedRoles: data,
- fetching: false
- });
- }
+ axios
+ .get(
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ config.serverConfig.invoker.deviceMgt +
+ '/roles?filter=' +
+ value,
+ )
+ .then(res => {
+ if (res.status === 200) {
+ if (fetchId !== this.lastFetchId) {
+ // for fetch callback order
+ return;
+ }
- }).catch((error) => {
- handleApiError(error, "Error occurred while trying to load roles.", true);
- if (error.hasOwnProperty("response") && error.response.status === 403) {
- const {forbiddenErrors} = this.state;
- forbiddenErrors.roles = true;
- this.setState({
- forbiddenErrors,
- fetching: false
- })
- } else {
- this.setState({
- fetching: false
- });
- }
- });
- };
+ const data = res.data.data.roles.map(role => ({
+ text: role,
+ value: role,
+ }));
- handleRoleSearch = roleSearchValue => {
- this.setState({
- roleSearchValue,
- unrestrictedRoles: [],
+ this.setState({
+ unrestrictedRoles: data,
fetching: false,
- });
- };
-
- render() {
- const {formConfig} = this.props;
- const {categories, tags, deviceTypes, fetching, roleSearchValue, unrestrictedRoles, forbiddenErrors} = this.state;
- const {getFieldDecorator} = this.props.form;
+ });
+ }
+ })
+ .catch(error => {
+ handleApiError(
+ error,
+ 'Error occurred while trying to load roles.',
+ true,
+ );
+ if (error.hasOwnProperty('response') && error.response.status === 403) {
+ const { forbiddenErrors } = this.state;
+ forbiddenErrors.roles = true;
+ this.setState({
+ forbiddenErrors,
+ fetching: false,
+ });
+ } else {
+ this.setState({
+ fetching: false,
+ });
+ }
+ });
+ };
- return (
-
-
-
+ handleRoleSearch = roleSearchValue => {
+ this.setState({
+ roleSearchValue,
+ unrestrictedRoles: [],
+ fetching: false,
+ });
+ };
-
-
-
- {getFieldDecorator('name', {
- rules: [{
- required: true,
- message: 'Please input a name'
- }],
- })(
-
- )}
-
+ return (
+
+
+
+
+
- {getFieldDecorator('description', {
- rules: [{
- required: true,
- message: 'Please enter a description'
- }],
- })(
-
+ {/* app name*/}
+
+ {getFieldDecorator('name', {
+ rules: [
+ {
+ required: true,
+ message: 'Please input a name',
+ },
+ ],
+ })( )}
+
- {/*Unrestricted Roles*/}
- {(forbiddenErrors.roles) && (
-
- )}
-
- {getFieldDecorator('unrestrictedRoles', {
- rules: [],
- initialValue: []
- })(
- : null}
- filterOption={false}
- onSearch={this.fetchRoles}
- onChange={this.handleRoleSearch}
- style={{width: '100%'}}>
- {unrestrictedRoles.map(d => (
- {d.text}
- ))}
-
- )}
-
- {(forbiddenErrors.categories) && (
-
- )}
-
- {getFieldDecorator('categories', {
- rules: [{
- required: true,
- message: 'Please select categories'
- }],
- })(
-
- {
- categories.map(category => {
- return (
-
- {category.categoryName}
-
- )
- })
- }
-
- )}
-
- {(forbiddenErrors.tags) && (
-
- )}
-
- {getFieldDecorator('tags', {
- rules: [{
- required: true,
- message: 'Please select tags'
- }],
- })(
-
- {
- tags.map(tag => {
- return (
-
- {tag.tagName}
-
- )
- })
- }
-
- )}
-
-
-
- Next
-
-
-
-
-
-
- );
- }
+ {/* description*/}
+
+ {getFieldDecorator('description', {
+ rules: [
+ {
+ required: true,
+ message: 'Please enter a description',
+ },
+ ],
+ })(
+ ,
+ )}
+
+ {/* Unrestricted Roles*/}
+ {forbiddenErrors.roles && (
+
+ )}
+
+ {getFieldDecorator('unrestrictedRoles', {
+ rules: [],
+ initialValue: [],
+ })(
+ : null}
+ filterOption={false}
+ onSearch={this.fetchRoles}
+ onChange={this.handleRoleSearch}
+ style={{ width: '100%' }}
+ >
+ {unrestrictedRoles.map(d => (
+ {d.text}
+ ))}
+ ,
+ )}
+
+ {forbiddenErrors.categories && (
+
+ )}
+
+ {getFieldDecorator('categories', {
+ rules: [
+ {
+ required: true,
+ message: 'Please select categories',
+ },
+ ],
+ })(
+
+ {categories.map(category => {
+ return (
+
+ {category.categoryName}
+
+ );
+ })}
+ ,
+ )}
+
+ {forbiddenErrors.tags && (
+
+ )}
+
+ {getFieldDecorator('tags', {
+ rules: [
+ {
+ required: true,
+ message: 'Please select tags',
+ },
+ ],
+ })(
+
+ {tags.map(tag => {
+ return {tag.tagName} ;
+ })}
+ ,
+ )}
+
+
+
+ Next
+
+
+
+
+
+
+ );
+ }
}
-export default withConfigContext(Form.create({name: 'app-details-form'})(NewAppDetailsForm));
+export default withConfigContext(
+ Form.create({ name: 'app-details-form' })(NewAppDetailsForm),
+);
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 0e53290397..6e1f0ec7de 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
@@ -16,550 +16,617 @@
* under the License.
*/
-import React from "react";
-import {Button, Col, Form, Icon, Input, Row, Select, Switch, Upload, Typography, Modal, Alert, Tooltip} from "antd";
-import "@babel/polyfill";
+import React from 'react';
+import {
+ Button,
+ Col,
+ Form,
+ Icon,
+ Input,
+ Row,
+ Select,
+ Upload,
+ Typography,
+ Modal,
+ Alert,
+} from 'antd';
+import '@babel/polyfill';
-const {Text} = Typography;
+const { Text } = Typography;
const formItemLayout = {
- labelCol: {
- xs: {span: 24},
- sm: {span: 8},
- },
- wrapperCol: {
- xs: {span: 24},
- sm: {span: 16},
- },
+ labelCol: {
+ xs: { span: 24 },
+ sm: { span: 8 },
+ },
+ wrapperCol: {
+ xs: { span: 24 },
+ sm: { span: 16 },
+ },
};
-const {Option} = Select;
-const {TextArea} = Input;
+const { Option } = Select;
+const { TextArea } = Input;
const InputGroup = Input.Group;
function getBase64(file) {
- return new Promise((resolve, reject) => {
- const reader = new FileReader();
- reader.readAsDataURL(file);
- reader.onload = () => resolve(reader.result);
- reader.onerror = error => reject(error);
- });
+ return new Promise((resolve, reject) => {
+ const reader = new FileReader();
+ reader.readAsDataURL(file);
+ reader.onload = () => resolve(reader.result);
+ reader.onerror = error => reject(error);
+ });
}
class NewAppUploadForm extends React.Component {
-
- constructor(props) {
- super(props);
- this.state = {
- icons: [],
- screenshots: [],
- loading: false,
- binaryFiles: [],
- application: null,
- isFree: true,
- previewVisible: false,
- previewImage: '',
- binaryFileHelperText: '',
- iconHelperText: '',
- screenshotHelperText: '',
- osVersionsHelperText: '',
- osVersionsValidateStatus: 'validating',
- metaData: []
- };
- this.lowerOsVersion = null;
- this.upperOsVersion = null;
- }
-
- normFile = e => {
- if (Array.isArray(e)) {
- return e;
- }
- return e && e.fileList;
+ constructor(props) {
+ super(props);
+ this.state = {
+ icons: [],
+ screenshots: [],
+ loading: false,
+ binaryFiles: [],
+ application: null,
+ isFree: true,
+ previewVisible: false,
+ previewImage: '',
+ binaryFileHelperText: '',
+ iconHelperText: '',
+ screenshotHelperText: '',
+ osVersionsHelperText: '',
+ osVersionsValidateStatus: 'validating',
+ metaData: [],
};
+ this.lowerOsVersion = null;
+ this.upperOsVersion = null;
+ }
- handleSubmit = e => {
- e.preventDefault();
- const {formConfig} = this.props;
- const {specificElements} = formConfig;
+ normFile = e => {
+ if (Array.isArray(e)) {
+ return e;
+ }
+ return e && e.fileList;
+ };
- this.props.form.validateFields((err, values) => {
- if (!err) {
- this.setState({
- loading: true
- });
- const {price, isSharedWithAllTenants, binaryFile, icon, screenshots, releaseDescription, releaseType} = values;
+ handleSubmit = e => {
+ e.preventDefault();
+ const { formConfig } = this.props;
+ const { specificElements } = formConfig;
- //add release data
- const release = {
- description: releaseDescription,
- price: 0,
- isSharedWithAllTenants: false,
- metaData: JSON.stringify(this.state.metaData),
- releaseType: releaseType
- };
+ this.props.form.validateFields((err, values) => {
+ if (!err) {
+ this.setState({
+ loading: true,
+ });
+ const {
+ binaryFile,
+ icon,
+ screenshots,
+ releaseDescription,
+ releaseType,
+ } = values;
- if (specificElements.hasOwnProperty("version")) {
- release.version = values.version;
- }
- if (specificElements.hasOwnProperty("url")) {
- release.url = values.url;
- }
- if (specificElements.hasOwnProperty("packageName")) {
- release.packageName = values.packageName;
- }
+ // add release data
+ const release = {
+ description: releaseDescription,
+ price: 0,
+ isSharedWithAllTenants: false,
+ metaData: JSON.stringify(this.state.metaData),
+ releaseType: releaseType,
+ };
- const data = new FormData();
- let isFormValid = true; // flag to check if this form is valid
+ 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 (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 (parseFloat(this.lowerOsVersion) >= parseFloat(this.upperOsVersion)) {
- isFormValid = false;
- this.setState({
- osVersionsHelperText: 'Please select valid range',
- osVersionsValidateStatus: 'error',
- });
- } else {
- release.supportedOsVersions = `${this.lowerOsVersion}-${this.upperOsVersion}`;
- }
- }
+ const data = new FormData();
+ let isFormValid = true; // flag to check if this form is valid
- if (specificElements.hasOwnProperty("binaryFile") && this.state.binaryFiles.length !== 1) {
- isFormValid = false;
- this.setState({
- binaryFileHelperText: 'Please select the application'
- });
- }
- if (this.state.icons.length !== 1) {
- isFormValid = false;
- this.setState({
- iconHelperText: 'Please select an icon'
- });
- }
- 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'
- });
- }
- if (isFormValid) {
- 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")) {
- data.append('binaryFile', binaryFile[0].originFileObj);
- }
- this.props.onSuccessReleaseData({data, release});
- }
- }
- });
- };
-
- handleIconChange = ({fileList}) => {
- if (fileList.length === 1) {
+ if (
+ formConfig.installationType !== 'WEB_CLIP' &&
+ formConfig.installationType !== 'CUSTOM'
+ ) {
+ if (this.lowerOsVersion == null || this.upperOsVersion == null) {
+ isFormValid = false;
this.setState({
- iconHelperText: ''
+ osVersionsHelperText: 'Please select supported OS versions',
+ osVersionsValidateStatus: 'error',
});
- }
- this.setState({
- icons: fileList
- });
- };
- handleBinaryFileChange = ({fileList}) => {
- if (fileList.length === 1) {
+ } else if (
+ parseFloat(this.lowerOsVersion) >= parseFloat(this.upperOsVersion)
+ ) {
+ isFormValid = false;
this.setState({
- binaryFileHelperText: ''
+ osVersionsHelperText: 'Please select valid range',
+ osVersionsValidateStatus: 'error',
});
+ } else {
+ release.supportedOsVersions = `${this.lowerOsVersion}-${this.upperOsVersion}`;
+ }
}
- this.setState({binaryFiles: fileList});
- };
- handleScreenshotChange = ({fileList}) => {
- if (fileList.length === 3) {
- this.setState({
- screenshotHelperText: ''
- });
+ if (
+ specificElements.hasOwnProperty('binaryFile') &&
+ this.state.binaryFiles.length !== 1
+ ) {
+ isFormValid = false;
+ this.setState({
+ binaryFileHelperText: 'Please select the application',
+ });
}
- this.setState({
- screenshots: fileList
- });
- };
-
- handlePreviewCancel = () => this.setState({previewVisible: false});
- handlePreview = async file => {
- if (!file.url && !file.preview) {
- file.preview = await getBase64(file.originFileObj);
+ if (this.state.icons.length !== 1) {
+ isFormValid = false;
+ this.setState({
+ iconHelperText: 'Please select an icon',
+ });
+ }
+ 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',
+ });
+ }
+ if (isFormValid) {
+ 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')) {
+ data.append('binaryFile', binaryFile[0].originFileObj);
+ }
+ this.props.onSuccessReleaseData({ data, release });
}
+ }
+ });
+ };
- this.setState({
- previewImage: file.url || file.preview,
- previewVisible: true,
- });
- };
+ handleIconChange = ({ fileList }) => {
+ if (fileList.length === 1) {
+ this.setState({
+ iconHelperText: '',
+ });
+ }
+ this.setState({
+ icons: fileList,
+ });
+ };
+ handleBinaryFileChange = ({ fileList }) => {
+ if (fileList.length === 1) {
+ this.setState({
+ binaryFileHelperText: '',
+ });
+ }
+ this.setState({ binaryFiles: fileList });
+ };
- addNewMetaData = () => {
- this.setState({
- metaData: this.state.metaData.concat({'key': '', 'value': ''})
- })
- };
+ handleScreenshotChange = ({ fileList }) => {
+ if (fileList.length === 3) {
+ this.setState({
+ screenshotHelperText: '',
+ });
+ }
+ this.setState({
+ screenshots: fileList,
+ });
+ };
- handleLowerOsVersionChange = (lowerOsVersion) => {
- this.lowerOsVersion = lowerOsVersion;
- this.setState({
- osVersionsValidateStatus: 'validating',
- osVersionsHelperText: ''
- });
- };
+ handlePreviewCancel = () => this.setState({ previewVisible: false });
+ handlePreview = async file => {
+ if (!file.url && !file.preview) {
+ file.preview = await getBase64(file.originFileObj);
+ }
- handleUpperOsVersionChange = (upperOsVersion) => {
- if (upperOsVersion === "all") {
- this.upperOsVersion = this.props.supportedOsVersions[this.props.supportedOsVersions.length - 1]["versionName"];
- } else {
- this.upperOsVersion = upperOsVersion;
- }
- this.setState({
- osVersionsValidateStatus: 'validating',
- osVersionsHelperText: ''
- });
- };
+ this.setState({
+ previewImage: file.url || file.preview,
+ previewVisible: true,
+ });
+ };
- render() {
- const {formConfig, supportedOsVersions} = this.props;
- const {getFieldDecorator} = this.props.form;
- const {
- icons,
- screenshots,
- binaryFiles,
- previewImage,
- previewVisible,
- binaryFileHelperText,
- iconHelperText,
- screenshotHelperText,
- metaData,
- osVersionsHelperText,
- osVersionsValidateStatus
- } = this.state;
- const uploadButton = (
-
- );
+ addNewMetaData = () => {
+ this.setState({
+ metaData: this.state.metaData.concat({ key: '', value: '' }),
+ });
+ };
- return (
-
-
-
+ handleLowerOsVersionChange = lowerOsVersion => {
+ this.lowerOsVersion = lowerOsVersion;
+ this.setState({
+ osVersionsValidateStatus: 'validating',
+ osVersionsHelperText: '',
+ });
+ };
-
-
-
- {getFieldDecorator('binaryFile', {
- valuePropName: 'binaryFile',
- getValueFromEvent: this.normFile,
- required: true,
- message: 'Please select application'
- })(
- false}>
- {binaryFiles.length !== 1 && (
-
- Click to upload
-
- )}
- ,
- )}
-
- )}
+ handleUpperOsVersionChange = upperOsVersion => {
+ if (upperOsVersion === 'all') {
+ this.upperOsVersion = this.props.supportedOsVersions[
+ this.props.supportedOsVersions.length - 1
+ ].versionName;
+ } else {
+ this.upperOsVersion = upperOsVersion;
+ }
+ this.setState({
+ osVersionsValidateStatus: 'validating',
+ osVersionsHelperText: '',
+ });
+ };
-
- {getFieldDecorator('icon', {
- valuePropName: 'icon',
- getValueFromEvent: this.normFile,
- required: true,
- message: 'Please select a icon'
- })(
- false}
- onPreview={this.handlePreview}>
- {icons.length === 1 ? null : uploadButton}
-
- )}
-
-
-
-
-
-
- Recommended : 240px x 240px
-
-
-
-
- {getFieldDecorator('screenshots', {
- valuePropName: 'icon',
- getValueFromEvent: this.normFile,
- required: true,
- message: 'Please select a icon'
- })(
- false}
- onPreview={this.handlePreview}>
- {screenshots.length >= 3 ? null : uploadButton}
-
- )}
-
-
-
-
-
-
- It is mandatory to upload three screenshots and the
- recommended screenshot size - min. 320px max. 3840px.
-
-
-
- {formConfig.specificElements.hasOwnProperty("packageName") && (
-
- {getFieldDecorator('packageName', {
- rules: [{
- required: true,
- message: 'Please input the package name'
- }],
- })(
-
- )}
-
- )}
+ render() {
+ const { formConfig, supportedOsVersions } = this.props;
+ const { getFieldDecorator } = this.props.form;
+ const {
+ icons,
+ screenshots,
+ binaryFiles,
+ previewImage,
+ previewVisible,
+ binaryFileHelperText,
+ iconHelperText,
+ screenshotHelperText,
+ metaData,
+ osVersionsHelperText,
+ osVersionsValidateStatus,
+ } = this.state;
+ const uploadButton = (
+
+ );
- {formConfig.specificElements.hasOwnProperty("url") && (
-
- {getFieldDecorator('url', {
- rules: [{
- required: true,
- message: 'Please input the url'
- }],
- })(
-
- )}
-
- )}
+ return (
+
+
+
+
+
+ {getFieldDecorator('binaryFile', {
+ valuePropName: 'binaryFile',
+ getValueFromEvent: this.normFile,
+ required: true,
+ message: 'Please select application',
+ })(
+ false}
+ >
+ {binaryFiles.length !== 1 && (
+
+ Click to upload
+
+ )}
+ ,
+ )}
+
+ )}
- {formConfig.specificElements.hasOwnProperty("version") && (
-
- {getFieldDecorator('version', {
- rules: [{
- required: true,
- message: 'Please input the version'
- }],
- })(
-
- )}
-
- )}
+
+ {getFieldDecorator('icon', {
+ valuePropName: 'icon',
+ getValueFromEvent: this.normFile,
+ required: true,
+ message: 'Please select a icon',
+ })(
+ false}
+ onPreview={this.handlePreview}
+ >
+ {icons.length === 1 ? null : uploadButton}
+ ,
+ )}
+
+
+
+
+ Recommended : 240px x 240px
+
+
+
+ {getFieldDecorator('screenshots', {
+ valuePropName: 'icon',
+ getValueFromEvent: this.normFile,
+ required: true,
+ message: 'Please select a icon',
+ })(
+ false}
+ onPreview={this.handlePreview}
+ >
+ {screenshots.length >= 3 ? null : uploadButton}
+ ,
+ )}
+
+
+
+
+
+ It is mandatory to upload three screenshots and the
+ recommended screenshot size - min. 320px max. 3840px.
+
+
+
+ {formConfig.specificElements.hasOwnProperty('packageName') && (
+
+ {getFieldDecorator('packageName', {
+ rules: [
+ {
+ required: true,
+ message: 'Please input the package name',
+ },
+ ],
+ })( )}
+
+ )}
-
- {getFieldDecorator('releaseType', {
- rules: [{
- required: true,
- message: 'Please input the Release Type'
- }],
- })(
-
- )}
-
+ {formConfig.specificElements.hasOwnProperty('url') && (
+
+ {getFieldDecorator('url', {
+ rules: [
+ {
+ required: true,
+ message: 'Please input the url',
+ },
+ ],
+ })( )}
+
+ )}
-
- {getFieldDecorator('releaseDescription', {
- rules: [{
- required: true,
- message: 'Please enter a description for release'
- }],
- })(
-
+ {formConfig.specificElements.hasOwnProperty('version') && (
+
+ {getFieldDecorator('version', {
+ rules: [
+ {
+ required: true,
+ message: 'Please input the version',
+ },
+ ],
+ })( )}
+
+ )}
- {(formConfig.installationType !== "WEB_CLIP" && formConfig.installationType !== "CUSTOM") && (
-
- {(this.props.forbiddenErrors.supportedOsVersions) && (
-
- )}
-
- {getFieldDecorator('supportedOS', {
- rules: [{
- required: true
- }],
- initialValue: false
- })(
-
-
-
-
-
- {supportedOsVersions.map(version => (
-
- {version.versionName}
-
- ))}
-
-
-
- -
-
-
-
- {(supportedOsVersions.length > 0) && (
-
- All
-
- )}
- {supportedOsVersions.map(version => (
-
- {version.versionName}
-
- ))}
-
-
-
-
-
- )}
-
-
- )}
-
- {getFieldDecorator('meta', {})(
-
- {
- metaData.map((data, index) => {
- return (
-
-
-
- {
- metaData[index]['key'] = e.currentTarget.value;
- this.setState({
- metaData
- })
- }}/>
-
-
- {
- metaData[index].value = e.currentTarget.value;
- this.setState({
- metaData
- });
- }}/>
-
-
- {
- metaData.splice(index, 1);
- this.setState({
- metaData
- });
- }}/>
-
-
-
- )
- }
- )
- }
-
- Add
-
-
- )}
-
-
-
- Submit
-
-
-
-
- Back
-
-
-
-
-
-
-
-
-
- );
- }
+
+ {getFieldDecorator('releaseType', {
+ rules: [
+ {
+ required: true,
+ message: 'Please input the Release Type',
+ },
+ ],
+ })( )}
+
+
+
+ {getFieldDecorator('releaseDescription', {
+ rules: [
+ {
+ required: true,
+ message: 'Please enter a description for release',
+ },
+ ],
+ })(
+ ,
+ )}
+
+
+ {formConfig.installationType !== 'WEB_CLIP' &&
+ formConfig.installationType !== 'CUSTOM' && (
+
+ {this.props.forbiddenErrors.supportedOsVersions && (
+
+ )}
+
+ {getFieldDecorator('supportedOS', {
+ rules: [
+ {
+ required: true,
+ },
+ ],
+ initialValue: false,
+ })(
+
+
+
+
+
+ {supportedOsVersions.map(version => (
+
+ {version.versionName}
+
+ ))}
+
+
+
+ -
+
+
+
+ {supportedOsVersions.length > 0 && (
+
+ All
+
+ )}
+ {supportedOsVersions.map(version => (
+
+ {version.versionName}
+
+ ))}
+
+
+
+
+
,
+ )}
+
+
+ )}
+
+ {getFieldDecorator('meta', {})(
+
+ {metaData.map((data, index) => {
+ return (
+
+
+
+ {
+ metaData[index].key = e.currentTarget.value;
+ this.setState({
+ metaData,
+ });
+ }}
+ />
+
+
+ {
+ metaData[index].value = e.currentTarget.value;
+ this.setState({
+ metaData,
+ });
+ }}
+ />
+
+
+ {
+ metaData.splice(index, 1);
+ this.setState({
+ metaData,
+ });
+ }}
+ />
+
+
+
+ );
+ })}
+
+ Add
+
+
,
+ )}
+
+
+
+ Submit
+
+
+
+
+ Back
+
+
+
+
+
+
+
+
+
+ );
+ }
}
-export default (Form.create({name: 'app-upload-form'})(NewAppUploadForm));
\ No newline at end of file
+export default Form.create({ name: 'app-upload-form' })(NewAppUploadForm);
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 abaea5dbe9..ea0ce20b2c 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
@@ -16,146 +16,162 @@
* under the License.
*/
-import React from "react";
-import {Form, notification, Spin, Card, Row, Col} from "antd";
-import axios from "axios";
-import {withRouter} from 'react-router-dom'
-import {withConfigContext} from "../../context/ConfigContext";
-import {handleApiError} from "../../js/Utils";
-import NewAppUploadForm from "../new-app/subForms/NewAppUploadForm";
+import React from 'react';
+import { Form, notification, Spin, Card, Row, Col } from 'antd';
+import axios from 'axios';
+import { withRouter } from 'react-router-dom';
+import { withConfigContext } from '../../context/ConfigContext';
+import { handleApiError } from '../../js/Utils';
+import NewAppUploadForm from '../new-app/subForms/NewAppUploadForm';
const formConfig = {
- specificElements: {
- binaryFile: {
- required: true
- }
- }
+ specificElements: {
+ binaryFile: {
+ required: true,
+ },
+ },
};
class AddNewReleaseFormComponent extends React.Component {
-
- constructor(props) {
- super(props);
- this.state = {
- loading: false,
- supportedOsVersions: [],
- application: null,
- release: null,
- deviceType: null,
- forbiddenErrors: {
- supportedOsVersions: false
- }
- };
- }
-
- componentDidMount() {
- this.getSupportedOsVersions(this.props.deviceType);
- }
-
- getSupportedOsVersions = (deviceType) => {
- const config = this.props.context;
- axios.get(
- window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt +
- `/admin/device-types/${deviceType}/versions`
- ).then(res => {
- if (res.status === 200) {
- let supportedOsVersions = JSON.parse(res.data.data);
- this.setState({
- supportedOsVersions,
- loading: false,
- });
- }
- }).catch((error) => {
- handleApiError(error, "Error occurred while trying to load supported OS versions.", true);
- if (error.hasOwnProperty("response") && error.response.status === 403) {
- const {forbiddenErrors} = this.state;
- forbiddenErrors.supportedOsVersions = true;
- this.setState({
- forbiddenErrors,
- loading: false
- })
- } else {
- this.setState({
- loading: false
- });
- }
- });
+ constructor(props) {
+ super(props);
+ this.state = {
+ loading: false,
+ supportedOsVersions: [],
+ application: null,
+ release: null,
+ deviceType: null,
+ forbiddenErrors: {
+ supportedOsVersions: false,
+ },
};
+ }
- onSuccessReleaseData = (releaseData) => {
- const config = this.props.context;
- const {appId, deviceType} = this.props;
- this.setState({
- loading: true
- });
- const {data, release} = releaseData;
+ componentDidMount() {
+ this.getSupportedOsVersions(this.props.deviceType);
+ }
- const json = JSON.stringify(release);
- const blob = new Blob([json], {
- type: 'application/json'
- });
- data.append("applicationRelease", blob);
+ getSupportedOsVersions = deviceType => {
+ const config = this.props.context;
+ axios
+ .get(
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ config.serverConfig.invoker.deviceMgt +
+ `/admin/device-types/${deviceType}/versions`,
+ )
+ .then(res => {
+ if (res.status === 200) {
+ let supportedOsVersions = JSON.parse(res.data.data);
+ this.setState({
+ supportedOsVersions,
+ loading: false,
+ });
+ }
+ })
+ .catch(error => {
+ handleApiError(
+ error,
+ 'Error occurred while trying to load supported OS versions.',
+ true,
+ );
+ if (error.hasOwnProperty('response') && error.response.status === 403) {
+ const { forbiddenErrors } = this.state;
+ forbiddenErrors.supportedOsVersions = true;
+ this.setState({
+ forbiddenErrors,
+ loading: false,
+ });
+ } else {
+ this.setState({
+ loading: false,
+ });
+ }
+ });
+ };
- const url = window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher +
- "/applications/" + deviceType + "/ent-app/" + appId;
- axios.post(
- url,
- data
- ).then(res => {
- if (res.status === 201) {
- this.setState({
- loading: false,
- });
+ onSuccessReleaseData = releaseData => {
+ const config = this.props.context;
+ const { appId, deviceType } = this.props;
+ this.setState({
+ loading: true,
+ });
+ const { data, release } = releaseData;
- notification["success"]({
- message: "Done!",
- description:
- "New release was added successfully",
- });
- const uuid = res.data.data.uuid;
- this.props.history.push('/publisher/apps/releases/' + uuid);
+ const json = JSON.stringify(release);
+ const blob = new Blob([json], {
+ type: 'application/json',
+ });
+ data.append('applicationRelease', blob);
- } else {
- this.setState({
- loading: false
- });
- }
- }).catch((error) => {
- handleApiError(error, "Sorry, we were unable to complete your request.");
- this.setState({
- loading: false
- });
- });
+ const url =
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ config.serverConfig.invoker.publisher +
+ '/applications/' +
+ deviceType +
+ '/ent-app/' +
+ appId;
+ axios
+ .post(url, data)
+ .then(res => {
+ if (res.status === 201) {
+ this.setState({
+ loading: false,
+ });
- };
+ notification.success({
+ message: 'Done!',
+ description: 'New release was added successfully',
+ });
+ const uuid = res.data.data.uuid;
+ this.props.history.push('/publisher/apps/releases/' + uuid);
+ } else {
+ this.setState({
+ loading: false,
+ });
+ }
+ })
+ .catch(error => {
+ handleApiError(
+ error,
+ 'Sorry, we were unable to complete your request.',
+ );
+ this.setState({
+ loading: false,
+ });
+ });
+ };
- onClickBackButton = () => {
- this.props.history.push('/publisher/apps/');
- };
+ onClickBackButton = () => {
+ this.props.history.push('/publisher/apps/');
+ };
- render() {
- const {loading, supportedOsVersions, forbiddenErrors} = this.state;
- return (
-
-
-
-
-
-
-
-
-
-
-
- );
- }
+ render() {
+ const { loading, supportedOsVersions, forbiddenErrors } = this.state;
+ return (
+
+
+
+
+
+
+
+
+
+
+
+ );
+ }
}
-const AddReleaseForm = withRouter(Form.create({name: 'add-new-release'})(AddNewReleaseFormComponent));
+const AddReleaseForm = withRouter(
+ Form.create({ name: 'add-new-release' })(AddNewReleaseFormComponent),
+);
export default withConfigContext(AddReleaseForm);
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/context/ConfigContext.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/context/ConfigContext.js
index ea680a4cc5..e79fea42fd 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/context/ConfigContext.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/context/ConfigContext.js
@@ -16,19 +16,19 @@
* under the License.
*/
-import React from "react";
+import React from 'react';
const ConfigContext = React.createContext();
export const withConfigContext = Component => {
- return props => (
-
- {context => {
- return ;
- }}
-
- );
+ // eslint-disable-next-line react/display-name
+ return props => (
+
+ {context => {
+ return ;
+ }}
+
+ );
};
export default ConfigContext;
-
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js
index 4f7175a075..431572739f 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/index.js
@@ -19,91 +19,87 @@
import React from 'react';
import ReactDOM from 'react-dom';
import * as serviceWorker from './serviceWorker';
-import App from "./App";
-import Login from "./pages/Login";
-import Dashboard from "./pages/dashboard/Dashboard";
-import Apps from "./pages/dashboard/apps/Apps";
-import Release from "./pages/dashboard/apps/release/Release";
-import AddNewEnterpriseApp from "./pages/dashboard/add-new-app/AddNewEnterpriseApp";
-import Mange from "./pages/dashboard/manage/Manage";
+import App from './App';
+import Login from './pages/Login';
+import Dashboard from './pages/dashboard/Dashboard';
+import Apps from './pages/dashboard/apps/Apps';
+import Release from './pages/dashboard/apps/release/Release';
+import AddNewEnterpriseApp from './pages/dashboard/add-new-app/AddNewEnterpriseApp';
+import Mange from './pages/dashboard/manage/Manage';
import './index.css';
-import AddNewPublicApp from "./pages/dashboard/add-new-app/AddNewPublicApp";
-import AddNewWebClip from "./pages/dashboard/add-new-app/AddNewWebClip";
-import AddNewRelease from "./pages/dashboard/add-new-release/AddNewRelease";
-import AddNewCustomApp from "./pages/dashboard/add-new-app/AddNewCustomApp";
-import ManageAndroidEnterprise from "./pages/dashboard/manage/android-enterprise/ManageAndroidEnterprise";
-import Page from "./pages/dashboard/manage/android-enterprise/page/Page";
-
+import AddNewPublicApp from './pages/dashboard/add-new-app/AddNewPublicApp';
+import AddNewWebClip from './pages/dashboard/add-new-app/AddNewWebClip';
+import AddNewRelease from './pages/dashboard/add-new-release/AddNewRelease';
+import AddNewCustomApp from './pages/dashboard/add-new-app/AddNewCustomApp';
+import ManageAndroidEnterprise from './pages/dashboard/manage/android-enterprise/ManageAndroidEnterprise';
+import Page from './pages/dashboard/manage/android-enterprise/page/Page';
const routes = [
- {
- path: '/publisher/login',
+ {
+ path: '/publisher/login',
+ exact: true,
+ component: Login,
+ },
+ {
+ path: '/publisher/',
+ exact: false,
+ component: Dashboard,
+ routes: [
+ {
+ path: '/publisher/apps',
+ component: Apps,
+ exact: true,
+ },
+ {
+ path: '/publisher/apps/releases/:uuid',
+ exact: true,
+ component: Release,
+ },
+ {
+ path: '/publisher/apps/:deviceType/:appId/add-release',
+ component: AddNewRelease,
+ exact: true,
+ },
+ {
+ path: '/publisher/add-new-app/enterprise',
+ component: AddNewEnterpriseApp,
+ exact: true,
+ },
+ {
+ path: '/publisher/add-new-app/public',
+ component: AddNewPublicApp,
+ exact: true,
+ },
+ {
+ path: '/publisher/add-new-app/web-clip',
+ component: AddNewWebClip,
exact: true,
- component: Login
- },
- {
- path: '/publisher/',
- exact: false,
- component: Dashboard,
- routes: [
- {
- path: '/publisher/apps',
- component: Apps,
- exact: true
- },
- {
- path: '/publisher/apps/releases/:uuid',
- exact: true,
- component: Release
- },
- {
- path: '/publisher/apps/:deviceType/:appId/add-release',
- component: AddNewRelease,
- exact: true
- },
- {
- path: '/publisher/add-new-app/enterprise',
- component: AddNewEnterpriseApp,
- exact: true
- },
- {
- path: '/publisher/add-new-app/public',
- component: AddNewPublicApp,
- exact: true
- },
- {
- path: '/publisher/add-new-app/web-clip',
- component: AddNewWebClip,
- exact: true
- },
- {
- path: '/publisher/add-new-app/custom-app',
- component: AddNewCustomApp,
- exact: true
- },
- {
- path: '/publisher/manage',
- component: Mange,
- exact: true
- },
- {
- path: '/publisher/manage/android-enterprise',
- component: ManageAndroidEnterprise,
- exact: true
- },
- {
- path: '/publisher/manage/android-enterprise/pages/:pageName/:pageId',
- component: Page,
- exact: true
- }
- ]
- }
+ },
+ {
+ path: '/publisher/add-new-app/custom-app',
+ component: AddNewCustomApp,
+ exact: true,
+ },
+ {
+ path: '/publisher/manage',
+ component: Mange,
+ exact: true,
+ },
+ {
+ path: '/publisher/manage/android-enterprise',
+ component: ManageAndroidEnterprise,
+ exact: true,
+ },
+ {
+ path: '/publisher/manage/android-enterprise/pages/:pageName/:pageId',
+ component: Page,
+ exact: true,
+ },
+ ],
+ },
];
-
-ReactDOM.render(
-
,
- document.getElementById('root'));
+ReactDOM.render( , document.getElementById('root'));
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/Utils.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/Utils.js
index d5b976499e..0f266bae8c 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/Utils.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/Utils.js
@@ -16,18 +16,29 @@
* under the License.
*/
-import {notification} from "antd";
+import { notification } from 'antd';
-export const handleApiError = (error, message, isForbiddenMessageSilent = false) => {
- if (error.hasOwnProperty("response") && error.response.status === 401) {
- const redirectUrl = encodeURI(window.location.href);
- window.location.href = window.location.origin + `/publisher/login?redirect=${redirectUrl}`;
- // silence 403 forbidden message
- } else if (!(isForbiddenMessageSilent && error.hasOwnProperty("response") && error.response.status === 403)) {
- notification["error"]({
- message: "There was a problem",
- duration: 10,
- description: message,
- });
- }
+export const handleApiError = (
+ error,
+ message,
+ isForbiddenMessageSilent = false,
+) => {
+ if (error.hasOwnProperty('response') && error.response.status === 401) {
+ const redirectUrl = encodeURI(window.location.href);
+ window.location.href =
+ window.location.origin + `/publisher/login?redirect=${redirectUrl}`;
+ // silence 403 forbidden message
+ } else if (
+ !(
+ isForbiddenMessageSilent &&
+ error.hasOwnProperty('response') &&
+ error.response.status === 403
+ )
+ ) {
+ notification.error({
+ message: 'There was a problem',
+ duration: 10,
+ description: message,
+ });
+ }
};
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/Login.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/Login.js
index 1282f0b6ce..dfa83bbe18 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/Login.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/Login.js
@@ -16,160 +16,183 @@
* under the License.
*/
-import React from "react";
-import {Typography, Row, Col, Form, Icon, Input, Button, Checkbox, message, notification} from 'antd';
+import React from 'react';
+import {
+ Typography,
+ Row,
+ Col,
+ Form,
+ Icon,
+ Input,
+ Button,
+ message,
+ notification,
+} from 'antd';
import './Login.css';
import axios from 'axios';
-import "./Login.css";
-import {withConfigContext} from "../context/ConfigContext";
-import {handleApiError} from "../js/Utils";
+import './Login.css';
+import { withConfigContext } from '../context/ConfigContext';
-const {Title} = Typography;
-const {Text} = Typography;
+const { Title } = Typography;
+const { Text } = Typography;
class Login extends React.Component {
- render() {
- const config = this.props.context;
- return (
-
-
-
-
-
-
-
-
-
-
-
-
-
- Login
-
-
-
-
-
-
-
-
-
-
-
- );
- }
+ render() {
+ const config = this.props.context;
+ return (
+
+
+
+
+
+
+
+
+
+
+
+ Login
+
+
+
+
+
+
+
+
+ );
+ }
}
class NormalLoginForm extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ inValid: false,
+ loading: false,
+ };
+ }
- constructor(props) {
- super(props);
- this.state = {
- inValid: false,
- loading: false
+ handleSubmit = e => {
+ const config = this.props.context;
+ const thisForm = this;
+ e.preventDefault();
+ this.props.form.validateFields((err, values) => {
+ thisForm.setState({
+ inValid: false,
+ });
+ if (!err) {
+ thisForm.setState({
+ loading: true,
+ });
+ const parameters = {
+ username: values.username,
+ password: values.password,
+ platform: 'publisher',
};
- }
- handleSubmit = (e) => {
- const config = this.props.context;
- const thisForm = this;
- e.preventDefault();
- this.props.form.validateFields((err, values) => {
- thisForm.setState({
- inValid: false
- });
- if (!err) {
- thisForm.setState({
- loading: true
- });
- const parameters = {
- username: values.username,
- password: values.password,
- platform: "publisher"
- };
+ const request = Object.keys(parameters)
+ .map(key => key + '=' + parameters[key])
+ .join('&');
- const request = Object.keys(parameters).map(key => key + '=' + parameters[key]).join('&');
-
- axios.post(window.location.origin+ config.serverConfig.loginUri, request
- ).then(res=>{
- if (res.status === 200) {
- let redirectUrl = window.location.origin+"/publisher";
- const searchParams = new URLSearchParams(window.location.search);
- if(searchParams.has("redirect")){
- redirectUrl = searchParams.get("redirect");
- }
- window.location = redirectUrl;
- }
- }).catch(function (error) {
- if (error.hasOwnProperty("response") && error.response.status === 401) {
- thisForm.setState({
- loading: false,
- inValid: true
- });
- } else {
- notification["error"]({
- message: "There was a problem",
- duration: 10,
- description: message,
- });
- thisForm.setState({
- loading: false,
- inValid: false
- });
- }
- });
+ axios
+ .post(window.location.origin + config.serverConfig.loginUri, request)
+ .then(res => {
+ if (res.status === 200) {
+ let redirectUrl = window.location.origin + '/publisher';
+ const searchParams = new URLSearchParams(window.location.search);
+ if (searchParams.has('redirect')) {
+ redirectUrl = searchParams.get('redirect');
+ }
+ window.location = redirectUrl;
}
+ })
+ .catch(function(error) {
+ if (
+ error.hasOwnProperty('response') &&
+ error.response.status === 401
+ ) {
+ thisForm.setState({
+ loading: false,
+ inValid: true,
+ });
+ } else {
+ notification.error({
+ message: 'There was a problem',
+ duration: 10,
+ description: message,
+ });
+ thisForm.setState({
+ loading: false,
+ inValid: false,
+ });
+ }
+ });
+ }
+ });
+ };
- });
- };
-
- render() {
- const {getFieldDecorator} = this.props.form;
- let errorMsg = "";
- if (this.state.inValid) {
- errorMsg = Invalid Login Details ;
- }
- let loading = "";
- if (this.state.loading) {
- loading = Loading.. ;
- }
- return (
-
- {getFieldDecorator('username', {
- rules: [{required: true, message: 'Please enter your username'}],
- })(
- }
- placeholder="Username"/>
- )}
-
-
- {getFieldDecorator('password', {
- rules: [{required: true, message: 'Please enter your password'}],
- })(
- } type="password"
- placeholder="Password"/>
- )}
-
- {loading}
- {errorMsg}
-
-
- Log in
-
-
-
- );
+ render() {
+ const { getFieldDecorator } = this.props.form;
+ let errorMsg = '';
+ if (this.state.inValid) {
+ errorMsg = Invalid Login Details ;
+ }
+ let loading = '';
+ if (this.state.loading) {
+ loading = Loading.. ;
}
+ return (
+
+ {getFieldDecorator('username', {
+ rules: [{ required: true, message: 'Please enter your username' }],
+ })(
+ }
+ placeholder="Username"
+ />,
+ )}
+
+
+ {getFieldDecorator('password', {
+ rules: [{ required: true, message: 'Please enter your password' }],
+ })(
+ }
+ type="password"
+ placeholder="Password"
+ />,
+ )}
+
+ {loading}
+ {errorMsg}
+
+
+ Log in
+
+
+
+ );
+ }
}
-const WrappedNormalLoginForm = Form.create({name: 'normal_login'})(withConfigContext(NormalLoginForm));
+const WrappedNormalLoginForm = Form.create({ name: 'normal_login' })(
+ withConfigContext(NormalLoginForm),
+);
export default withConfigContext(Login);
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 ba2a948dd0..57d8ba17ab 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
@@ -16,214 +16,247 @@
* under the License.
*/
-import React from "react";
-import {Layout, Menu, Icon, Drawer, Button} from 'antd';
-import {Switch, Link} from "react-router-dom";
-import RouteWithSubRoutes from "../../components/RouteWithSubRoutes"
-import {Redirect} from 'react-router'
-import "./Dashboard.css";
-import {withConfigContext} from "../../context/ConfigContext";
-import Logout from "./logout/Logout";
+import React from 'react';
+import { Layout, Menu, Icon, Drawer, Button } from 'antd';
+import { Switch, Link } from 'react-router-dom';
+import RouteWithSubRoutes from '../../components/RouteWithSubRoutes';
+import { Redirect } from 'react-router';
+import './Dashboard.css';
+import { withConfigContext } from '../../context/ConfigContext';
+import Logout from './logout/Logout';
-const {Header, Content, Footer} = Layout;
-const {SubMenu} = Menu;
+const { Header, Content, Footer } = Layout;
+const { SubMenu } = Menu;
class Dashboard extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- routes: props.routes,
- visible: false,
- collapsed: false
- };
- this.config = this.props.context;
- this.Logo = this.config.theme.logo;
- this.footerText = this.config.theme.footerText;
- }
-
- showMobileNavigationBar = () => {
- this.setState({
- visible: true,
- collapsed: !this.state.collapsed
- });
- };
-
- onCloseMobileNavigationBar = () => {
- this.setState({
- visible: false,
- });
+ constructor(props) {
+ super(props);
+ this.state = {
+ routes: props.routes,
+ visible: false,
+ collapsed: false,
};
+ this.config = this.props.context;
+ this.Logo = this.config.theme.logo;
+ this.footerText = this.config.theme.footerText;
+ }
- render() {
- return (
-
-
-
-
-
-
+ showMobileNavigationBar = () => {
+ this.setState({
+ visible: true,
+ collapsed: !this.state.collapsed,
+ });
+ };
-
-
- Apps
+ onCloseMobileNavigationBar = () => {
+ this.setState({
+ visible: false,
+ });
+ };
-
-
- Add New App
-
- }>
-
-
- Public App
-
-
-
-
- Enterprise App
-
-
-
-
- Web Clip
-
-
-
-
- Custom App
-
-
-
+ render() {
+ return (
+
+
+
-
+
+
+ Add New App
+
+ }
+ >
+
+ Public App
+
+
+
+ Enterprise App
+
+
+
+ Web Clip
+
+
+
+ Custom App
+
+
+
-
-
-
-
-
-
-
-
-
-
- }
- placement="left"
- closable={false}
- onClose={this.onCloseMobileNavigationBar}
- visible={this.state.visible}
- getContainer={false}
- style={{position: 'absolute'}}>
-
-
-
- Apps
-
-
-
- Add New App
-
- }>
-
- Public APP
-
-
- Enterprise APP
-
-
- Web Clip
-
-
- Custom App
-
-
-
-
- Manage
-
-
-
-
-
-
-
-
- }>
-
-
-
-
+
+
+ Manage
+
+ }
+ >
+
+
+ General
+
+
+ {this.config.androidEnterpriseToken != null && (
+
+
+ Android
+ Enterprise
+
+
+ )}
+
-
-
-
-
- {this.state.routes.map((route) => (
-
- ))}
-
-
-
-
+
+
+ {this.config.user}
+
+ }
+ >
+
+
+
- );
- }
+
+
+
+
+
+
+
+
+
+
+
+
+
+ }
+ placement="left"
+ closable={false}
+ onClose={this.onCloseMobileNavigationBar}
+ visible={this.state.visible}
+ getContainer={false}
+ style={{ position: 'absolute' }}
+ >
+
+
+
+
+ Apps
+
+
+
+
+ Add New App
+
+ }
+ >
+
+ Public APP
+
+
+
+ Enterprise APP
+
+
+
+ Web Clip
+
+
+ Custom App
+
+
+
+
+
+ Manage
+
+
+
+
+
+
+
+
+
+ }
+ >
+
+
+
+
+
+
+
+
+
+ {this.state.routes.map(route => (
+
+ ))}
+
+
+
+
+
+ );
+ }
}
-export default withConfigContext(Dashboard);
\ No newline at end of file
+export default withConfigContext(Dashboard);
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewCustomApp.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewCustomApp.js
index e1a523e9a2..7e2c6aa587 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewCustomApp.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewCustomApp.js
@@ -16,69 +16,65 @@
* under the License.
*/
-import React from "react";
-import {
- PageHeader,
- Typography,
- Breadcrumb,
- Icon
-} from "antd";
-import AddNewAppForm from "../../../components/new-app/AddNewAppForm";
-import {Link} from "react-router-dom";
+import React from 'react';
+import { PageHeader, Typography, Breadcrumb, Icon } from 'antd';
+import AddNewAppForm from '../../../components/new-app/AddNewAppForm';
+import { Link } from 'react-router-dom';
-const {Paragraph} = Typography;
+const { Paragraph } = Typography;
const formConfig = {
- installationType: "CUSTOM",
- endpoint: "/custom-app",
- jsonPayloadName: "application",
- releaseWrapperName: "customAppReleaseWrappers",
- specificElements: {
- binaryFile: {
- required: true
- },
- packageName : {
- required: true
- },
- version : {
- required: true
- }
- }
+ installationType: 'CUSTOM',
+ endpoint: '/custom-app',
+ jsonPayloadName: 'application',
+ releaseWrapperName: 'customAppReleaseWrappers',
+ specificElements: {
+ binaryFile: {
+ required: true,
+ },
+ packageName: {
+ required: true,
+ },
+ version: {
+ required: true,
+ },
+ },
};
class AddNewCustomApp extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ current: 0,
+ categories: [],
+ };
+ }
- constructor(props) {
- super(props);
- this.state = {
- current: 0,
- categories: []
- };
- }
-
- render() {
- return (
-
-
-
-
- Home
-
- Add New Custom App
-
-
-
Add New Custom App
-
Submit and share your own application to the corporate app store.
-
-
-
-
-
-
- );
- }
+ render() {
+ return (
+
+
+
+
+
+ Home
+
+
+ Add New Custom App
+
+
+
Add New Custom App
+
+ Submit and share your own application to the corporate app store.
+
+
+
+
+
+ );
+ }
}
export default AddNewCustomApp;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewEnterpriseApp.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewEnterpriseApp.js
index c51f56ba5b..c499b0ce34 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewEnterpriseApp.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewEnterpriseApp.js
@@ -16,63 +16,59 @@
* under the License.
*/
-import React from "react";
-import {
- PageHeader,
- Typography,
- Breadcrumb,
- Icon
-} from "antd";
-import AddNewAppForm from "../../../components/new-app/AddNewAppForm";
-import {Link} from "react-router-dom";
+import React from 'react';
+import { PageHeader, Typography, Breadcrumb, Icon } from 'antd';
+import AddNewAppForm from '../../../components/new-app/AddNewAppForm';
+import { Link } from 'react-router-dom';
-const {Paragraph} = Typography;
+const { Paragraph } = Typography;
const formConfig = {
- installationType: "ENTERPRISE",
- endpoint: "/ent-app",
- jsonPayloadName: "application",
- releaseWrapperName: "entAppReleaseWrappers",
- specificElements: {
- binaryFile: {
- required: true
- }
- }
+ installationType: 'ENTERPRISE',
+ endpoint: '/ent-app',
+ jsonPayloadName: 'application',
+ releaseWrapperName: 'entAppReleaseWrappers',
+ specificElements: {
+ binaryFile: {
+ required: true,
+ },
+ },
};
class AddNewEnterpriseApp extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ current: 0,
+ categories: [],
+ };
+ }
- constructor(props) {
- super(props);
- this.state = {
- current: 0,
- categories: []
- };
- }
-
- render() {
- return (
-
-
-
-
- Home
-
- Add New Enterprise App
-
-
-
Add New Enterprise App
-
Submit and share your own application to the corporate app store.
-
-
-
-
-
-
- );
- }
+ render() {
+ return (
+
+
+
+
+
+ Home
+
+
+ Add New Enterprise App
+
+
+
Add New Enterprise App
+
+ Submit and share your own application to the corporate app store.
+
+
+
+
+
+ );
+ }
}
export default AddNewEnterpriseApp;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewPublicApp.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewPublicApp.js
index b5961871da..6d9daa523a 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewPublicApp.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewPublicApp.js
@@ -16,72 +16,67 @@
* under the License.
*/
-import React from "react";
-import {
- Icon,
- PageHeader,
- Typography,
- Breadcrumb
-} from "antd";
-import AddNewAppForm from "../../../components/new-app/AddNewAppForm";
-import {Link} from "react-router-dom";
+import React from 'react';
+import { Icon, PageHeader, Typography, Breadcrumb } from 'antd';
+import AddNewAppForm from '../../../components/new-app/AddNewAppForm';
+import { Link } from 'react-router-dom';
-const {Paragraph, Title} = Typography;
+const { Paragraph } = Typography;
const formConfig = {
- installationType: "PUBLIC",
- endpoint: "/public-app",
- jsonPayloadName:"public-app",
- releaseWrapperName: "publicAppReleaseWrappers",
- specificElements: {
- packageName : {
- required: true
- },
- version : {
- required: true
- }
- }
+ installationType: 'PUBLIC',
+ endpoint: '/public-app',
+ jsonPayloadName: 'public-app',
+ releaseWrapperName: 'publicAppReleaseWrappers',
+ specificElements: {
+ packageName: {
+ required: true,
+ },
+ version: {
+ required: true,
+ },
+ },
};
class AddNewEnterpriseApp extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ current: 0,
+ categories: [],
+ };
+ }
- constructor(props) {
- super(props);
- this.state = {
- current: 0,
- categories: []
- };
- }
+ componentDidMount() {
+ // this.getCategories();
+ }
- componentDidMount() {
- // this.getCategories();
- }
-
-
- render() {
- return (
-
-
-
-
- Home
-
- Add New Public App
-
-
-
Add New Public App
-
Share a public application in google play or apple store to your corporate app store.
-
-
-
-
-
-
-
- );
- }
+ render() {
+ return (
+
+
+
+
+
+ Home
+
+
+ Add New Public App
+
+
+
Add New Public App
+
+ Share a public application in google play or apple store to your
+ corporate app store.
+
+
+
+
+
+ );
+ }
}
export default AddNewEnterpriseApp;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewWebClip.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewWebClip.js
index f37e453901..d9998c827c 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewWebClip.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-app/AddNewWebClip.js
@@ -16,67 +16,60 @@
* under the License.
*/
-import React from "react";
-import {
- Icon,
- PageHeader,
- Typography,
- Breadcrumb
-} from "antd";
-import AddNewAppForm from "../../../components/new-app/AddNewAppForm";
-import {Link} from "react-router-dom";
+import React from 'react';
+import { Icon, PageHeader, Typography, Breadcrumb } from 'antd';
+import AddNewAppForm from '../../../components/new-app/AddNewAppForm';
+import { Link } from 'react-router-dom';
-const {Paragraph, Title}= Typography;
+const { Paragraph } = Typography;
const formConfig = {
- installationType: "WEB_CLIP",
- endpoint: "/web-app",
- jsonPayloadName:"webapp",
- releaseWrapperName: "webAppReleaseWrappers",
- specificElements: {
- url : {
- required: true
- },
- version : {
- required: true
- }
- }
+ installationType: 'WEB_CLIP',
+ endpoint: '/web-app',
+ jsonPayloadName: 'webapp',
+ releaseWrapperName: 'webAppReleaseWrappers',
+ specificElements: {
+ url: {
+ required: true,
+ },
+ version: {
+ required: true,
+ },
+ },
};
class AddNewEnterpriseApp extends React.Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ current: 0,
+ categories: [],
+ };
+ }
- constructor(props) {
- super(props);
- this.state = {
- current: 0,
- categories: []
- };
- }
-
-
- render() {
- return (
-
-
-
-
- Home
-
- Add New Web Clip
-
-
-
Add New Web Clip
-
Share a Web Clip to your corporate app store.
-
-
-
-
-
-
- );
- }
+ render() {
+ return (
+
+
+
+
+
+ Home
+
+
+ Add New Web Clip
+
+
+
Add New Web Clip
+
Share a Web Clip to your corporate app store.
+
+
+
+
+ );
+ }
}
export default AddNewEnterpriseApp;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-release/AddNewRelease.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-release/AddNewRelease.js
index d5d7d70bb0..74c4a2ad1e 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-release/AddNewRelease.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/add-new-release/AddNewRelease.js
@@ -16,52 +16,46 @@
* under the License.
*/
-import React from "react";
-import {
- Icon,
- PageHeader,
- Typography,
- Breadcrumb
-} from "antd";
-import AddNewReleaseForm from "../../../components/new-release/AddReleaseForm";
-import {Link} from "react-router-dom";
+import React from 'react';
+import { Icon, PageHeader, Typography, Breadcrumb } from 'antd';
+import AddNewReleaseForm from '../../../components/new-release/AddReleaseForm';
+import { Link } from 'react-router-dom';
const Paragraph = Typography;
class AddNewRelease extends React.Component {
-
- constructor(props) {
- super(props);
- this.state = {
- current: 0,
- categories: []
- };
- }
-
- render() {
- const {appId, deviceType} = this.props.match.params;
- return (
-
-
-
-
- Home
-
- Add New Release
-
-
-
Add New Release
-
Add new release for the application
-
-
-
-
-
-
- );
- }
+ constructor(props) {
+ super(props);
+ this.state = {
+ current: 0,
+ categories: [],
+ };
+ }
+
+ render() {
+ const { appId, deviceType } = this.props.match.params;
+ return (
+
+
+
+
+
+ Home
+
+
+ Add New Release
+
+
+
Add New Release
+
Add new release for the application
+
+
+
+
+ );
+ }
}
export default AddNewRelease;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js
index 248fca92ae..8f9773bf69 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/Apps.js
@@ -16,28 +16,25 @@
* under the License.
*/
-import React from "react";
-import ListApps from "../../../components/apps/list-apps/ListApps";
+import React from 'react';
+import ListApps from '../../../components/apps/list-apps/ListApps';
class Apps extends React.Component {
- routes;
- constructor(props) {
- super(props);
- this.routes = props.routes;
+ routes;
+ constructor(props) {
+ super(props);
+ this.routes = props.routes;
+ }
- }
-
- render() {
- return (
-
-
- );
- }
+ render() {
+ return (
+
+ );
+ }
}
export default Apps;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/release/Release.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/release/Release.js
index ba3bf141ef..04f91a54de 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/release/Release.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/apps/release/Release.js
@@ -16,193 +16,232 @@
* under the License.
*/
-import React from "react";
+import React from 'react';
import '../../../../App.css';
-import {Typography, Row, Col, message, Card, notification, Skeleton} from "antd";
+import { Typography, Row, Col, Card, Skeleton } from 'antd';
import axios from 'axios';
-import ReleaseView from "../../../../components/apps/release/ReleaseView";
-import LifeCycle from "../../../../components/apps/release/lifeCycle/LifeCycle";
-import {withConfigContext} from "../../../../context/ConfigContext";
-import {handleApiError} from "../../../../js/Utils";
-import NewAppUploadForm from "../../../../components/new-app/subForms/NewAppUploadForm";
+import ReleaseView from '../../../../components/apps/release/ReleaseView';
+import LifeCycle from '../../../../components/apps/release/lifeCycle/LifeCycle';
+import { withConfigContext } from '../../../../context/ConfigContext';
+import { handleApiError } from '../../../../js/Utils';
-const {Title} = Typography;
+const { Title } = Typography;
class Release extends React.Component {
- routes;
-
- constructor(props) {
- super(props);
- this.routes = props.routes;
- this.state = {
- loading: true,
- app: null,
- uuid: null,
- release: null,
- currentLifecycleStatus: null,
- lifecycle: null,
- supportedOsVersions: [],
- forbiddenErrors: {
- supportedOsVersions: false,
- lifeCycle: false
- }
- };
- }
-
- componentDidMount() {
- const {uuid} = this.props.match.params;
- this.fetchData(uuid);
- this.getLifecycle();
-
- }
-
- changeCurrentLifecycleStatus = (status) => {
- this.setState({
- currentLifecycleStatus: status
- });
- };
-
- updateRelease = (release) => {
- this.setState({
- release
- });
- };
-
- fetchData = (uuid) => {
- const config = this.props.context;
-
- //send request to the invoker
- axios.get(
- window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/release/" + uuid,
- ).then(res => {
- if (res.status === 200) {
- const app = res.data.data;
- const release = (app !== null) ? app.applicationReleases[0] : null;
- const currentLifecycleStatus = (release !== null) ? release.currentStatus : null;
- this.setState({
- app: app,
- release: release,
- currentLifecycleStatus: currentLifecycleStatus,
- loading: false,
- uuid: uuid
- });
- if (config.deviceTypes.mobileTypes.includes(app.deviceType)) {
- this.getSupportedOsVersions(app.deviceType);
- }
- }
-
- }).catch((error) => {
- handleApiError(error, "Error occurred while trying to load the release.");
- this.setState({loading: false});
- });
- };
-
- getLifecycle = () => {
- const config = this.props.context;
- axios.get(
- window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications/lifecycle-config"
- ).then(res => {
- if (res.status === 200) {
- const lifecycle = res.data.data;
- this.setState({
- lifecycle: lifecycle
- })
- }
-
- }).catch((error) => {
- handleApiError(error, "Error occurred while trying to load lifecycle configuration.", true);
- if (error.hasOwnProperty("response") && error.response.status === 403) {
- const {forbiddenErrors} = this.state;
- forbiddenErrors.lifeCycle = true;
- this.setState({
- forbiddenErrors
- })
- }
- });
- };
-
- getSupportedOsVersions = (deviceType) => {
- const config = this.props.context;
- axios.get(
- window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.deviceMgt +
- `/admin/device-types/${deviceType}/versions`
- ).then(res => {
- if (res.status === 200) {
- let supportedOsVersions = JSON.parse(res.data.data);
- this.setState({
- supportedOsVersions
- });
- }
- }).catch((error) => {
- handleApiError(error, "Error occurred while trying to load supported OS versions.", true);
- if (error.hasOwnProperty("response") && error.response.status === 403) {
- const {forbiddenErrors} = this.state;
- forbiddenErrors.supportedOsVersions = true;
- this.setState({
- forbiddenErrors,
- loading: false
- })
- } else {
- this.setState({
- loading: false
- });
- }
- });
+ routes;
+
+ constructor(props) {
+ super(props);
+ this.routes = props.routes;
+ this.state = {
+ loading: true,
+ app: null,
+ uuid: null,
+ release: null,
+ currentLifecycleStatus: null,
+ lifecycle: null,
+ supportedOsVersions: [],
+ forbiddenErrors: {
+ supportedOsVersions: false,
+ lifeCycle: false,
+ },
};
-
- render() {
- const {app, release, currentLifecycleStatus, lifecycle, loading, forbiddenErrors} = this.state;
-
- if (release == null && loading === false) {
- return (
-
-
No Apps Found
-
- );
+ }
+
+ componentDidMount() {
+ const { uuid } = this.props.match.params;
+ this.fetchData(uuid);
+ this.getLifecycle();
+ }
+
+ changeCurrentLifecycleStatus = status => {
+ this.setState({
+ currentLifecycleStatus: status,
+ });
+ };
+
+ updateRelease = release => {
+ this.setState({
+ release,
+ });
+ };
+
+ fetchData = uuid => {
+ const config = this.props.context;
+
+ // send request to the invoker
+ axios
+ .get(
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ config.serverConfig.invoker.publisher +
+ '/applications/release/' +
+ uuid,
+ )
+ .then(res => {
+ if (res.status === 200) {
+ const app = res.data.data;
+ const release = app !== null ? app.applicationReleases[0] : null;
+ const currentLifecycleStatus =
+ release !== null ? release.currentStatus : null;
+ this.setState({
+ app: app,
+ release: release,
+ currentLifecycleStatus: currentLifecycleStatus,
+ loading: false,
+ uuid: uuid,
+ });
+ if (config.deviceTypes.mobileTypes.includes(app.deviceType)) {
+ this.getSupportedOsVersions(app.deviceType);
+ }
}
-
- //todo remove uppercase
- return (
-
-
-
-
-
-
- {(release !== null) && (
- )
- }
-
-
-
-
-
-
- {(release !== null) && (
- )
- }
-
-
-
-
-
-
-
+ })
+ .catch(error => {
+ handleApiError(
+ error,
+ 'Error occurred while trying to load the release.',
);
+ this.setState({ loading: false });
+ });
+ };
+
+ getLifecycle = () => {
+ const config = this.props.context;
+ axios
+ .get(
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ config.serverConfig.invoker.publisher +
+ '/applications/lifecycle-config',
+ )
+ .then(res => {
+ if (res.status === 200) {
+ const lifecycle = res.data.data;
+ this.setState({
+ lifecycle: lifecycle,
+ });
+ }
+ })
+ .catch(error => {
+ handleApiError(
+ error,
+ 'Error occurred while trying to load lifecycle configuration.',
+ true,
+ );
+ if (error.hasOwnProperty('response') && error.response.status === 403) {
+ const { forbiddenErrors } = this.state;
+ forbiddenErrors.lifeCycle = true;
+ this.setState({
+ forbiddenErrors,
+ });
+ }
+ });
+ };
+
+ getSupportedOsVersions = deviceType => {
+ const config = this.props.context;
+ axios
+ .get(
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ config.serverConfig.invoker.deviceMgt +
+ `/admin/device-types/${deviceType}/versions`,
+ )
+ .then(res => {
+ if (res.status === 200) {
+ let supportedOsVersions = JSON.parse(res.data.data);
+ this.setState({
+ supportedOsVersions,
+ });
+ }
+ })
+ .catch(error => {
+ handleApiError(
+ error,
+ 'Error occurred while trying to load supported OS versions.',
+ true,
+ );
+ if (error.hasOwnProperty('response') && error.response.status === 403) {
+ const { forbiddenErrors } = this.state;
+ forbiddenErrors.supportedOsVersions = true;
+ this.setState({
+ forbiddenErrors,
+ loading: false,
+ });
+ } else {
+ this.setState({
+ loading: false,
+ });
+ }
+ });
+ };
+
+ render() {
+ const {
+ app,
+ release,
+ currentLifecycleStatus,
+ lifecycle,
+ loading,
+ forbiddenErrors,
+ } = this.state;
+
+ if (release == null && loading === false) {
+ return (
+
+
No Apps Found
+
+ );
}
+
+ // todo remove uppercase
+ return (
+
+
+
+
+
+
+ {release !== null && (
+
+ )}
+
+
+
+
+
+
+ {release !== null && (
+
+ )}
+
+
+
+
+
+
+ );
+ }
}
export default withConfigContext(Release);
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/logout/Logout.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/logout/Logout.js
index 26e0e89bb6..c217cdb202 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/logout/Logout.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/logout/Logout.js
@@ -16,64 +16,66 @@
* under the License.
*/
-import React from "react";
-import {notification, Menu, Icon} from 'antd';
+import React from 'react';
+import { notification, Menu, Icon } from 'antd';
import axios from 'axios';
-import {withConfigContext} from "../../../context/ConfigContext";
+import { withConfigContext } from '../../../context/ConfigContext';
/*
This class for call the logout api by sending request
*/
class Logout extends React.Component {
-
- constructor(props) {
- super(props);
- this.state = {
- inValid: false,
- loading: false
- };
- }
- /*
+ constructor(props) {
+ super(props);
+ this.state = {
+ inValid: false,
+ loading: false,
+ };
+ }
+ /*
This function call the logout api when the request is success
*/
- handleSubmit = () => {
+ handleSubmit = () => {
+ const thisForm = this;
+ const config = this.props.context;
- const thisForm = this;
- const config = this.props.context;
+ thisForm.setState({
+ inValid: false,
+ });
- thisForm.setState({
- inValid: false
- });
-
- axios.post(window.location.origin + config.serverConfig.logoutUri
- ).then(res => {
- //if the api call status is correct then user will logout and then it goes to login page
- if (res.status === 200) {
- window.location = window.location.origin + "/publisher/login";
- }
- }).catch(function (error) {
- if (error.hasOwnProperty("response") && error.response.status === 400) {
- thisForm.setState({
- inValid: true
- });
- } else {
- notification["error"]({
- message: "There was a problem",
- duration: 0,
- description:
- "Error occurred while trying to logout.",
- });
- }
- });
- };
+ axios
+ .post(window.location.origin + config.serverConfig.logoutUri)
+ .then(res => {
+ // if the api call status is correct then user will logout and then it goes to login page
+ if (res.status === 200) {
+ window.location = window.location.origin + '/publisher/login';
+ }
+ })
+ .catch(function(error) {
+ if (error.hasOwnProperty('response') && error.response.status === 400) {
+ thisForm.setState({
+ inValid: true,
+ });
+ } else {
+ notification.error({
+ message: 'There was a problem',
+ duration: 0,
+ description: 'Error occurred while trying to logout.',
+ });
+ }
+ });
+ };
- render() {
- return (
-
- Logout
-
- );
- }
+ render() {
+ return (
+
+
+
+ Logout
+
+
+ );
+ }
}
export default withConfigContext(Logout);
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/manage/Manage.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/manage/Manage.js
index 2932d335b1..7d835141e6 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/manage/Manage.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/manage/Manage.js
@@ -16,56 +16,55 @@
* under the License.
*/
-import React from "react";
-import {PageHeader, Typography, Breadcrumb, Row, Col, Icon} from "antd";
-import ManageCategories from "../../../components/manage/categories/ManageCategories";
-import ManageTags from "../../../components/manage/categories/ManageTags";
-import {Link} from "react-router-dom";
+import React from 'react';
+import { PageHeader, Typography, Breadcrumb, Row, Col, Icon } from 'antd';
+import ManageCategories from '../../../components/manage/categories/ManageCategories';
+import ManageTags from '../../../components/manage/categories/ManageTags';
+import { Link } from 'react-router-dom';
-const {Paragraph} = Typography;
+const { Paragraph } = Typography;
class Manage extends React.Component {
- routes;
+ routes;
- constructor(props) {
- super(props);
- this.routes = props.routes;
+ constructor(props) {
+ super(props);
+ this.routes = props.routes;
+ }
- }
-
- render() {
- return (
-
-
-
-
- Home
-
-
- Manage
-
- General
-
-
-
Manage General Settings
-
Maintain and manage categories and tags here..
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
- }
+ render() {
+ return (
+
+
+
+
+
+ Home
+
+
+ Manage
+ General
+
+
+
Manage General Settings
+
+ Maintain and manage categories and tags here..
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+ }
}
export default Manage;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/manage/android-enterprise/ManageAndroidEnterprise.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/manage/android-enterprise/ManageAndroidEnterprise.js
index e0348e8fc5..ec3986c48d 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/manage/android-enterprise/ManageAndroidEnterprise.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/manage/android-enterprise/ManageAndroidEnterprise.js
@@ -16,53 +16,50 @@
* under the License.
*/
-import React from "react";
-import {PageHeader, Typography, Breadcrumb, Divider, Button, Icon} from "antd";
-import {Link} from "react-router-dom";
-import SyncAndroidApps from "../../../../components/manage/android-enterprise/SyncAndroidApps";
-import {withConfigContext} from "../../../../context/ConfigContext";
-import GooglePlayIframe from "../../../../components/manage/android-enterprise/GooglePlayIframe";
-import Pages from "../../../../components/manage/android-enterprise/Pages/Pages";
-
-const {Paragraph} = Typography;
+import React from 'react';
+import { PageHeader, Breadcrumb, Divider, Icon } from 'antd';
+import { Link } from 'react-router-dom';
+import SyncAndroidApps from '../../../../components/manage/android-enterprise/SyncAndroidApps';
+import { withConfigContext } from '../../../../context/ConfigContext';
+import GooglePlayIframe from '../../../../components/manage/android-enterprise/GooglePlayIframe';
+import Pages from '../../../../components/manage/android-enterprise/Pages/Pages';
class ManageAndroidEnterprise extends React.Component {
- routes;
-
- constructor(props) {
- super(props);
- this.routes = props.routes;
- this.config = this.props.context;
- }
+ routes;
- render() {
- return (
-
-
-
-
- Home
-
-
- Manage
-
- Android Enterprise
-
-
-
Manage Android Enterprise
- {/*
Lorem ipsum */}
-
-
-
-
+ constructor(props) {
+ super(props);
+ this.routes = props.routes;
+ this.config = this.props.context;
+ }
- );
- }
+ render() {
+ return (
+
+
+
+
+
+ Home
+
+
+ Manage
+ Android Enterprise
+
+
+
Manage Android Enterprise
+ {/*
Lorem ipsum */}
+
+
+
+
+ );
+ }
}
export default withConfigContext(ManageAndroidEnterprise);
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/manage/android-enterprise/page/Page.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/manage/android-enterprise/page/Page.js
index 12f8720780..efc4a424d5 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/manage/android-enterprise/page/Page.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/pages/dashboard/manage/android-enterprise/page/Page.js
@@ -16,371 +16,409 @@
* under the License.
*/
-import React from "react";
+import React from 'react';
import {
- PageHeader,
- Typography,
- Breadcrumb,
- Button,
- Icon,
- Col,
- Row,
- notification,
- message,
- Spin,
- Select,
- Tag,
- Divider
-} from "antd";
-import {Link, withRouter} from "react-router-dom";
-import {withConfigContext} from "../../../../../context/ConfigContext";
-import axios from "axios";
-import Cluster from "../../../../../components/manage/android-enterprise/Pages/Cluster/Cluster";
-import EditLinks from "../../../../../components/manage/android-enterprise/Pages/EditLinks/EditLinks";
-import {handleApiError} from "../../../../../js/Utils";
-
-const {Option} = Select;
-const {Title, Text} = Typography;
+ PageHeader,
+ Typography,
+ Breadcrumb,
+ Button,
+ Icon,
+ Col,
+ Row,
+ notification,
+ message,
+ Spin,
+ Tag,
+ Divider,
+} from 'antd';
+import { Link, withRouter } from 'react-router-dom';
+import { withConfigContext } from '../../../../../context/ConfigContext';
+import axios from 'axios';
+import Cluster from '../../../../../components/manage/android-enterprise/Pages/Cluster/Cluster';
+import EditLinks from '../../../../../components/manage/android-enterprise/Pages/EditLinks/EditLinks';
+import { handleApiError } from '../../../../../js/Utils';
+
+const { Title } = Typography;
class Page extends React.Component {
- routes;
-
- constructor(props) {
- super(props);
- const {pageName, pageId} = this.props.match.params;
- this.pageId = pageId;
- this.routes = props.routes;
- this.config = this.props.context;
- this.pages = [];
- this.pageNames = {};
- this.state = {
- pageName,
- clusters: [],
- loading: false,
- applications: [],
- isAddNewClusterVisible: false,
- links: []
- };
- }
-
- componentDidMount() {
- this.fetchClusters();
- this.fetchApplications();
- this.fetchPages();
- }
-
- removeLoadedCluster = (clusterId) => {
- const clusters = [...this.state.clusters];
- let index = -1;
- for (let i = 0; i < clusters.length; i++) {
- if (clusters[i].clusterId === clusterId) {
- index = i;
- break;
- }
- }
- clusters.splice(index, 1);
- this.setState({
- clusters
- });
+ routes;
+
+ constructor(props) {
+ super(props);
+ const { pageName, pageId } = this.props.match.params;
+ this.pageId = pageId;
+ this.routes = props.routes;
+ this.config = this.props.context;
+ this.pages = [];
+ this.pageNames = {};
+ this.state = {
+ pageName,
+ clusters: [],
+ loading: false,
+ applications: [],
+ isAddNewClusterVisible: false,
+ links: [],
};
-
- updatePageName = pageName => {
- const config = this.props.context;
- if (pageName !== this.state.pageName && pageName !== "") {
- const data = {
- locale: "en",
- pageName: pageName,
- pageId: this.pageId
- };
- axios.put(
- window.location.origin + config.serverConfig.invoker.uri +
- "/device-mgt/android/v1.0/enterprise/store-layout/page",
- data
- ).then(res => {
- if (res.status === 200) {
- notification["success"]({
- message: 'Saved!',
- description: 'Page name updated successfully!'
- });
- this.setState({
- loading: false,
- pageName: res.data.data.pageName,
- });
-
- this.props.history.push(`/publisher/manage/android-enterprise/pages/${pageName}/${this.pageId}`);
-
- }
- }).catch((error) => {
- handleApiError(error, "Error occurred while trying to save the page name.");
- this.setState({loading: false});
+ }
+
+ componentDidMount() {
+ this.fetchClusters();
+ this.fetchApplications();
+ this.fetchPages();
+ }
+
+ removeLoadedCluster = clusterId => {
+ const clusters = [...this.state.clusters];
+ let index = -1;
+ for (let i = 0; i < clusters.length; i++) {
+ if (clusters[i].clusterId === clusterId) {
+ index = i;
+ break;
+ }
+ }
+ clusters.splice(index, 1);
+ this.setState({
+ clusters,
+ });
+ };
+
+ updatePageName = pageName => {
+ const config = this.props.context;
+ if (pageName !== this.state.pageName && pageName !== '') {
+ const data = {
+ locale: 'en',
+ pageName: pageName,
+ pageId: this.pageId,
+ };
+ axios
+ .put(
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ '/device-mgt/android/v1.0/enterprise/store-layout/page',
+ data,
+ )
+ .then(res => {
+ if (res.status === 200) {
+ notification.success({
+ message: 'Saved!',
+ description: 'Page name updated successfully!',
});
- }
- };
-
- swapClusters = (index, swapIndex) => {
- const clusters = [...this.state.clusters];
-
- if (swapIndex !== -1 && index < clusters.length) {
- // swap elements
- [clusters[index], clusters[swapIndex]] = [clusters[swapIndex], clusters[index]];
-
this.setState({
- clusters,
+ loading: false,
+ pageName: res.data.data.pageName,
});
- }
- };
-
- fetchPages = () => {
- const config = this.props.context;
- this.setState({loading: true});
-
- //send request to the invoker
- axios.get(
- window.location.origin + config.serverConfig.invoker.uri +
- "/device-mgt/android/v1.0/enterprise/store-layout/page",
- ).then(res => {
- if (res.status === 200) {
- this.pages = res.data.data.page;
-
- let links = [];
-
- this.pages.forEach((page) => {
- this.pageNames[page.id.toString()] = page.name[0]["text"];
- if (page.id === this.pageId && page.hasOwnProperty("link")) {
- links = page["link"];
- }
- });
-
- this.setState({
- loading: false,
- links
- });
- }
-
- }).catch((error) => {
- if (error.hasOwnProperty("response") && error.response.status === 401) {
- message.error('You are not logged in');
- window.location.href = window.location.origin + '/publisher/login';
- } else {
- notification["error"]({
- message: "There was a problem",
- duration: 0,
- description:
- "Error occurred while trying to load pages.",
- });
- }
- this.setState({loading: false});
+ this.props.history.push(
+ `/publisher/manage/android-enterprise/pages/${pageName}/${this.pageId}`,
+ );
+ }
+ })
+ .catch(error => {
+ handleApiError(
+ error,
+ 'Error occurred while trying to save the page name.',
+ );
+ this.setState({ loading: false });
});
- };
+ }
+ };
- fetchClusters = () => {
- const config = this.props.context;
- axios.get(
- window.location.origin + config.serverConfig.invoker.uri +
- `/device-mgt/android/v1.0/enterprise/store-layout/page/${this.pageId}/clusters`
- ).then(res => {
- if (res.status === 200) {
- let clusters = JSON.parse(res.data.data);
-
- // sort according to the orderInPage value
- clusters.sort((a, b) => (a.orderInPage > b.orderInPage) ? 1 : -1);
-
- this.setState({
- clusters,
- loading: false
- });
- }
- }).catch((error) => {
- if (error.hasOwnProperty("response") && error.response.status === 401) {
- window.location.href = window.location.origin + '/publisher/login';
- } else if (!(error.hasOwnProperty("response") && error.response.status === 404)) {
- // API sends 404 when no apps
- notification["error"]({
- message: "There was a problem",
- duration: 0,
- description:
- "Error occurred while trying to load clusters.",
- });
- }
- this.setState({
- loading: false
- });
- });
- };
+ swapClusters = (index, swapIndex) => {
+ const clusters = [...this.state.clusters];
- //fetch applications
- fetchApplications = () => {
- const config = this.props.context;
- this.setState({loading: true});
-
- const filters = {
- appType: "PUBLIC",
- deviceType: "android"
- };
-
- //send request to the invoker
- axios.post(
- window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher + "/applications",
- filters
- ).then(res => {
- if (res.status === 200) {
- const applications = res.data.data.applications.map(application => {
- const release = application.applicationReleases[0];
- return {
- packageId: `app:${application.packageName}`,
- iconUrl: release.iconPath,
- name: application.name
- }
- });
-
- this.setState({
- loading: false,
- applications,
- });
- }
+ if (swapIndex !== -1 && index < clusters.length) {
+ // swap elements
+ [clusters[index], clusters[swapIndex]] = [
+ clusters[swapIndex],
+ clusters[index],
+ ];
- }).catch((error) => {
- if (error.hasOwnProperty("response") && error.response.status === 401) {
- message.error('You are not logged in');
- window.location.href = window.location.origin + '/publisher/login';
- } else {
- notification["error"]({
- message: "There was a problem",
- duration: 0,
- description:
- "Error occurred while trying to load pages.",
- });
+ this.setState({
+ clusters,
+ });
+ }
+ };
+
+ fetchPages = () => {
+ const config = this.props.context;
+ this.setState({ loading: true });
+
+ // send request to the invoker
+ axios
+ .get(
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ '/device-mgt/android/v1.0/enterprise/store-layout/page',
+ )
+ .then(res => {
+ if (res.status === 200) {
+ this.pages = res.data.data.page;
+
+ let links = [];
+
+ this.pages.forEach(page => {
+ this.pageNames[page.id.toString()] = page.name[0].text;
+ if (page.id === this.pageId && page.hasOwnProperty('link')) {
+ links = page.link;
}
+ });
- this.setState({loading: false});
- });
- };
+ this.setState({
+ loading: false,
+ links,
+ });
+ }
+ })
+ .catch(error => {
+ if (error.hasOwnProperty('response') && error.response.status === 401) {
+ message.error('You are not logged in');
+ window.location.href = window.location.origin + '/publisher/login';
+ } else {
+ notification.error({
+ message: 'There was a problem',
+ duration: 0,
+ description: 'Error occurred while trying to load pages.',
+ });
+ }
- toggleAddNewClusterVisibility = (isAddNewClusterVisible) => {
+ this.setState({ loading: false });
+ });
+ };
+
+ fetchClusters = () => {
+ const config = this.props.context;
+ axios
+ .get(
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ `/device-mgt/android/v1.0/enterprise/store-layout/page/${this.pageId}/clusters`,
+ )
+ .then(res => {
+ if (res.status === 200) {
+ let clusters = JSON.parse(res.data.data);
+
+ // sort according to the orderInPage value
+ clusters.sort((a, b) => (a.orderInPage > b.orderInPage ? 1 : -1));
+
+ this.setState({
+ clusters,
+ loading: false,
+ });
+ }
+ })
+ .catch(error => {
+ if (error.hasOwnProperty('response') && error.response.status === 401) {
+ window.location.href = window.location.origin + '/publisher/login';
+ } else if (
+ !(error.hasOwnProperty('response') && error.response.status === 404)
+ ) {
+ // API sends 404 when no apps
+ notification.error({
+ message: 'There was a problem',
+ duration: 0,
+ description: 'Error occurred while trying to load clusters.',
+ });
+ }
this.setState({
- isAddNewClusterVisible
+ loading: false,
});
- };
+ });
+ };
- addSavedClusterToThePage = (cluster) => {
- this.setState({
- clusters: [...this.state.clusters, cluster],
- isAddNewClusterVisible: false
- });
- window.scrollTo(0, document.body.scrollHeight);
- };
+ // fetch applications
+ fetchApplications = () => {
+ const config = this.props.context;
+ this.setState({ loading: true });
- updateLinks = (links) =>{
- this.setState({
- links
- });
+ const filters = {
+ appType: 'PUBLIC',
+ deviceType: 'android',
};
- render() {
- const {pageName, loading, clusters, applications, isAddNewClusterVisible, links} = this.state;
- return (
-
-
-
-
- Home
-
-
- Manage
-
-
- Android Enterprise
-
- Manage Page
-
-
-
Manage Android Enterprise
- {/*
Lorem ipsum */}
-
-
-
-
-
-
- {pageName}
-
-
-
-
- Links
- {
- links.map(link => {
- if (this.pageNames.hasOwnProperty(link.toString())) {
- return {this.pageNames[link.toString()]}
- } else {
- return null;
- }
- })
- }
-
-
- {/* */}
-
- {/**/}
-
-
-
- Clusters
-
-
- {
- this.toggleAddNewClusterVisibility(true);
- }}
- >Add new cluster
-
-
-
-
-
- {
- clusters.map((cluster, index) => {
- return (
-
- );
- })
- }
-
-
+ // send request to the invoker
+ axios
+ .post(
+ window.location.origin +
+ config.serverConfig.invoker.uri +
+ config.serverConfig.invoker.publisher +
+ '/applications',
+ filters,
+ )
+ .then(res => {
+ if (res.status === 200) {
+ const applications = res.data.data.applications.map(application => {
+ const release = application.applicationReleases[0];
+ return {
+ packageId: `app:${application.packageName}`,
+ iconUrl: release.iconPath,
+ name: application.name,
+ };
+ });
+
+ this.setState({
+ loading: false,
+ applications,
+ });
+ }
+ })
+ .catch(error => {
+ if (error.hasOwnProperty('response') && error.response.status === 401) {
+ message.error('You are not logged in');
+ window.location.href = window.location.origin + '/publisher/login';
+ } else {
+ notification.error({
+ message: 'There was a problem',
+ duration: 0,
+ description: 'Error occurred while trying to load pages.',
+ });
+ }
+
+ this.setState({ loading: false });
+ });
+ };
+
+ toggleAddNewClusterVisibility = isAddNewClusterVisible => {
+ this.setState({
+ isAddNewClusterVisible,
+ });
+ };
+
+ addSavedClusterToThePage = cluster => {
+ this.setState({
+ clusters: [...this.state.clusters, cluster],
+ isAddNewClusterVisible: false,
+ });
+ window.scrollTo(0, document.body.scrollHeight);
+ };
+
+ updateLinks = links => {
+ this.setState({
+ links,
+ });
+ };
+
+ render() {
+ const {
+ pageName,
+ loading,
+ clusters,
+ applications,
+ isAddNewClusterVisible,
+ links,
+ } = this.state;
+ return (
+
+
+
+
+
+ Home
+
+
+ Manage
+
+
+ Android Enterprise
+
+
+ Manage Page
+
+
+
Manage Android Enterprise
+ {/*
Lorem ipsum */}
+
+
+
+
+
+
+
+ {pageName}
+
+
+
+
+
+ Links
+ {links.map(link => {
+ if (this.pageNames.hasOwnProperty(link.toString())) {
+ return (
+
+ {this.pageNames[link.toString()]}
+
+ );
+ }
+ return null;
+ })}
+
+
+ {/* */}
+
+ {/* */}
+
+
+
+
Clusters
+
+
+ {
+ this.toggleAddNewClusterVisibility(true);
+ }}
+ >
+ Add new cluster
+
+
+
+
- );
- }
+ {clusters.map((cluster, index) => {
+ return (
+
+ );
+ })}
+
+
+
+ );
+ }
}
export default withConfigContext(withRouter(Page));
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/serviceWorker.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/serviceWorker.js
index 249177c0b0..da52a982ac 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/serviceWorker.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/serviceWorker.js
@@ -34,8 +34,8 @@ const isLocalhost = Boolean(
window.location.hostname === '[::1]' ||
// 127.0.0.1/8 is considered localhost for IPv4.
window.location.hostname.match(
- /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
- )
+ /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/,
+ ),
);
export function register(config) {
@@ -61,7 +61,7 @@ export function register(config) {
navigator.serviceWorker.ready.then(() => {
console.log(
'This web app is being served cache-first by a service ' +
- 'worker. To learn more, visit https://bit.ly/CRA-PWA'
+ 'worker. To learn more, visit https://bit.ly/CRA-PWA',
);
});
} else {
@@ -89,7 +89,7 @@ function registerValidSW(swUrl, config) {
// content until all client tabs are closed.
console.log(
'New content is available and will be used when all ' +
- 'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
+ 'tabs for this page are closed. See https://bit.ly/CRA-PWA.',
);
// Execute callback
@@ -139,7 +139,7 @@ function checkValidServiceWorker(swUrl, config) {
})
.catch(() => {
console.log(
- 'No internet connection found. App is running in offline mode.'
+ 'No internet connection found. App is running in offline mode.',
);
});
}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/webpack.config.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/webpack.config.js
index 7094474a56..70a6d8396b 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/webpack.config.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/webpack.config.js
@@ -17,119 +17,119 @@
*/
var path = require('path');
-const HtmlWebPackPlugin = require("html-webpack-plugin");
-const MiniCssExtractPlugin = require("mini-css-extract-plugin");
-const configurations = require("./public/conf/config.json");
+const HtmlWebPackPlugin = require('html-webpack-plugin');
+const MiniCssExtractPlugin = require('mini-css-extract-plugin');
+const configurations = require('./public/conf/config.json');
const config = {
- devtool: "source-map",
- output: {
- publicPath: '/publisher/'
+ devtool: 'source-map',
+ output: {
+ publicPath: '/publisher/',
+ },
+ watch: false,
+ resolve: {
+ alias: {
+ AppData: path.resolve(__dirname, 'source/src/app/common/'),
+ AppComponents: path.resolve(__dirname, 'source/src/app/components/'),
},
- watch: false,
- resolve: {
- alias: {
- AppData: path.resolve(__dirname, 'source/src/app/common/'),
- AppComponents: path.resolve(__dirname, 'source/src/app/components/')
- },
- extensions: ['.jsx', '.js', '.ttf', '.woff', '.woff2', '.svg']
- },
- module: {
- rules: [
- {
- test: /\.(js|jsx)$/,
- exclude: /node_modules/,
- use: [
- {
- loader: 'babel-loader'
- }
- ]
- },
- {
- test: /\.html$/,
- use: [
- {
- loader: "html-loader",
- options: {minimize: true}
- }
- ]
- },
- {
- test: /\.css$/,
- use: [MiniCssExtractPlugin.loader, "css-loader"]
- },
- {
- test: /\.scss$/,
- use: [
- MiniCssExtractPlugin.loader,
- "css-loader",
- "postcss-loader",
- "sass-loader"
- ]
+ extensions: ['.jsx', '.js', '.ttf', '.woff', '.woff2', '.svg'],
+ },
+ module: {
+ rules: [
+ {
+ test: /\.(js|jsx)$/,
+ exclude: /node_modules/,
+ use: [
+ {
+ loader: 'babel-loader',
+ },
+ ],
+ },
+ {
+ test: /\.html$/,
+ use: [
+ {
+ loader: 'html-loader',
+ options: { minimize: true },
+ },
+ ],
+ },
+ {
+ test: /\.css$/,
+ use: [MiniCssExtractPlugin.loader, 'css-loader'],
+ },
+ {
+ test: /\.scss$/,
+ use: [
+ MiniCssExtractPlugin.loader,
+ 'css-loader',
+ 'postcss-loader',
+ 'sass-loader',
+ ],
+ },
+ {
+ test: /\.scss$/,
+ use: ['style-loader', 'scss-loader'],
+ },
+ {
+ test: /\.less$/,
+ use: [
+ {
+ loader: 'style-loader',
+ },
+ {
+ loader: 'css-loader',
+ },
+ {
+ loader: 'less-loader',
+ options: {
+ modifyVars: {
+ 'primary-color': configurations.theme.primaryColor,
+ 'link-color': configurations.theme.primaryColor,
+ },
+ javascriptEnabled: true,
},
- {
- test: /\.scss$/,
- use: ['style-loader', 'scss-loader']
+ },
+ ],
+ },
+ {
+ test: /\.(woff|woff2|eot|ttf|svg)$/,
+ loader: 'url-loader?limit=100000',
+ },
+ {
+ test: /\.(png|jpe?g)/i,
+ use: [
+ {
+ loader: 'url-loader',
+ options: {
+ name: './img/[name].[ext]',
+ limit: 10000,
},
- {
- test: /\.less$/,
- use: [
- {
- loader: "style-loader"
- },
- {
- loader: "css-loader"
- },
- {
- loader: "less-loader",
- options: {
- modifyVars: {
- 'primary-color': configurations.theme.primaryColor,
- 'link-color': configurations.theme.primaryColor,
- },
- javascriptEnabled: true,
- },
- }
- ]
- },
- {
- test: /\.(woff|woff2|eot|ttf|svg)$/,
- loader: 'url-loader?limit=100000',
- },
- {
- test: /\.(png|jpe?g)/i,
- use: [
- {
- loader: "url-loader",
- options: {
- name: "./img/[name].[ext]",
- limit: 10000
- }
- },
- {
- loader: "img-loader"
- }
- ]
- }
- ]
- },
- plugins: [
- new HtmlWebPackPlugin({
- template: "./src/index.html",
- filename: "./index.html"
- }),
- new MiniCssExtractPlugin({
- filename: "[name].css",
- chunkFilename: "[id].css"
- })
+ },
+ {
+ loader: 'img-loader',
+ },
+ ],
+ },
],
- externals: {
- 'Config': JSON.stringify(require('./public/conf/config.json'))
- }
+ },
+ plugins: [
+ new HtmlWebPackPlugin({
+ template: './src/index.html',
+ filename: './index.html',
+ }),
+ new MiniCssExtractPlugin({
+ filename: '[name].css',
+ chunkFilename: '[id].css',
+ }),
+ ],
+ externals: {
+ Config: JSON.stringify(require('./public/conf/config.json')),
+ },
};
-if (process.env.NODE_ENV === "development") {
- config.watch = true;
+if (process.env.NODE_ENV === 'development') {
+ config.watch = true;
}
module.exports = config;