From f6c332df15ae253cee0b5d265dfae3ba9ba61f10 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/public/conf/config.json | 2 +- .../react-app/src/App.js | 76 ++++++---- .../src/components/Authorized/index.js | 45 ++++++ .../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 | 84 +++++------ .../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 | 133 +++-------------- .../services/utils/authorizationHandler.js | 24 ++++ 34 files changed, 517 insertions(+), 351 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 (79%) 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 create mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/services/utils/authorizationHandler.js 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 3d87e31b9ba..4ae222c87fe 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 f4d08b4dea1..6ade8a306d5 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,67 @@ 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/current-user/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 00000000000..bf7376ac845 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/components/Authorized/index.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2020, 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 { 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 2c8a8d7d120..b8582bbc3af 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 48f896b092d..15f9e0d216b 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 19c2b1a76de..f94bcf38209 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 ca17bf66407..f49680c5b21 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 633b6a9c7c4..e28026c3fda 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 d0f65330873..10ed1a3db58 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 821cac54656..7a972a9f15c 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 87df7e62c03..391ff813d18 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 454c88e69ef..fcd9f85ac18 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 13806129d9b..4dce40b902f 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 9722614e05f..3dac70cf558 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 1f6620e118c..d3ac6379818 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 0c42aff3e48..9c79c202fe7 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 79% 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 7bb1358fb0d..64960187f7f 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,49 @@ 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', + total: data.recordsTotal, + showTotal: (total, range) => + `showing ${range[0]}-${range[1]} of ${total} devices`, + }} + 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 8e9dc5b0cd5..ffd553b28ea 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 d3dce763fec..aa715abe83f 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 da999eafdbe..3d29772c257 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 1d0799bcdb7..5880d09f0eb 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 d05adf76e78..fcdafd75512 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 00000000000..7c8b1683865 --- /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) 2020, 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 a9b79743473..462fa571137 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,5 +1,5 @@ /* - * Copyright (c) 2019, Entgra (pvt) Ltd. (http://entgra.io) All Rights Reserved. + * Copyright (c) 2020, 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 @@ -17,122 +17,33 @@ */ 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; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/services/utils/authorizationHandler.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/services/utils/authorizationHandler.js new file mode 100644 index 00000000000..4e939e42d16 --- /dev/null +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/src/services/utils/authorizationHandler.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2020, 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. + */ + +export const isAuthorized = (user, permission) => { + if (!user || !permission) { + return false; + } + return user.permissions.includes(permission); +};