From aaf6f647ec5fe8650ec814d3a43a4f751a3f68f1 Mon Sep 17 00:00:00 2001 From: Jayasanka Weerasinghe Date: Mon, 6 Apr 2020 15:28:16 +0530 Subject: [PATCH] Add permission based access control to APPM store --- .../react-app/package.json | 2 +- .../react-app/public/conf/config.json | 2 +- .../react-app/src/App.js | 78 ++++++--- .../src/components/Authorized/index.js | 27 ++++ .../react-app/src/scenes/Home/index.js | 2 +- .../scenes/Apps/components/AppList/index.js | 35 +--- .../src/scenes/Home/scenes/Apps/index.js | 20 ++- .../components/ImageViewer/index.js | 0 .../Install/components/DeviceInstall/index.js | 4 +- .../Install/components/GroupInstall/index.js | 4 +- .../Install/components/RoleInstall/index.js | 4 +- .../Install/components/UserInstall/index.js | 4 +- .../ReleaseView/components/Install/index.js | 0 .../components/AddReview/index.js | 4 +- .../componets/CurrentUsersReview/index.js | 87 +++++----- .../ReviewContainer/componets/Rating/index.js | 2 +- .../componets/Rating/styles.css | 0 .../Review/components/Edit/index.js | 4 +- .../Review/components/Edit/styles.css | 0 .../Reviews/components/Review/index.js | 45 ++++-- .../Reviews/components/Review/styles.css | 0 .../componets/Reviews/index.js | 4 +- .../componets/Reviews/styles.css | 0 .../components/ReviewContainer/index.js | 62 ++++---- .../components/SubscriptionDetails/index.js | 86 +++++----- .../components/DeviceUninstall/index.js | 4 +- .../components/GroupUninstall/index.js | 4 +- .../components/RoleUninstall/index.js | 4 +- .../components/UserUninstall/index.js | 4 +- .../ReleaseView/components/Uninstall/index.js | 0 .../components/installModalFooter/index.js | 0 .../components}/ReleaseView/index.js | 72 +++++---- .../Release/components/ReleasePage/index.js | 135 ++++++++++++++++ .../Home/scenes/Apps/scenes/Release/index.js | 149 +++--------------- 34 files changed, 479 insertions(+), 369 deletions(-) create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/Authorized/index.js rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/components/ImageViewer/index.js (100%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/components/Install/components/DeviceInstall/index.js (98%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/components/Install/components/GroupInstall/index.js (97%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/components/Install/components/RoleInstall/index.js (97%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/components/Install/components/UserInstall/index.js (97%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/components/Install/index.js (100%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/components/ReviewContainer/componets/CurrentUsersReview/components/AddReview/index.js (97%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/components/ReviewContainer/componets/CurrentUsersReview/index.js (57%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/components/ReviewContainer/componets/Rating/index.js (98%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/components/ReviewContainer/componets/Rating/styles.css (100%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/components/ReviewContainer/componets/Reviews/components/Review/components/Edit/index.js (97%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/components/ReviewContainer/componets/Reviews/components/Review/components/Edit/styles.css (100%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/components/ReviewContainer/componets/Reviews/components/Review/index.js (76%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/components/ReviewContainer/componets/Reviews/components/Review/styles.css (100%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/components/ReviewContainer/componets/Reviews/index.js (98%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/components/ReviewContainer/componets/Reviews/styles.css (100%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/components/ReviewContainer/index.js (72%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/components/SubscriptionDetails/index.js (78%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/components/Uninstall/components/DeviceUninstall/index.js (98%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/components/Uninstall/components/GroupUninstall/index.js (97%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/components/Uninstall/components/RoleUninstall/index.js (97%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/components/Uninstall/components/UserUninstall/index.js (97%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/components/Uninstall/index.js (100%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/components/installModalFooter/index.js (100%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/{ => ReleasePage/components}/ReleaseView/index.js (81%) create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/index.js diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/package.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/package.json index 56aa61b49b..ff1ed9d713 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/package.json +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/package.json @@ -85,7 +85,7 @@ "start": "webpack-dev-server --mode development --open", "dev": "webpack --mode development", "build": "webpack --mode production", - "watch": "webpack --watch --mode development", + "watch": "webpack --watch --mode development --progress --colors", "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject", "build_prod": "cross-env NODE_ENV=production NODE_OPTIONS=--max_old_space_size=4096 webpack -p --display errors-only --hide-modules", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/conf/config.json b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/conf/config.json index 3d87e31b9b..4ae222c87f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/conf/config.json +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/conf/config.json @@ -7,8 +7,8 @@ "footerText": "©2019 entgra.io" }, "serverConfig": { - "invokerUri": "/ui-request-handler/invoke/application-mgt-store/v1.0", "invoker": { + "contextPath" : "/store-ui-request-handler", "uri": "/store-ui-request-handler/invoke", "publisher": "/application-mgt-publisher/v1.0", "store": "/application-mgt-store/v1.0", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/App.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/App.js index f4d08b4dea..f6caf0ecea 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/App.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/App.js @@ -92,43 +92,69 @@ class App extends React.Component { checkUserLoggedIn = config => { axios .post( - window.location.origin + '/store-ui-request-handler/user', - 'platform=publisher', + window.location.origin + + config.serverConfig.invoker.contextPath + + '/user', ) .then(res => { - config.user = res.data.data; + config.user = { + username: res.data.data, + }; const pageURL = window.location.pathname; const lastURLSegment = pageURL.substr(pageURL.lastIndexOf('/') + 1); if (lastURLSegment === 'login') { window.location.href = window.location.origin + '/store/'; } else { - this.setState({ - loading: false, - config: config, - }); + this.getUserPermissions(config); } }) .catch(error => { - if (error.hasOwnProperty('response') && error.response.status === 401) { - const redirectUrl = encodeURI(window.location.href); - const pageURL = window.location.pathname; - const lastURLSegment = pageURL.substr(pageURL.lastIndexOf('/') + 1); - if (lastURLSegment !== 'login') { - window.location.href = - window.location.origin + `/store/login?redirect=${redirectUrl}`; - } else { - this.setState({ - loading: false, - config: config, - }); - } - } else { - this.setState({ - loading: false, - error: true, - }); - } + this.handleApiError(error, config); + }); + }; + + getUserPermissions = config => { + axios + .get( + window.location.origin + + config.serverConfig.invoker.uri + + config.serverConfig.invoker.deviceMgt + + '/users/' + + config.user.username + + '/permissions', + ) + .then(res => { + config.user.permissions = res.data.data.permissions; + this.setState({ + loading: false, + config: config, + }); + }) + .catch(error => { + this.handleApiError(error, config); + }); + }; + + handleApiError = (error, config) => { + if (error.hasOwnProperty('response') && error.response.status === 401) { + const redirectUrl = encodeURI(window.location.href); + const pageURL = window.location.pathname; + const lastURLSegment = pageURL.substr(pageURL.lastIndexOf('/') + 1); + if (lastURLSegment !== 'login') { + window.location.href = + window.location.origin + `/store/login?redirect=${redirectUrl}`; + } else { + this.setState({ + loading: false, + config: config, + }); + } + } else { + this.setState({ + loading: false, + error: true, }); + } }; render() { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/Authorized/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/Authorized/index.js new file mode 100644 index 0000000000..f0f1a46092 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/Authorized/index.js @@ -0,0 +1,27 @@ +import react from 'react'; +import { withConfigContext } from '../context/ConfigContext'; + +class Authorized extends react.Component { + constructor(props) { + super(props); + } + + isAuthorized = (user, permission) => { + if (!user || !permission) { + return false; + } + return user.permissions.includes(permission); + }; + + render() { + return this.isAuthorized(this.props.context.user, this.props.permission) + ? this.props.yes + : this.props.no; + } +} + +Authorized.defaultProps = { + yes: () => null, + no: () => null, +}; +export default withConfigContext(Authorized); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/index.js index 2c8a8d7d12..b8582bbc3a 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/index.js @@ -171,7 +171,7 @@ class Dashboard extends React.Component { title={ - {this.config.user} + {this.config.user.username} } > diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/components/AppList/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/components/AppList/index.js index 48f896b092..15f9e0d216 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/components/AppList/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/components/AppList/index.js @@ -34,9 +34,6 @@ class AppList extends React.Component { loading: true, hasMore: true, loadMore: true, - forbiddenErrors: { - apps: false, - }, totalAppCount: 0, }; } @@ -101,23 +98,10 @@ class AppList extends React.Component { } }) .catch(error => { - 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, - }); - } + handleApiError(error, 'Error occurred while trying to load apps.'); + this.setState({ + loading: false, + }); }); }; @@ -145,7 +129,7 @@ class AppList extends React.Component { }; render() { - const { apps, loading, forbiddenErrors, hasMore } = this.state; + const { apps, loading, hasMore } = this.state; return (
@@ -158,14 +142,7 @@ class AppList extends React.Component { useWindow={true} > - {forbiddenErrors.apps && ( - - )} - {!forbiddenErrors.apps && apps.length === 0 && ( + {apps.length === 0 && (
{deviceType !== null && ( - + } + no={ + + } /> )}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ImageViewer/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ImageViewer/index.js similarity index 100% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ImageViewer/index.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ImageViewer/index.js diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Install/components/DeviceInstall/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Install/components/DeviceInstall/index.js similarity index 98% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Install/components/DeviceInstall/index.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Install/components/DeviceInstall/index.js index 19c2b1a76d..f94bcf3820 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Install/components/DeviceInstall/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Install/components/DeviceInstall/index.js @@ -23,8 +23,8 @@ import TimeAgo from 'javascript-time-ago'; // Load locale-specific relative date/time formatting rules. import en from 'javascript-time-ago/locale/en'; -import { withConfigContext } from '../../../../../../../../../../../../components/context/ConfigContext'; -import { handleApiError } from '../../../../../../../../../../../../services/utils/errorHandler'; +import { withConfigContext } from '../../../../../../../../../../../../../../components/context/ConfigContext'; +import { handleApiError } from '../../../../../../../../../../../../../../services/utils/errorHandler'; import InstallModalFooter from '../../../installModalFooter'; const { Text } = Typography; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Install/components/GroupInstall/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Install/components/GroupInstall/index.js similarity index 97% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Install/components/GroupInstall/index.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Install/components/GroupInstall/index.js index ca17bf6640..f49680c5b2 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Install/components/GroupInstall/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Install/components/GroupInstall/index.js @@ -20,8 +20,8 @@ import React from 'react'; import { Typography, Select, Spin, Alert } from 'antd'; import debounce from 'lodash.debounce'; import axios from 'axios'; -import { withConfigContext } from '../../../../../../../../../../../../components/context/ConfigContext'; -import { handleApiError } from '../../../../../../../../../../../../services/utils/errorHandler'; +import { withConfigContext } from '../../../../../../../../../../../../../../components/context/ConfigContext'; +import { handleApiError } from '../../../../../../../../../../../../../../services/utils/errorHandler'; import InstallModalFooter from '../../../installModalFooter'; const { Text } = Typography; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Install/components/RoleInstall/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Install/components/RoleInstall/index.js similarity index 97% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Install/components/RoleInstall/index.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Install/components/RoleInstall/index.js index 633b6a9c7c..e28026c3fd 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Install/components/RoleInstall/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Install/components/RoleInstall/index.js @@ -20,8 +20,8 @@ import React from 'react'; import { Typography, Select, Spin, Alert } from 'antd'; import debounce from 'lodash.debounce'; import axios from 'axios'; -import { withConfigContext } from '../../../../../../../../../../../../components/context/ConfigContext'; -import { handleApiError } from '../../../../../../../../../../../../services/utils/errorHandler'; +import { withConfigContext } from '../../../../../../../../../../../../../../components/context/ConfigContext'; +import { handleApiError } from '../../../../../../../../../../../../../../services/utils/errorHandler'; import InstallModalFooter from '../../../installModalFooter'; const { Text } = Typography; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Install/components/UserInstall/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Install/components/UserInstall/index.js similarity index 97% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Install/components/UserInstall/index.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Install/components/UserInstall/index.js index d0f6533087..10ed1a3db5 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Install/components/UserInstall/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Install/components/UserInstall/index.js @@ -20,8 +20,8 @@ import React from 'react'; import { Typography, Select, Spin, Alert } from 'antd'; import debounce from 'lodash.debounce'; import axios from 'axios'; -import { withConfigContext } from '../../../../../../../../../../../../components/context/ConfigContext'; -import { handleApiError } from '../../../../../../../../../../../../services/utils/errorHandler'; +import { withConfigContext } from '../../../../../../../../../../../../../../components/context/ConfigContext'; +import { handleApiError } from '../../../../../../../../../../../../../../services/utils/errorHandler'; import InstallModalFooter from '../../../installModalFooter'; const { Text } = Typography; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Install/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Install/index.js similarity index 100% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Install/index.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Install/index.js diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/CurrentUsersReview/components/AddReview/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/CurrentUsersReview/components/AddReview/index.js similarity index 97% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/CurrentUsersReview/components/AddReview/index.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/CurrentUsersReview/components/AddReview/index.js index 821cac5465..7a972a9f15 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/CurrentUsersReview/components/AddReview/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/CurrentUsersReview/components/AddReview/index.js @@ -31,8 +31,8 @@ import { } from 'antd'; import StarRatings from 'react-star-ratings'; import axios from 'axios'; -import { withConfigContext } from '../../../../../../../../../../../../../../components/context/ConfigContext'; -import { handleApiError } from '../../../../../../../../../../../../../../services/utils/errorHandler'; +import { withConfigContext } from '../../../../../../../../../../../../../../../../components/context/ConfigContext'; +import { handleApiError } from '../../../../../../../../../../../../../../../../services/utils/errorHandler'; const { Title } = Typography; const { TextArea } = Input; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/CurrentUsersReview/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/CurrentUsersReview/index.js similarity index 57% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/CurrentUsersReview/index.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/CurrentUsersReview/index.js index 87df7e62c0..391ff813d1 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/CurrentUsersReview/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/CurrentUsersReview/index.js @@ -20,7 +20,8 @@ import React from 'react'; import { List, Typography, Empty, Alert } from 'antd'; import SingleReview from '../Reviews/components/Review'; import AddReview from './components/AddReview'; -import { withConfigContext } from '../../../../../../../../../../../../components/context/ConfigContext'; +import { withConfigContext } from '../../../../../../../../../../../../../../components/context/ConfigContext'; +import Authorized from '../../../../../../../../../../../../../../components/Authorized'; const { Text } = Typography; @@ -30,45 +31,38 @@ class CurrentUsersReview extends React.Component { return (
MY REVIEW - {this.props.forbidden && ( - - )} - {!this.props.forbidden && ( -
- {currentUserReviews.length > 0 && ( -
- ( - - - - )} - /> -
- )} +
+ {currentUserReviews.length > 0 && ( +
+ ( + + + + )} + /> +
+ )} - {currentUserReviews.length === 0 && ( -
+ {currentUserReviews.length === 0 && ( + } > - {/* */} -
- )} -
- )} + } + no={ + + } + /> + )} +
); } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/Rating/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/Rating/index.js similarity index 98% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/Rating/index.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/Rating/index.js index 454c88e69e..fcd9f85ac1 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/Rating/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/Rating/index.js @@ -20,7 +20,7 @@ import React from 'react'; import { Row, Typography, Icon } from 'antd'; import StarRatings from 'react-star-ratings'; import './styles.css'; -import { withConfigContext } from '../../../../../../../../../../../../components/context/ConfigContext'; +import { withConfigContext } from '../../../../../../../../../../../../../../components/context/ConfigContext'; const { Text } = Typography; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/Rating/styles.css b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/Rating/styles.css similarity index 100% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/Rating/styles.css rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/Rating/styles.css diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/Reviews/components/Review/components/Edit/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/Reviews/components/Review/components/Edit/index.js similarity index 97% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/Reviews/components/Review/components/Edit/index.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/Reviews/components/Review/components/Edit/index.js index 13806129d9..4dce40b902 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/Reviews/components/Review/components/Edit/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/Reviews/components/Review/components/Edit/index.js @@ -31,8 +31,8 @@ import { import StarRatings from 'react-star-ratings'; import axios from 'axios'; import './styles.css'; -import { withConfigContext } from '../../../../../../../../../../../../../../../../components/context/ConfigContext'; -import { handleApiError } from '../../../../../../../../../../../../../../../../services/utils/errorHandler'; +import { withConfigContext } from '../../../../../../../../../../../../../../../../../../components/context/ConfigContext'; +import { handleApiError } from '../../../../../../../../../../../../../../../../../../services/utils/errorHandler'; const { Title } = Typography; const { TextArea } = Input; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/Reviews/components/Review/components/Edit/styles.css b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/Reviews/components/Review/components/Edit/styles.css similarity index 100% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/Reviews/components/Review/components/Edit/styles.css rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/Reviews/components/Review/components/Edit/styles.css diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/Reviews/components/Review/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/Reviews/components/Review/index.js similarity index 76% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/Reviews/components/Review/index.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/Reviews/components/Review/index.js index 9722614e05..3dac70cf55 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/Reviews/components/Review/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/Reviews/components/Review/index.js @@ -24,8 +24,9 @@ import Twemoji from 'react-twemoji'; import './styles.css'; import EditReview from './components/Edit'; import axios from 'axios'; -import { withConfigContext } from '../../../../../../../../../../../../../../components/context/ConfigContext'; -import { handleApiError } from '../../../../../../../../../../../../../../services/utils/errorHandler'; +import { withConfigContext } from '../../../../../../../../../../../../../../../../components/context/ConfigContext'; +import { handleApiError } from '../../../../../../../../../../../../../../../../services/utils/errorHandler'; +import Authorized from '../../../../../../../../../../../../../../../../components/Authorized'; const { Text, Paragraph } = Typography; const colorList = [ @@ -100,7 +101,7 @@ class Review extends React.Component { }; render() { - const { isEditable, isDeletable, uuid } = this.props; + const { isEditable, isDeletable, uuid, isPersonalReview } = this.props; const { color, review } = this.state; const { content, rating, username } = review; const avatarLetter = username.charAt(0).toUpperCase(); @@ -135,15 +136,35 @@ class Review extends React.Component { updateCallback={this.updateCallback} /> )} - {isDeletable && ( - - delete - + {isDeletable && !isPersonalReview && ( + + delete + + } + /> + )} + {isDeletable && isPersonalReview && ( + + delete + + } + /> )}
); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/Reviews/components/Review/styles.css b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/Reviews/components/Review/styles.css similarity index 100% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/Reviews/components/Review/styles.css rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/Reviews/components/Review/styles.css diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/Reviews/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/Reviews/index.js similarity index 98% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/Reviews/index.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/Reviews/index.js index 1f6620e118..d3ac637981 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/Reviews/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/Reviews/index.js @@ -23,8 +23,8 @@ import './styles.css'; import InfiniteScroll from 'react-infinite-scroller'; import SingleReview from './components/Review'; import axios from 'axios'; -import { withConfigContext } from '../../../../../../../../../../../../components/context/ConfigContext'; -import { handleApiError } from '../../../../../../../../../../../../services/utils/errorHandler'; +import { withConfigContext } from '../../../../../../../../../../../../../../components/context/ConfigContext'; +import { handleApiError } from '../../../../../../../../../../../../../../services/utils/errorHandler'; const limit = 5; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/Reviews/styles.css b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/Reviews/styles.css similarity index 100% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/componets/Reviews/styles.css rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/componets/Reviews/styles.css diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/index.js similarity index 72% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/index.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/index.js index 0c42aff3e4..9c79c202fe 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/ReviewContainer/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/ReviewContainer/index.js @@ -22,8 +22,9 @@ import { Col, Divider, Row, Typography } from 'antd'; import DetailedRating from './componets/Rating'; import Reviews from './componets/Reviews'; import axios from 'axios'; -import { handleApiError } from '../../../../../../../../../../services/utils/errorHandler'; -import { withConfigContext } from '../../../../../../../../../../components/context/ConfigContext'; +import { handleApiError } from '../../../../../../../../../../../../services/utils/errorHandler'; +import { withConfigContext } from '../../../../../../../../../../../../components/context/ConfigContext'; +import Authorized from '../../../../../../../../../../../../components/Authorized'; const { Text } = Typography; @@ -34,7 +35,6 @@ class ReviewContainer extends React.Component { currentUserReviews: [], detailedRating: null, forbiddenErrors: { - currentReview: false, reviews: false, rating: false, }, @@ -70,18 +70,6 @@ class ReviewContainer extends React.Component { '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, - }); - } }); }; @@ -130,25 +118,33 @@ class ReviewContainer extends React.Component { render() { const { uuid } = this.props; - const { currentUserReviews, detailedRating, forbiddenErrors } = this.state; + const { currentUserReviews, detailedRating } = this.state; return ( -
- - - REVIEWS - - - - - - -
+ + + + REVIEWS + + + + + + + + } + /> ); } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/SubscriptionDetails/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/SubscriptionDetails/index.js similarity index 78% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/SubscriptionDetails/index.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/SubscriptionDetails/index.js index 7bb1358fb0..7083bfebee 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/SubscriptionDetails/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/SubscriptionDetails/index.js @@ -23,8 +23,9 @@ import TimeAgo from 'javascript-time-ago'; // Load locale-specific relative date/time formatting rules. import en from 'javascript-time-ago/locale/en'; -import { withConfigContext } from '../../../../../../../../../../components/context/ConfigContext'; -import { handleApiError } from '../../../../../../../../../../services/utils/errorHandler'; +import { withConfigContext } from '../../../../../../../../../../../../components/context/ConfigContext'; +import { handleApiError } from '../../../../../../../../../../../../services/utils/errorHandler'; +import Authorized from '../../../../../../../../../../../../components/Authorized'; const { Text } = Typography; @@ -223,48 +224,51 @@ class SubscriptionDetails extends React.Component { render() { const { data, pagination, loading } = this.state; return ( -
- {this.state.isForbidden && ( + +
+ + The following are the subscription details of the application in + each respective device. + +
+
+ +
+ + record.device.deviceIdentifier + + record.device.enrolmentInfo.owner + + record.device.enrolmentInfo.ownership + } + dataSource={data.data} + pagination={{ + ...pagination, + size: 'small', + // position: "top", + total: data.recordsTotal, + showTotal: (total, range) => + `showing ${range[0]}-${range[1]} of ${total} devices`, + // showQuickJumper: true + }} + onChange={this.handleTableChange} + loading={loading} + scroll={{ x: 1000 }} + /> + + } + no={ - )} -
- - The following are the subscription details of the application in - each respective device. - -
-
- -
-
- record.device.deviceIdentifier + - record.device.enrolmentInfo.owner + - record.device.enrolmentInfo.ownership - } - dataSource={data.data} - pagination={{ - ...pagination, - size: 'small', - // position: "top", - total: data.recordsTotal, - showTotal: (total, range) => - `showing ${range[0]}-${range[1]} of ${total} devices`, - // showQuickJumper: true - }} - onChange={this.handleTableChange} - loading={loading} - scroll={{ x: 1000 }} - /> - + } + /> ); } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Uninstall/components/DeviceUninstall/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Uninstall/components/DeviceUninstall/index.js similarity index 98% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Uninstall/components/DeviceUninstall/index.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Uninstall/components/DeviceUninstall/index.js index 8e9dc5b0cd..ffd553b28e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Uninstall/components/DeviceUninstall/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Uninstall/components/DeviceUninstall/index.js @@ -23,8 +23,8 @@ import TimeAgo from 'javascript-time-ago'; // Load locale-specific relative date/time formatting rules. import en from 'javascript-time-ago/locale/en'; -import { withConfigContext } from '../../../../../../../../../../../../components/context/ConfigContext'; -import { handleApiError } from '../../../../../../../../../../../../services/utils/errorHandler'; +import { withConfigContext } from '../../../../../../../../../../../../../../components/context/ConfigContext'; +import { handleApiError } from '../../../../../../../../../../../../../../services/utils/errorHandler'; import InstallModalFooter from '../../../installModalFooter'; const { Text } = Typography; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Uninstall/components/GroupUninstall/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Uninstall/components/GroupUninstall/index.js similarity index 97% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Uninstall/components/GroupUninstall/index.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Uninstall/components/GroupUninstall/index.js index d3dce763fe..aa715abe83 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Uninstall/components/GroupUninstall/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Uninstall/components/GroupUninstall/index.js @@ -20,8 +20,8 @@ import React from 'react'; import { Typography, Select, Spin, Alert } from 'antd'; import debounce from 'lodash.debounce'; import axios from 'axios'; -import { withConfigContext } from '../../../../../../../../../../../../components/context/ConfigContext'; -import { handleApiError } from '../../../../../../../../../../../../services/utils/errorHandler'; +import { withConfigContext } from '../../../../../../../../../../../../../../components/context/ConfigContext'; +import { handleApiError } from '../../../../../../../../../../../../../../services/utils/errorHandler'; import InstallModalFooter from '../../../installModalFooter'; const { Text } = Typography; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Uninstall/components/RoleUninstall/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Uninstall/components/RoleUninstall/index.js similarity index 97% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Uninstall/components/RoleUninstall/index.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Uninstall/components/RoleUninstall/index.js index da999eafdb..3d29772c25 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Uninstall/components/RoleUninstall/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Uninstall/components/RoleUninstall/index.js @@ -20,8 +20,8 @@ import React from 'react'; import { Typography, Select, Spin, Alert } from 'antd'; import debounce from 'lodash.debounce'; import axios from 'axios'; -import { withConfigContext } from '../../../../../../../../../../../../components/context/ConfigContext'; -import { handleApiError } from '../../../../../../../../../../../../services/utils/errorHandler'; +import { withConfigContext } from '../../../../../../../../../../../../../../components/context/ConfigContext'; +import { handleApiError } from '../../../../../../../../../../../../../../services/utils/errorHandler'; import InstallModalFooter from '../../../installModalFooter'; const { Text } = Typography; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Uninstall/components/UserUninstall/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Uninstall/components/UserUninstall/index.js similarity index 97% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Uninstall/components/UserUninstall/index.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Uninstall/components/UserUninstall/index.js index 1d0799bcdb..5880d09f0e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Uninstall/components/UserUninstall/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Uninstall/components/UserUninstall/index.js @@ -20,8 +20,8 @@ import React from 'react'; import { Typography, Select, Spin, Alert } from 'antd'; import debounce from 'lodash.debounce'; import axios from 'axios'; -import { withConfigContext } from '../../../../../../../../../../../../components/context/ConfigContext'; -import { handleApiError } from '../../../../../../../../../../../../services/utils/errorHandler'; +import { withConfigContext } from '../../../../../../../../../../../../../../components/context/ConfigContext'; +import { handleApiError } from '../../../../../../../../../../../../../../services/utils/errorHandler'; import InstallModalFooter from '../../../installModalFooter'; const { Text } = Typography; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Uninstall/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Uninstall/index.js similarity index 100% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/Uninstall/index.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/Uninstall/index.js diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/installModalFooter/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/installModalFooter/index.js similarity index 100% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/components/installModalFooter/index.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/components/installModalFooter/index.js diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/index.js similarity index 81% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/index.js rename to components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/index.js index d05adf76e7..efaaf8da70 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleaseView/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/components/ReleaseView/index.js @@ -30,17 +30,18 @@ import { Tabs, Tag, } from 'antd'; -import '../../../../../../../../App.css'; +// import '../../../../../../../../App.css'; import ImageViewer from './components/ImageViewer'; import StarRatings from 'react-star-ratings'; import axios from 'axios'; import pSBC from 'shade-blend-color'; import AppInstallModal from './components/Install'; import Uninstall from './components/Uninstall'; -import { withConfigContext } from '../../../../../../../../components/context/ConfigContext'; -import { handleApiError } from '../../../../../../../../services/utils/errorHandler'; +import { withConfigContext } from '../../../../../../../../../../components/context/ConfigContext'; +import { handleApiError } from '../../../../../../../../../../services/utils/errorHandler'; import ReviewContainer from './components/ReviewContainer'; import SubscriptionDetails from './components/SubscriptionDetails'; +import Authorized from '../../../../../../../../../../components/Authorized'; const { Title, Text, Paragraph } = Typography; const { TabPane } = Tabs; @@ -167,22 +168,24 @@ class ReleaseView extends React.Component { return (
- - +
+ + +
@@ -208,11 +211,21 @@ class ReleaseView extends React.Component { textAlign: 'right', }} > - - - + + + + } + no={ + + } + /> @@ -281,9 +294,14 @@ class ReleaseView extends React.Component { - - - + + + + } + /> diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/index.js new file mode 100644 index 0000000000..53f89f78e9 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/components/ReleasePage/index.js @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. + * + * Entgra (pvt) Ltd. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import React from 'react'; +import '../../../../../../../../App.css'; +import { Skeleton, Typography, Row, Col, Card, Breadcrumb, Icon } from 'antd'; +import ReleaseView from './components/ReleaseView'; +import axios from 'axios'; +import { withConfigContext } from '../../../../../../../../components/context/ConfigContext'; +import { Link } from 'react-router-dom'; +import { handleApiError } from '../../../../../../../../services/utils/errorHandler'; + +const { Title } = Typography; + +class ReleasePage extends React.Component { + constructor(props) { + super(props); + this.state = { + loading: true, + app: null, + uuid: null, + forbiddenErrors: { + app: false, + }, + }; + } + + componentDidMount() { + const { uuid, deviceType } = this.props; + this.fetchData(uuid); + this.props.changeSelectedMenuItem(deviceType); + } + + fetchData = uuid => { + const config = this.props.context; + + // send request to the invoker + axios + .get( + window.location.origin + + config.serverConfig.invoker.uri + + config.serverConfig.invoker.store + + '/applications/' + + uuid, + ) + .then(res => { + if (res.status === 200) { + let app = res.data.data; + + this.setState({ + app: app, + loading: false, + uuid: uuid, + }); + } + }) + .catch(error => { + 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, + }); + } + }); + }; + + render() { + const { app, loading } = this.state; + const { deviceType } = this.props; + + let content = No Releases Found; + let appName = 'loading...'; + + if (app != null && app.applicationReleases.length !== 0) { + content = ; + appName = app.name; + } + + return ( +
+ +
+ + + + + {deviceType + ' apps'}{' '} + + + {appName} + + + + {content} + + + + + + ); + } +} + +export default withConfigContext(ReleasePage); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/index.js index a9b7974347..835c69880a 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/scenes/Home/scenes/Apps/scenes/Release/index.js @@ -1,138 +1,31 @@ -/* - * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. - * - * Entgra (pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - import React from 'react'; -import '../../../../../../App.css'; -import { Skeleton, Typography, Row, Col, Card, Breadcrumb, Icon } from 'antd'; -import ReleaseView from './components/ReleaseView'; -import axios from 'axios'; -import { withConfigContext } from '../../../../../../components/context/ConfigContext'; -import { Link } from 'react-router-dom'; -import { handleApiError } from '../../../../../../services/utils/errorHandler'; - -const { Title } = Typography; +import Authorized from '../../../../../../components/Authorized'; +import ReleasePage from './components/ReleasePage'; +import { Result } from 'antd'; class Release extends React.Component { - routes; - - constructor(props) { - super(props); - this.routes = props.routes; - this.state = { - loading: true, - app: null, - uuid: null, - forbiddenErrors: { - app: false, - }, - }; - } - - componentDidMount() { + render() { const { uuid, deviceType } = this.props.match.params; - this.fetchData(uuid); - this.props.changeSelectedMenuItem(deviceType); - } - - fetchData = uuid => { - const config = this.props.context; - - // send request to the invoker - axios - .get( - window.location.origin + - config.serverConfig.invoker.uri + - config.serverConfig.invoker.store + - '/applications/' + - uuid, - ) - .then(res => { - if (res.status === 200) { - let app = res.data.data; - - this.setState({ - app: app, - loading: false, - uuid: uuid, - }); + return ( + } - }) - .catch(error => { - 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, - }); + no={ + } - }); - }; - - render() { - const { app, loading } = this.state; - const { deviceType } = this.props.match.params; - - let content = No Releases Found; - let appName = 'loading...'; - - if (app != null && app.applicationReleases.length !== 0) { - content = ; - appName = app.name; - } - - return ( -
- -
- - - - - {deviceType + ' apps'}{' '} - - - {appName} - - - - {content} - - - - - + /> ); } } -export default withConfigContext(Release); +export default Release;