{getFieldDecorator('meta', {})(
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 1fa47170e90..abaea5dbe97 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
@@ -41,7 +41,10 @@ class AddNewReleaseFormComponent extends React.Component {
supportedOsVersions: [],
application: null,
release: null,
- deviceType: null
+ deviceType: null,
+ forbiddenErrors: {
+ supportedOsVersions: false
+ }
};
}
@@ -63,10 +66,19 @@ class AddNewReleaseFormComponent extends React.Component {
});
}
}).catch((error) => {
- handleApiError(error, "Error occurred while trying to load supported OS versions.");
- this.setState({
- loading: false
- });
+ 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
+ });
+ }
});
};
@@ -85,7 +97,7 @@ class AddNewReleaseFormComponent extends React.Component {
data.append("applicationRelease", blob);
const url = window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.publisher +
- "/applications/" + deviceType + "/ent-app/" + appId;
+ "/applications/" + deviceType + "/ent-app/" + appId;
axios.post(
url,
data
@@ -122,14 +134,15 @@ class AddNewReleaseFormComponent extends React.Component {
};
render() {
- const {loading, supportedOsVersions} = this.state;
+ const {loading, supportedOsVersions, forbiddenErrors} = this.state;
return (
-
+
{
+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}`;
- } else {
+ // silence 403 forbidden message
+ } else if (!(isForbiddenMessageSilent && error.hasOwnProperty("response") && error.response.status === 403)) {
notification["error"]({
message: "There was a problem",
duration: 10,
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 40fd63a0ba0..fc653d7bf40 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
@@ -24,6 +24,7 @@ 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";
const {Title} = Typography;
@@ -40,13 +41,19 @@ class Release extends React.Component {
release: null,
currentLifecycleStatus: null,
lifecycle: null,
- supportedOsVersions:[]
+ supportedOsVersions: [],
+ forbiddenErrors: {
+ supportedOsVersions: false,
+ lifeCycle: false
+ }
};
}
componentDidMount() {
const {uuid} = this.props.match.params;
this.fetchData(uuid);
+ this.getLifecycle();
+
}
componentDidUpdate(prevProps, prevState, snapshot) {
@@ -86,10 +93,8 @@ class Release extends React.Component {
loading: false,
uuid: uuid
});
- if(config.deviceTypes.mobileTypes.includes(app.deviceType)){
+ if (config.deviceTypes.mobileTypes.includes(app.deviceType)) {
this.getSupportedOsVersions(app.deviceType);
- }else{
- this.getLifecycle();
}
}
@@ -111,8 +116,15 @@ class Release extends React.Component {
})
}
- }).catch(function (error) {
- handleApiError(error, "Error occurred while trying to load lifecycle configuration.");
+ }).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
+ })
+ }
});
};
@@ -125,21 +137,28 @@ class Release extends React.Component {
if (res.status === 200) {
let supportedOsVersions = JSON.parse(res.data.data);
this.setState({
- supportedOsVersions,
- loading: false,
+ supportedOsVersions
});
- this.getLifecycle();
}
}).catch((error) => {
- handleApiError(error, "Error occurred while trying to load supported OS versions.");
- this.setState({
- loading: false
- });
+ 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} = this.state;
+ const {app, release, currentLifecycleStatus, lifecycle, loading, forbiddenErrors} = this.state;
if (release == null && loading === false) {
return (
@@ -159,12 +178,13 @@ class Release extends React.Component {
{(release !== null) && (
)
}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/AppCard.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/AppCard.js
index e60e8652a1e..64d155299f0 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/AppCard.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/AppCard.js
@@ -50,7 +50,7 @@ class AppCard extends React.Component {
{app.name}
- {app.subMethod.toLowerCase()}
+ {app.type.toLowerCase()}
{
if (res.status === 200) {
@@ -73,18 +76,37 @@ class AppList extends React.Component {
}
}).catch((error) => {
- handleApiError(error,"Error occurred while trying to load apps.");
- this.setState({loading: false});
+ handleApiError(error, "Error occurred while trying to load apps.", true);
+ if (error.hasOwnProperty("response") && error.response.status === 403) {
+ const {forbiddenErrors} = this.state;
+ forbiddenErrors.apps = true;
+ this.setState({
+ forbiddenErrors,
+ loading: false
+ })
+ } else {
+ this.setState({
+ loading: false
+ });
+ }
});
};
render() {
- const {apps,loading} = this.state;
+ const {apps, loading, forbiddenErrors} = this.state;
return (
- {apps.length === 0 && (
+ {(forbiddenErrors.apps) && (
+ Back Home}
+ />
+ )}
+ {!((forbiddenErrors.apps)) && apps.length === 0 && (
-
+
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/InstalledDevicesTable.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/SubscriptionDetails.js
similarity index 78%
rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/InstalledDevicesTable.js
rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/SubscriptionDetails.js
index 39fd3ef27c7..be71eb4e8f8 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/InstalledDevicesTable.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/SubscriptionDetails.js
@@ -18,7 +18,20 @@
import React from "react";
import axios from "axios";
-import {Tag, message, notification, Table, Typography, Tooltip, Icon, Divider, Button, Modal, Select} from "antd";
+import {
+ Tag,
+ message,
+ notification,
+ Table,
+ Typography,
+ Tooltip,
+ Icon,
+ Divider,
+ Button,
+ Modal,
+ Select,
+ Alert
+} from "antd";
import TimeAgo from 'javascript-time-ago'
// Load locale-specific relative date/time formatting rules.
@@ -53,7 +66,16 @@ const columns = [
title: 'Action',
dataIndex: 'action',
key: 'action',
- render: action => action.toLowerCase()
+ render: action => {
+ action = action.toLowerCase();
+ let color = "fff";
+ if(action==="subscribed"){
+ color = "#6ab04c"
+ }else if(action === "unsubscribed"){
+ color = "#f0932b"
+ }
+ return {action}
+ }
},
{
title: 'Triggered By',
@@ -128,7 +150,7 @@ const getTimeAgo = (time) => {
};
-class InstalledDevicesTable extends React.Component {
+class SubscriptionDetails extends React.Component {
constructor(props) {
super(props);
config = this.props.context;
@@ -140,7 +162,8 @@ class InstalledDevicesTable extends React.Component {
selectedRows: [],
deviceGroups: [],
groupModalVisible: false,
- selectedGroupId: []
+ selectedGroupId: [],
+ isForbidden: false
};
}
@@ -171,18 +194,25 @@ class InstalledDevicesTable extends React.Component {
`/admin/subscription/${this.props.uuid}?` + encodedExtraParams,
).then(res => {
if (res.status === 200) {
- const pagination = {...this.state.pagination};
console.log(res.data.data.data);
this.setState({
loading: false,
- data: res.data.data.data,
- pagination,
+ data: res.data.data.data
});
}
}).catch((error) => {
- handleApiError(error, "Something went wrong when trying to load subscription data.");
- this.setState({loading: false});
+ handleApiError(error, "Something went wrong when trying to load subscription data.", true);
+ if (error.hasOwnProperty("response") && error.response.status === 403) {
+ this.setState({
+ isForbidden: true,
+ loading: false
+ })
+ } else {
+ this.setState({
+ loading: false
+ });
+ }
});
};
@@ -190,11 +220,23 @@ class InstalledDevicesTable extends React.Component {
const {data, pagination, loading, selectedRows} = this.state;
return (
+ {(this.state.isForbidden) && (
+
+ )}
- The following are the subscription details of the application in each respective device.
+ The following are the subscription details of the application in each respective device.
+
+
+ Refresh
+
+
(record.device.deviceIdentifier + record.device.enrolmentInfo.owner + record.device.enrolmentInfo.ownership)}
@@ -214,4 +256,4 @@ class InstalledDevicesTable extends React.Component {
}
}
-export default withConfigContext(InstalledDevicesTable);
\ No newline at end of file
+export default withConfigContext(SubscriptionDetails);
\ No newline at end of file
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js
index 3e67c54c033..ed69db96eff 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/DeviceInstall.js
@@ -18,7 +18,7 @@
import React from "react";
import axios from "axios";
-import {Button, message, DatePicker, Table, Typography} from "antd";
+import {Button, message, DatePicker, Table, Typography, Alert} from "antd";
import TimeAgo from 'javascript-time-ago'
// Load locale-specific relative date/time formatting rules.
@@ -112,7 +112,8 @@ class DeviceInstall extends React.Component {
loading: false,
selectedRows: [],
scheduledTime: null,
- isScheduledInstallVisible: false
+ isScheduledInstallVisible: false,
+ isForbidden: false
};
}
@@ -169,8 +170,17 @@ class DeviceInstall extends React.Component {
}
}).catch((error) => {
- handleApiError(error, "Error occurred while trying to load devices.");
- this.setState({loading: false});
+ handleApiError(error, "Error occurred while trying to load devices.", true);
+ if (error.hasOwnProperty("response") && error.response.status === 403) {
+ this.setState({
+ isForbidden: true,
+ loading: false
+ })
+ } else {
+ this.setState({
+ loading: false
+ });
+ }
});
};
@@ -209,6 +219,13 @@ class DeviceInstall extends React.Component {
Start installing the application for one or more users by entering the corresponding user name.
Select install to automatically start downloading the application for the respective user/users.
+ {(this.state.isForbidden) && (
+
+ )}
{
- handleApiError(error, "Error occurred while trying to load devices.");
- this.setState({loading: false});
+ handleApiError(error, "Error occurred while trying to load devices.", true);
+ if (error.hasOwnProperty("response") && error.response.status === 403) {
+ this.setState({
+ isForbidden: true,
+ loading: false
+ })
+ } else {
+ this.setState({
+ loading: false
+ });
+ }
});
};
@@ -204,6 +214,13 @@ class DeviceUninstall extends React.Component {
Start uninstalling the application for devices by selecting the corresponding devices.
Select uninstall to automatically start uninstalling the application for the respective devices.
+ {(this.state.isForbidden) && (
+
+ )}
{
@@ -67,8 +68,17 @@ class GroupInstall extends React.Component {
}
}).catch((error) => {
- handleApiError(error,"Error occurred while trying to load groups.");
- this.setState({fetching: false});
+ handleApiError(error,"Error occurred while trying to load groups.", true);
+ if (error.hasOwnProperty("response") && error.response.status === 403) {
+ this.setState({
+ isForbidden: true,
+ loading: false
+ })
+ } else {
+ this.setState({
+ loading: false
+ });
+ }
});
};
@@ -96,6 +106,13 @@ class GroupInstall extends React.Component {
return (
Start installing the application for one or more groups by entering the corresponding group name. Select install to automatically start downloading the application for the respective device group/ groups.
+ {(this.state.isForbidden) && (
+
+ )}
{
@@ -50,9 +51,8 @@ class GroupUninstall extends React.Component {
const uuid = this.props.uuid;
axios.get(
- window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.store+ "/subscription/" + uuid + "/"+
- "/GROUP?",
-
+ window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/subscription/" + uuid + "/" +
+ "/GROUP?",
).then(res => {
if (res.status === 200) {
if (fetchId !== this.lastFetchId) {
@@ -69,8 +69,17 @@ class GroupUninstall extends React.Component {
}
}).catch((error) => {
- handleApiError(error,"Error occurred while trying to load groups.");
- this.setState({fetching: false});
+ handleApiError(error, "Error occurred while trying to load groups.", true);
+ if (error.hasOwnProperty("response") && error.response.status === 403) {
+ this.setState({
+ isForbidden: true,
+ loading: false
+ })
+ } else {
+ this.setState({
+ loading: false
+ });
+ }
});
};
@@ -82,13 +91,13 @@ class GroupUninstall extends React.Component {
});
};
- uninstall = (timestamp=null) =>{
+ uninstall = (timestamp = null) => {
const {value} = this.state;
const data = [];
- value.map(val=>{
+ value.map(val => {
data.push(val.key);
});
- this.props.onUninstall("group", data, "uninstall",timestamp);
+ this.props.onUninstall("group", data, "uninstall", timestamp);
};
render() {
@@ -96,26 +105,35 @@ class GroupUninstall extends React.Component {
const {fetching, data, value} = this.state;
return (
-
- Start uninstalling the application for one or more groups by entering the corresponding group name. Select uninstall to automatically start uninstalling the application for the respective device group/ groups.
-
-
- : null}
- filterOption={false}
- onSearch={this.fetchUser}
- onChange={this.handleChange}
- style={{width: '100%'}}>
- {data.map(d => (
- {d.text}
- ))}
-
-
-
+
+
Start uninstalling the application for one or more groups by entering the corresponding group
+ name. Select uninstall to automatically start uninstalling the application for the respective device
+ group/ groups.
+ {(this.state.isForbidden) && (
+
+ )}
+
+
+
: null}
+ filterOption={false}
+ onSearch={this.fetchUser}
+ onChange={this.handleChange}
+ style={{width: '100%'}}>
+ {data.map(d => (
+
{d.text}
+ ))}
+
+
+
);
}
}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/RoleInstall.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/RoleInstall.js
index 276ba34ab37..063311953ab 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/RoleInstall.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/RoleInstall.js
@@ -17,7 +17,7 @@
*/
import React from "react";
-import {Typography, Select, Spin, message, notification, Button} from "antd";
+import {Typography, Select, Spin, message, notification, Button, Alert} from "antd";
import debounce from 'lodash.debounce';
import axios from "axios";
import {withConfigContext} from "../../../../context/ConfigContext";
@@ -40,6 +40,7 @@ class RoleInstall extends React.Component {
data: [],
value: [],
fetching: false,
+ isForbidden: false
};
fetchUser = value => {
@@ -67,8 +68,17 @@ class RoleInstall extends React.Component {
}
}).catch((error) => {
- handleApiError(error,"Error occurred while trying to load roles.");
- this.setState({fetching: false});
+ handleApiError(error,"Error occurred while trying to load roles.", true);
+ if (error.hasOwnProperty("response") && error.response.status === 403) {
+ this.setState({
+ isForbidden: true,
+ loading: false
+ })
+ } else {
+ this.setState({
+ loading: false
+ });
+ }
});
};
@@ -96,6 +106,13 @@ class RoleInstall extends React.Component {
return (
Start installing the application for one or more roles by entering the corresponding role name. Select install to automatically start downloading the application for the respective user role/roles.
+ {(this.state.isForbidden) && (
+
+ )}
+ style={{width: '100%'}}>
{data.map(d => (
{d.text}
))}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/RoleUninstall.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/RoleUninstall.js
index 5e7462de3cd..0076e80b70a 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/RoleUninstall.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/RoleUninstall.js
@@ -17,7 +17,7 @@
*/
import React from "react";
-import {Typography, Select, Spin, message, notification, Button} from "antd";
+import {Typography, Select, Spin, message, notification, Button, Alert} from "antd";
import debounce from 'lodash.debounce';
import axios from "axios";
import {withConfigContext} from "../../../../context/ConfigContext";
@@ -39,6 +39,7 @@ class RoleUninstall extends React.Component {
data: [],
value: [],
fetching: false,
+ isForbidden: false
};
fetchUser = value => {
@@ -50,8 +51,8 @@ class RoleUninstall extends React.Component {
const uuid = this.props.uuid;
axios.get(
- window.location.origin+ config.serverConfig.invoker.uri + config.serverConfig.invoker.store+ "/subscription/" + uuid + "/"+
- "/ROLE?",
+ window.location.origin + config.serverConfig.invoker.uri + config.serverConfig.invoker.store + "/subscription/" + uuid + "/" +
+ "/ROLE?",
).then(res => {
if (res.status === 200) {
if (fetchId !== this.lastFetchId) {
@@ -68,53 +69,71 @@ class RoleUninstall extends React.Component {
}
}).catch((error) => {
- handleApiError(error,"Error occurred while trying to load roles.");
- this.setState({fetching: false});
+ handleApiError(error, "Error occurred while trying to load roles.", true);
+ if (error.hasOwnProperty("response") && error.response.status === 403) {
+ this.setState({
+ isForbidden: true,
+ loading: false
+ })
+ } else {
+ this.setState({
+ loading: false
+ });
+ }
});
};
handleChange = value => {
this.setState({
- value,
- data: [],
- fetching: false,
- });
+ value,
+ data: [],
+ fetching: false,
+ });
};
- uninstall = (timestamp=null) =>{
+ uninstall = (timestamp = null) => {
const {value} = this.state;
const data = [];
- value.map(val=>{
+ value.map(val => {
data.push(val.key);
});
- this.props.onUninstall("role", data, "uninstall",timestamp);
+ this.props.onUninstall("role", data, "uninstall", timestamp);
};
render() {
const {fetching, data, value} = this.state;
return (
-
- Start uninstalling the application for one or more roles by entering the corresponding role name. Select uninstall to automatically start uninstalling the application for the respective user role/roles.
-
-
- : null}
- filterOption={false}
- onSearch={this.fetchUser}
- onChange={this.handleChange}
- style={{width: '100%'}}
- >
- {data.map(d => (
- {d.text}
- ))}
-
-
-
+
+
Start uninstalling the application for one or more roles by entering the corresponding role name.
+ Select uninstall to automatically start uninstalling the application for the respective user
+ role/roles.
+ {(this.state.isForbidden) && (
+
+ )}
+
+
+
: null}
+ filterOption={false}
+ onSearch={this.fetchUser}
+ onChange={this.handleChange}
+ style={{width: '100%'}}
+ >
+ {data.map(d => (
+
{d.text}
+ ))}
+
+
+
);
}
}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/UserInstall.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/UserInstall.js
index 82f91bddff4..ddac89bcabe 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/UserInstall.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/install/UserInstall.js
@@ -17,7 +17,7 @@
*/
import React from "react";
-import {Typography, Select, Spin, message, notification, Button} from "antd";
+import {Typography, Select, Spin, message, notification, Button, Alert} from "antd";
import debounce from 'lodash.debounce';
import axios from "axios";
import {withConfigContext} from "../../../../context/ConfigContext";
@@ -69,8 +69,17 @@ class UserInstall extends React.Component {
}
}).catch((error) => {
- handleApiError(error,"Error occurred while trying to load users.");
- this.setState({fetching: false});
+ handleApiError(error,"Error occurred while trying to load users.", true);
+ if (error.hasOwnProperty("response") && error.response.status === 403) {
+ this.setState({
+ isForbidden: true,
+ loading: false
+ })
+ } else {
+ this.setState({
+ loading: false
+ });
+ }
});
};
@@ -79,6 +88,7 @@ class UserInstall extends React.Component {
value,
data: [],
fetching: false,
+ isForbidden: false
});
};
@@ -97,6 +107,13 @@ class UserInstall extends React.Component {
return (
Start installing the application for one or more users by entering the corresponding user name. Select install to automatically start downloading the application for the respective user/users.
+ {(this.state.isForbidden) && (
+
+ )}
Select users
{
@@ -67,8 +68,17 @@ class UserUninstall extends React.Component {
}
}).catch((error) => {
- handleApiError(error, "Error occurred while trying to load users.");
- this.setState({fetching: false});
+ handleApiError(error, "Error occurred while trying to load users.", true);
+ if (error.hasOwnProperty("response") && error.response.status === 403) {
+ this.setState({
+ isForbidden: true,
+ loading: false
+ })
+ } else {
+ this.setState({
+ loading: false
+ });
+ }
});
};
@@ -97,6 +107,13 @@ class UserUninstall extends React.Component {
Start uninstalling the application for one or more users by entering the corresponding user name.
Select uninstall to automatically start uninstalling the application for the respective
user/users.
+ {(this.state.isForbidden) && (
+
+ )}
Select users
MY REVIEW
-
- {currentUserReviews.length > 0 && (
-
- (
-
-
-
- )}
- >
-
-
- )}
+ {(this.props.forbidden) && (
+
+ )}
+ {(!this.props.forbidden) && (
+
+ {currentUserReviews.length > 0 && (
+
+ (
+
+
+
+ )}
+ >
+
+
+ )}
- {currentUserReviews.length === 0 && (
-
-
Share your experience with your community by adding a review.
- }
- >
- {/*Add review */}
-
-
-
- )}
-
-
+ {currentUserReviews.length === 0 && (
+
+
Share your experience with your community by adding a review.
+ }>
+ {/*Add review */}
+
+
+
+ )}
+
+ )}
);
}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/ReviewContainer.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/ReviewContainer.js
index 2b8f124cb2a..291d032939a 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/ReviewContainer.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/apps/release/review/ReviewContainer.js
@@ -32,7 +32,12 @@ class ReviewContainer extends React.Component {
super(props);
this.state = {
currentUserReviews: [],
- detailedRating: null
+ detailedRating: null,
+ forbiddenErrors: {
+ currentReview: false,
+ reviews: false,
+ rating: false
+ }
}
}
@@ -54,7 +59,19 @@ class ReviewContainer extends React.Component {
}
}).catch((error) => {
- handleApiError(error, "Error occurred while trying to get your review.");
+ handleApiError(error, "Error occurred while trying to get your review.", true);
+ if (error.hasOwnProperty("response") && error.response.status === 403) {
+ const {forbiddenErrors} = this.state;
+ forbiddenErrors.currentReview = true;
+ this.setState({
+ forbiddenErrors,
+ loading: false
+ })
+ } else {
+ this.setState({
+ loading: false
+ });
+ }
});
};
@@ -79,7 +96,7 @@ class ReviewContainer extends React.Component {
}
}).catch(function (error) {
- handleApiError(error, "Error occurred while trying to load ratings.");
+ handleApiError(error, "Error occurred while trying to load ratings.", true);
});
};
@@ -90,10 +107,11 @@ class ReviewContainer extends React.Component {
render() {
const {uuid} = this.props;
- const {currentUserReviews,detailedRating} = this.state;
+ const {currentUserReviews,detailedRating, forbiddenErrors} = this.state;
return (
{
@@ -60,8 +63,20 @@ class Reviews extends React.Component {
callback(reviews);
}
- }).catch(function (error) {
- handleApiError(error,"Error occurred while trying to load reviews.");
+ }).catch((error) => {
+ handleApiError(error, "Error occurred while trying to load reviews.", true);
+ if (error.hasOwnProperty("response") && error.response.status === 403) {
+ const {forbiddenErrors} = this.state;
+ forbiddenErrors.reviews = true;
+ this.setState({
+ forbiddenErrors,
+ loading: false
+ })
+ } else {
+ this.setState({
+ loading: false
+ });
+ }
});
};
@@ -101,7 +116,7 @@ class Reviews extends React.Component {
});
};
- deleteCallback = () =>{
+ deleteCallback = () => {
this.fetchData(0, limit, res => {
this.setState({
data: res,
@@ -114,30 +129,40 @@ class Reviews extends React.Component {
const {loading, hasMore, data, loadMore} = this.state;
const {uuid} = this.props;
return (
-
-
- (
-
-
-
- )}>
- {loading && hasMore && (
-
-
-
- )}
-
-
- {!loadMore && (data.length >= limit) && (
- Read All Reviews
-
)}
+
+ {(this.state.forbiddenErrors.reviews) && (
+
+ )}
+
+
+ (
+
+
+
+ )}>
+ {loading && hasMore && (
+
+
+
+ )}
+
+
+ {!loadMore && (data.length >= limit) && (
+ Read All Reviews
+
)}
+
);
}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/js/Utils.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/js/Utils.js
index 7bdcef3eeaa..aea33339854 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/js/Utils.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/js/Utils.js
@@ -18,14 +18,15 @@
import {notification} from "antd";
-export const handleApiError = (error, 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 + `/store/login?redirect=${redirectUrl}`;
- } else {
+ // silence 403 forbidden message
+ } else if (!(isForbiddenMessageSilent && error.hasOwnProperty("response") && error.response.status === 403)) {
notification["error"]({
message: "There was a problem",
- duration: 2,
+ duration: 10,
description: message,
});
}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/Dashboard.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/Dashboard.js
index 30c7da2df18..b0a5108ddf4 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/Dashboard.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/Dashboard.js
@@ -17,7 +17,8 @@
*/
import React from "react";
-import {Layout, Menu, Icon, Drawer, Button} from 'antd';
+import {Layout, Menu, Icon, Drawer, Button, Alert} from 'antd';
+
const {Header, Content, Footer} = Layout;
import {Link} from "react-router-dom";
import RouteWithSubRoutes from "../../components/RouteWithSubRoutes";
@@ -38,7 +39,10 @@ class Dashboard extends React.Component {
selectedKeys: [],
deviceTypes: [],
visible: false,
- collapsed: false
+ collapsed: false,
+ forbiddenErrors: {
+ deviceTypes: false
+ }
};
this.logo = this.props.context.theme.logo;
this.config = this.props.context;
@@ -62,10 +66,19 @@ class Dashboard extends React.Component {
}
}).catch((error) => {
- handleApiError(error,"Error occurred while trying to load device types.");
- this.setState({
- loading: false
- });
+ 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
+ });
+ }
});
};
@@ -81,7 +94,7 @@ class Dashboard extends React.Component {
collapsed: !this.state.collapsed,
});
};
-
+
onCloseMobileNavigationBar = () => {
this.setState({
visible: false,
@@ -90,7 +103,7 @@ class Dashboard extends React.Component {
render() {
const config = this.props.context;
- const {selectedKeys, deviceTypes} = this.state;
+ const {selectedKeys, deviceTypes, forbiddenErrors} = this.state;
const DeviceTypesData = deviceTypes.map((deviceType) => {
const platform = deviceType.name;
@@ -116,7 +129,7 @@ class Dashboard extends React.Component {
-
+
@@ -131,7 +144,7 @@ class Dashboard extends React.Component {
- Web Clips
+ Web Clips
@@ -140,7 +153,7 @@ class Dashboard extends React.Component {
{this.config.user}
- }>
+ }>
@@ -156,32 +169,32 @@ class Dashboard extends React.Component {
-
-
- }
- placement="left"
- closable={false}
- onClose={this.onCloseMobileNavigationBar}
- visible={this.state.visible}
- getContainer={false}
- style={{position: 'absolute'}}>
-
-
- {DeviceTypesData}
-
-
-
+
+
+ }
+ placement="left"
+ closable={false}
+ onClose={this.onCloseMobileNavigationBar}
+ visible={this.state.visible}
+ getContainer={false}
+ style={{position: 'absolute'}}>
+
+
+ {DeviceTypesData}
+
+
+
Web Clips
-
-
-
-
+
+
+
+
+ {(forbiddenErrors.deviceTypes) && (
+
+ )}
{this.state.routes.map((route) => (
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/apps/release/Release.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/apps/release/Release.js
index adac67e7378..80cfe2b9cb7 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/apps/release/Release.js
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/pages/dashboard/apps/release/Release.js
@@ -36,7 +36,10 @@ class Release extends React.Component {
this.state = {
loading: true,
app: null,
- uuid: null
+ uuid: null,
+ forbiddenErrors: {
+ app: false
+ }
};
}
@@ -72,8 +75,19 @@ class Release extends React.Component {
}
}).catch((error) => {
- handleApiError(error,"Error occurred while trying to load releases.");
- this.setState({loading: false});
+ handleApiError(error,"Error occurred while trying to load releases.", false);
+ if (error.hasOwnProperty("response") && error.response.status === 403) {
+ const {forbiddenErrors} = this.state;
+ forbiddenErrors.app = true;
+ this.setState({
+ forbiddenErrors,
+ loading: false
+ })
+ } else {
+ this.setState({
+ loading: false
+ });
+ }
});
};