From 191f707d67783c2b219ab726a392c9eb6a8a0e69 Mon Sep 17 00:00:00 2001 From: Prasanna Dangalla Date: Sun, 30 Jul 2023 15:34:27 +0530 Subject: [PATCH 01/26] Added UI changes related to Key Manager Usage implementations inadmin portal. --- .../main/webapp/site/public/locales/en.json | 12 +- .../KeyManagers/DeleteKeyManager.jsx | 23 +- .../KeyManagers/ListKeyManagerUsages.jsx | 429 ++++++++++++++++++ .../KeyManagers/ListKeyManagers.jsx | 21 + .../src/app/components/KeyManagers/index.jsx | 2 + .../main/webapp/source/src/app/data/api.js | 12 + 6 files changed, 496 insertions(+), 3 deletions(-) create mode 100644 portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx diff --git a/portals/admin/src/main/webapp/site/public/locales/en.json b/portals/admin/src/main/webapp/site/public/locales/en.json index 048321e6ca2..4b280dcc597 100644 --- a/portals/admin/src/main/webapp/site/public/locales/en.json +++ b/portals/admin/src/main/webapp/site/public/locales/en.json @@ -290,6 +290,7 @@ "KeyManagers.AddEditKeyManager.token.handling.options": "Token Handling Options", "KeyManagers.AddEditKeyManager.token.validation.method": "Token Validation Method", "KeyManagers.AddEditKeyManager.useIntrospect": "Use introspect", + "KeyManagers.AddEditKeyManager.usages": "Key Manager - usages", "KeyManagers.AddEditTokenExchangeIDP.form.Issuer": "Issuer", "KeyManagers.AddEditTokenExchangeIDP.form.issuer.help": "E.g.,: https://localhost:9443/oauth2/token", "KeyManagers.AddEditTokenExchangeIDP.form.tokenEndpoint": "Token Endpoint", @@ -316,6 +317,7 @@ "KeyManagers.ListKeyManagers.table.header.label.name": "Name", "KeyManagers.ListKeyManagers.table.header.label.provider": "Provider", "KeyManagers.ListKeyManagers.table.header.label.tokenType": "Type", + "KeyManagers.ListKeyManagers.table.header.label.usage": "Usage", "Keymanager.Claim.Action": "Action", "Keymanager.KeyValidation.Action": "Action", "Keymanager.KeyValidation.ClaimKey": "Claim Key", @@ -790,5 +792,13 @@ "error.list.404": "404 : The page cannot be found.", "error.list.404.description": "The page you are looking for might have been removed, had its name changed or is temporarily unavailable.", "error.list.500": "500 : The page cannot be displayed.", - "error.list.500.description": "The server encountered an internal error or misconfiguration and was unable to complete your request." + "error.list.500.description": "The server encountered an internal error or misconfiguration and was unable to complete your request.", + "Api.Name": "API Name", + "Api.Version": "Version", + "Api.Context": "Context", + "Api.Status": "Status", + "Api.SubscriptionCount": "Subscription Count", + "Api.Owner": "Owner", + "KeyManagers.ListKeyManagerUsages.quota.apis.count": "APIs Count", + "KeyManagers.ListKeyManagerUsages.quota.applications.count": "Applications Count" } diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx index a8bef6139b8..cffab6f6828 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx @@ -1,3 +1,4 @@ +/* eslint-disable no-unused-vars */ /* * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * @@ -16,7 +17,7 @@ * under the License. */ -import React from 'react'; +import React, { useEffect, useState } from 'react'; import API from 'AppData/api'; import PropTypes from 'prop-types'; import { FormattedMessage } from 'react-intl'; @@ -31,10 +32,28 @@ import { useAppContext } from 'AppComponents/Shared/AppContext'; * @returns {JSX} Loading animation. */ function Delete({ updateList, dataRow }) { + const [deletaData, setDeleteData] = React.useState(true); const { id, type, isGlobal } = dataRow; const { isSuperTenant, user: { _scopes } } = useAppContext(); const isSuperAdmin = isSuperTenant && _scopes.includes('apim:admin_settings'); + const fetchData = () => { + const restApi = new API(); + restApi.getKeyManagerUsages(id) + .then((result) => { + if (result.body.apiCount === 0 && result.body.applicationCount === 0) { + setDeleteData(false); + } + }) + .catch((error) => { + const { status } = error; + throw (error); + }); + console.log(id); + }; + useEffect(() => { + fetchData(); + }, []); const formSaveCallback = () => { // todo: don't create a new promise const promiseAPICall = new Promise((resolve, reject) => { @@ -68,7 +87,7 @@ function Delete({ updateList, dataRow }) { triggerIconProps={{ color: 'primary', component: 'span', - disabled: type === 'default' || (isGlobal && !isSuperAdmin), + disabled: type === 'default' || (isGlobal && !isSuperAdmin) || deletaData, }} > diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx new file mode 100644 index 00000000000..c01dc5c87e5 --- /dev/null +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx @@ -0,0 +1,429 @@ +/* eslint-disable react/jsx-props-no-spreading */ +/* + * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * WSO2 Inc. 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, { useEffect, useState } from 'react'; +import { FormattedMessage, useIntl } from 'react-intl'; +import Typography from '@material-ui/core/Typography'; +import Grid from '@material-ui/core/Grid'; +import { makeStyles } from '@material-ui/core/styles'; +import Card from '@material-ui/core/Card'; +import CardActions from '@material-ui/core/CardActions'; +import CardContent from '@material-ui/core/CardContent'; +import MUIDataTable from 'mui-datatables'; +import ContentBase from 'AppComponents/AdminPages/Addons/ContentBase'; +import InlineProgress from 'AppComponents/AdminPages/Addons/InlineProgress'; +import Alert from 'AppComponents/Shared/Alert'; +import List from '@material-ui/core/List'; +import Paper from '@material-ui/core/Paper'; +import ListItem from '@material-ui/core/ListItem'; +import ListItemIcon from '@material-ui/core/ListItemIcon'; +import ListItemText from '@material-ui/core/ListItemText'; +import HelpBase from 'AppComponents/AdminPages/Addons/HelpBase'; +import DescriptionIcon from '@material-ui/icons/Description'; +import Link from '@material-ui/core/Link'; +import Configurations from 'Config'; +import API from 'AppData/api'; +import WarningBase from 'AppComponents/AdminPages/Addons/WarningBase'; +import { Alert as MUIAlert } from '@material-ui/lab'; +import { useParams } from 'react-router-dom'; +import Box from '@material-ui/core/Box'; +import clsx from 'clsx'; +import Toolbar from '@material-ui/core/Toolbar'; + +const useStyles = makeStyles((theme) => ({ + searchInput: { + fontSize: theme.typography.fontSize, + }, + block: { + display: 'block', + }, + contentWrapper: { + margin: theme.spacing(2), + }, + approveButton: { + textDecoration: 'none', + backgroundColor: theme.palette.success.light, + }, + rejectButton: { + textDecoration: 'none', + backgroundColor: theme.palette.error.light, + }, +})); + +/** + * Render a list + * @param {JSON} props props passed from parent + * @returns {JSX} Header AppBar components. + */ +function ListKeyManagerUsages() { + const intl = useIntl(); + const [data, setData] = useState(null); + const restApi = new API(); + const classes = useStyles(); + const [hasListPermission, setHasListPermission] = useState(true); + const [errorMessage, setError] = useState(null); + const { id } = useParams(); + + /** + * API call to get Detected Data + * @returns {Promise}. + */ + function apiCall() { + return restApi + .getKeyManagerUsages(id) + .then((result) => { + return result.body; + }) + .catch((error) => { + const { status } = error; + if (status === 401) { + setHasListPermission(false); + } else { + Alert.error(intl.formatMessage({ + id: 'KeyManagers.ListKeyManagerUsages.error', + defaultMessage: 'Unable to get Key Manager usage details', + })); + throw (error); + } + }); + } + + const fetchData = () => { + // Fetch data from backend + setData(null); + const promiseAPICall = apiCall(); + promiseAPICall.then((LocalData) => { + setData(LocalData); + }) + .catch((e) => { + console.error('Unable to fetch data. ', e.message); + setError(e.message); + }); + }; + + useEffect(() => { + fetchData(); + }, []); + + const pageProps = { + + pageStyle: 'half', + title: intl.formatMessage({ + id: 'KeyManagers.AddEditKeyManager.usages', + defaultMessage: 'Key Manager Usage', + }), + }; + + const columApiProps = [ + { + name: 'name', + label: intl.formatMessage({ + id: 'Api.Name', + defaultMessage: 'API Name', + }), + options: { + sort: false, + filter: true, + }, + }, + { + name: 'version', + label: intl.formatMessage({ + id: 'Api.Version', + defaultMessage: 'Version', + }), + options: { + sort: false, + filter: true, + }, + }, + { + name: 'provider', + label: intl.formatMessage({ + id: 'Api.Provider', + defaultMessage: 'Provider', + }), + options: { + sort: false, + filter: true, + }, + }, + ]; + + const columApplicationProps = [ + { + name: 'name', + label: intl.formatMessage({ + id: 'Aplication.Name', + defaultMessage: 'Aplication Name', + }), + options: { + sort: false, + filter: true, + }, + }, + { + name: 'owner', + label: intl.formatMessage({ + id: 'Aplication.Owner', + defaultMessage: 'Aplication owner', + }), + options: { + sort: false, + filter: true, + }, + }, + { + name: 'organization', + label: intl.formatMessage({ + id: 'Aplication.organization', + defaultMessage: 'Aplication organization', + }), + options: { + sort: false, + filter: true, + }, + }, + ]; + + const addButtonProps = {}; + const addButtonOverride = null; + const noDataMessage = ( + + ); + + const columnsApis = [ + ...columApiProps, + ]; + + const columnsApplications = [ + ...columApplicationProps, + ]; + + const options = { + filterType: 'checkbox', + selectableRows: 'none', + filter: false, + search: false, + print: false, + download: false, + viewColumns: false, + customToolbar: null, + responsive: 'stacked', + }; + if (data && data.length === 0) { + return ( + + + + + + + + + + + + {addButtonOverride || ( + // eslint-disable-next-line react/no-unknown-property + + )} + + + + ); + } + if (!hasListPermission) { + return ( + + )} + content={( + + )} + /> + ); + } + if (!errorMessage && !data) { + return ( + + + + + ); + } + if (errorMessage) { + return ( + + {errorMessage} + + + ); + } + return ( + <> +
+ + + + + + + + + + + TODO + + + + + + + + + + + + + )} + /> + + + + + + + + + + + + + + API Usages + + + + + + + Threre are + {' '} + {data.apiCount} + {' '} + APIs using this keymanager specifically. + + + {data && data.apis.length > 0 && ( + + )} + {data && data.apis.length === 0 && ( +
+ + {noDataMessage} + +
+ )} +
+ + + + + + Application Usages + + + + Threre are + {' '} + {data.applicationCount} + {' '} + APIs using this keymanager specifically. + + + {data && data.applications.length > 0 && ( + + )} + {data && data.applications.length === 0 && ( +
+ + {noDataMessage} + +
+ )} +
+
+
+ +
+
+ + ); +} + +export default ListKeyManagerUsages; diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagers.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagers.jsx index f7b86353b51..41a3da77e0e 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagers.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagers.jsx @@ -301,6 +301,27 @@ export default function ListKeyManagers() { sort: false, }, }, + { + name: 'usage', + label: intl.formatMessage({ + id: 'KeyManagers.ListKeyManagers.table.header.label.usage', + defaultMessage: 'Usage', + }), + options: { + customBodyRender: (value, tableMeta) => { + if (typeof tableMeta.rowData === 'object') { + const artifactId = tableMeta.rowData[tableMeta.rowData.length - 2]; + return ( + + + + ); + } else { + return
; + } + }, + }, + }, { name: 'enabled', options: { display: false } }, { name: 'id', options: { display: false } }, { name: 'isGlobal', options: { display: false } }, diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/index.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/index.jsx index e64ce98547e..6e8a2f0fa88 100755 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/index.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/index.jsx @@ -3,6 +3,7 @@ import { Route, Switch, withRouter } from 'react-router-dom'; import ResourceNotFound from 'AppComponents/Base/Errors/ResourceNotFound'; import ListKeyManagers from './ListKeyManagers'; import AddEditKeyManager from './AddEditKeyManager'; +import ListKeyManagerUsages from './ListKeyManagerUsages'; /** * Render a list @@ -14,6 +15,7 @@ function KeyManagers() { + ); diff --git a/portals/admin/src/main/webapp/source/src/app/data/api.js b/portals/admin/src/main/webapp/source/src/app/data/api.js index c0f494ec85f..8f617f178c8 100644 --- a/portals/admin/src/main/webapp/source/src/app/data/api.js +++ b/portals/admin/src/main/webapp/source/src/app/data/api.js @@ -868,6 +868,18 @@ class API extends Resource { }); } + /** + * Get key manager usages + */ + getKeyManagerUsages(keyManagerId) { + return this.client.then((client) => { + return client.apis['Key Manager (Individual)'].get_key_managers_usages__keyManagerId_( + { keyManagerId: keyManagerId }, + this._requestMetaData(), + ); + }); + } + /** * Add an Key Manager */ From 40d7712eae1182d30644e60397b50ac849ef5a36 Mon Sep 17 00:00:00 2001 From: Prasanna Dangalla Date: Mon, 31 Jul 2023 17:03:19 +0530 Subject: [PATCH 02/26] Added key manager names. --- .../components/KeyManagers/ListKeyManagerUsages.jsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx index c01dc5c87e5..b7ff09747f6 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx @@ -164,6 +164,17 @@ function ListKeyManagerUsages() { filter: true, }, }, + { + name: 'keyManagerEntry', + label: intl.formatMessage({ + id: 'Api.keyManagerEntry', + defaultMessage: 'Key Managers', + }), + options: { + sort: false, + filter: true, + }, + }, ]; const columApplicationProps = [ From 54d4421c1b38c45a361fa045cfd1810d5a3bcc38 Mon Sep 17 00:00:00 2001 From: Prasanna Dangalla Date: Tue, 1 Aug 2023 22:20:10 +0530 Subject: [PATCH 03/26] Implemented Key manager is deletable function. --- .../app/components/KeyManagers/DeleteKeyManager.jsx | 4 ++-- .../components/KeyManagers/ListKeyManagerUsages.jsx | 2 +- .../app/components/KeyManagers/ListKeyManagers.jsx | 2 +- .../admin/src/main/webapp/source/src/app/data/api.js | 12 ++++++++++++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx index cffab6f6828..a1208e39097 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx @@ -38,9 +38,9 @@ function Delete({ updateList, dataRow }) { const isSuperAdmin = isSuperTenant && _scopes.includes('apim:admin_settings'); const fetchData = () => { const restApi = new API(); - restApi.getKeyManagerUsages(id) + restApi.isKeyManagerDeletable(id) .then((result) => { - if (result.body.apiCount === 0 && result.body.applicationCount === 0) { + if (result.body) { setDeleteData(false); } }) diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx index b7ff09747f6..8f176a431e9 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx @@ -1,6 +1,6 @@ /* eslint-disable react/jsx-props-no-spreading */ /* - * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2023, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagers.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagers.jsx index 41a3da77e0e..78714ed0b56 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagers.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagers.jsx @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2023, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except diff --git a/portals/admin/src/main/webapp/source/src/app/data/api.js b/portals/admin/src/main/webapp/source/src/app/data/api.js index 8f617f178c8..93fac1facb1 100644 --- a/portals/admin/src/main/webapp/source/src/app/data/api.js +++ b/portals/admin/src/main/webapp/source/src/app/data/api.js @@ -880,6 +880,18 @@ class API extends Resource { }); } + /** + * Check whether the key manager is deletable or not. + */ + isKeyManagerDeletable(keyManagerId) { + return this.client.then((client) => { + return client.apis['Key Manager (Individual)'].get_key_managers_is_deletable__keyManagerId_( + { keyManagerId: keyManagerId }, + this._requestMetaData(), + ); + }); + } + /** * Add an Key Manager */ From f29d78315a2d2ddc94c455b01b6ae687760c5881 Mon Sep 17 00:00:00 2001 From: Prasanna Dangalla Date: Thu, 3 Aug 2023 11:39:35 +0530 Subject: [PATCH 04/26] Added Remove token ui function. --- .../Shared/AppsAndKeys/TokenManager.jsx | 4 + .../Shared/AppsAndKeys/ViewKeys.jsx | 79 +++++++++++++++++-- 2 files changed, 77 insertions(+), 6 deletions(-) diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx index 1e9a0df446c..5fb2e463b45 100755 --- a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx @@ -876,6 +876,7 @@ class TokenManager extends React.Component { hashEnabled={keymanager.enableTokenHashing || hashEnabled} keyManagerConfig={keymanager} mode={mode} + loadApplication={this.loadApplication} /> @@ -1106,6 +1107,7 @@ class TokenManager extends React.Component { hashEnabled={keymanager.enableTokenHashing || hashEnabled} keyManagerConfig={keymanager} mode={mode} + loadApplication={this.loadApplication} /> @@ -1142,6 +1144,7 @@ class TokenManager extends React.Component { callbackError={hasError} setValidating={this.setValidating} defaultTokenEndpoint={defaultTokenEndpoint} + selectedApp={selectedApp} />
diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/ViewKeys.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/ViewKeys.jsx index db1b4e44000..d487630e858 100755 --- a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/ViewKeys.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/ViewKeys.jsx @@ -17,6 +17,8 @@ */ import React from 'react'; import { styled } from '@mui/material/styles'; +import API from 'AppData/api'; +import { withRouter } from 'react-router-dom'; import PropTypes from 'prop-types'; import IconButton from '@mui/material/IconButton'; import Button from '@mui/material/Button'; @@ -130,6 +132,28 @@ class ViewKeys extends React.Component { * Fetch Application object by ID coming from URL path params and fetch related keys to display */ componentDidMount() { + this.getGeneratedKeys(); + } + + /** + * Adding this here becasue it is not possible to add in the render method becasue isKeyJWT in state is used + * to close the dialog box and render method will casue this to be always true and cannot close the box. + * Rule is ignored becasue according to react docs its ok to setstate as long as we are checking a condition + * This is an ani pattern to be fixed later. + * wso2/product-apim#5293 + * https://reactjs.org/docs/react-component.html#componentdidupdate + * @param {*} prevProps previous props + * @memberof ViewKeys + */ + componentDidUpdate(prevProps) { + const { isKeyJWT } = this.props; + if (isKeyJWT && !prevProps.isKeyJWT) { + // eslint-disable-next-line react/no-did-update-set-state + this.setState({ isKeyJWT: true }); + } + } + + getGeneratedKeys = () => { const { accessTokenRequest } = this.state; const { keyType } = this.props; this.applicationPromise @@ -219,6 +243,29 @@ class ViewKeys extends React.Component { this.setState({ open: true, showToken: false }); }; + /** + * Handle onCLick of remove keys + * */ + handleClickRemove = (keyMappingId) => { + const { selectedTab, keyType, intl, loadApplication } = this.props; + this.applicationPromise + .then((application) => { + return application.cleanUpKeys(keyType, selectedTab, keyMappingId); + }) + .then((result) => { + if (result) { + loadApplication(); + Alert.info(intl.formatMessage({ + id: 'Shared.AppsAndKeys.TokenManager.key.cleanupall.success', + defaultMessage: 'Application keys removed successfully', + })); + } + }) + .catch((error) => { + throw (error); + }); + }; + /** * Handle onCLick of regenerate consumer secret * */ @@ -604,11 +651,12 @@ class ViewKeys extends React.Component { /> )} - + {(keyManagerConfig.enableTokenGeneration && supportedGrantTypesUnchanged + && supportedGrantTypesUnchanged.find((a) => a.includes('client_credentials'))) + && mode !== 'MAPPED' + && ( + + )}
)} {supportedGrantTypesUnchanged && !supportedGrantTypesUnchanged.includes('client_credentials') && !hashEnabled && ( @@ -681,4 +748,4 @@ ViewKeys.propTypes = { mode: PropTypes.string, }; -export default injectIntl((ViewKeys)); +export default injectIntl(withRouter(withStyles(styles)(ViewKeys))); From 8b5a620c1594c0c5780befbccab6c7af35f4b650 Mon Sep 17 00:00:00 2001 From: Prasanna Dangalla Date: Tue, 8 Aug 2023 16:50:29 +0530 Subject: [PATCH 05/26] Added keys removal functionality. --- .../KeyManagers/ListKeyManagerUsages.jsx | 100 ++++++++---------- .../KeyManagers/ListKeyManagers.jsx | 3 +- .../Shared/AppsAndKeys/ViewKeys.jsx | 2 +- .../source/src/app/data/Application.jsx | 52 ++++++--- 4 files changed, 82 insertions(+), 75 deletions(-) diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx index 8f176a431e9..608b94ce059 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx @@ -164,17 +164,6 @@ function ListKeyManagerUsages() { filter: true, }, }, - { - name: 'keyManagerEntry', - label: intl.formatMessage({ - id: 'Api.keyManagerEntry', - defaultMessage: 'Key Managers', - }), - options: { - sort: false, - filter: true, - }, - }, ]; const columApplicationProps = [ @@ -193,7 +182,7 @@ function ListKeyManagerUsages() { name: 'owner', label: intl.formatMessage({ id: 'Aplication.Owner', - defaultMessage: 'Aplication owner', + defaultMessage: 'Aplication Owner', }), options: { sort: false, @@ -233,12 +222,12 @@ function ListKeyManagerUsages() { const options = { filterType: 'checkbox', selectableRows: 'none', - filter: false, - search: false, + filter: true, + search: true, print: false, download: false, viewColumns: false, - customToolbar: null, + customToolbar: false, responsive: 'stacked', }; if (data && data.length === 0) { @@ -327,11 +316,6 @@ function ListKeyManagerUsages() { defaultMessage='Key Manager Usage' />
- - - TODO - - @@ -361,7 +345,7 @@ function ListKeyManagerUsages() { - + @@ -370,16 +354,14 @@ function ListKeyManagerUsages() {
+ + + + {data.apiCount === 1 ? '1 API is using this keymanager specifically.' + : data.apiCount + ' APIs are using this keymanager specifically.'} + + - - - Threre are - {' '} - {data.apiCount} - {' '} - APIs using this keymanager specifically. - - {data && data.apis.length > 0 && ( + + + + Application Usages + + + + + + + {data.applicationCount === 1 ? '1 Application is using this ' + + 'keymanager specifically.' + : data.applicationCount + ' Applications are using this ' + + 'keymanager specifically.'} + + - - - Application Usages - - - - Threre are - {' '} - {data.applicationCount} - {' '} - APIs using this keymanager specifically. - + {data && data.applications.length > 0 && ( + + )} + {data && data.applications.length === 0 && ( +
+ + {noDataMessage} + +
+ )}
- {data && data.applications.length > 0 && ( - - )} - {data && data.applications.length === 0 && ( -
- - {noDataMessage} - -
- )}
diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagers.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagers.jsx index 78714ed0b56..4b4e7db8992 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagers.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagers.jsx @@ -45,6 +45,7 @@ import Card from '@mui/material/Card'; import CardActions from '@mui/material/CardActions'; import CardContent from '@mui/material/CardContent'; import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'; +import FormatListBulletedIcon from '@mui/icons-material/FormatListBulleted'; const styles = { searchBar: { @@ -313,7 +314,7 @@ export default function ListKeyManagers() { const artifactId = tableMeta.rowData[tableMeta.rowData.length - 2]; return ( - + ); } else { diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/ViewKeys.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/ViewKeys.jsx index d487630e858..80aed093959 100755 --- a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/ViewKeys.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/ViewKeys.jsx @@ -250,7 +250,7 @@ class ViewKeys extends React.Component { const { selectedTab, keyType, intl, loadApplication } = this.props; this.applicationPromise .then((application) => { - return application.cleanUpKeys(keyType, selectedTab, keyMappingId); + return application.removeKeys(keyType, selectedTab, keyMappingId); }) .then((result) => { if (result) { diff --git a/portals/devportal/src/main/webapp/source/src/app/data/Application.jsx b/portals/devportal/src/main/webapp/source/src/app/data/Application.jsx index 2595b442fe2..94e23bd298f 100644 --- a/portals/devportal/src/main/webapp/source/src/app/data/Application.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/data/Application.jsx @@ -14,7 +14,6 @@ * limitations under the License. */ - import APIClientFactory from './APIClientFactory'; import Resource from './Resource'; import Utils from './Utils'; @@ -88,11 +87,11 @@ export default class Application extends Resource { const keys = keysResponse.obj.list; this._setKeys(keys); this._setTokens(keys); - if (keyType === 'PRODUCTION'){ + if (keyType === 'PRODUCTION') { return this.productionKeys; } else { return this.sandboxKeys; - } + } }); } @@ -107,10 +106,10 @@ export default class Application extends Resource { * @returns {promise} Set the generated token into current * instance and return tokenObject received as Promise object */ - generateToken(selectedTab, type, validityPeriod, selectedScopes, isTokenExchange - , externalToken) { + generateToken(selectedTab, type, validityPeriod, selectedScopes, isTokenExchange, + externalToken) { if (isTokenExchange) { - const defaultKMTab = "Resident Key Manager"; + const defaultKMTab = 'Resident Key Manager'; const promiseToken = this.getKeys() .then(() => this.client) .then((client) => { @@ -121,7 +120,7 @@ export default class Application extends Resource { keys = this.sandboxKeys.get(defaultKMTab); } keys.additionalProperties.subject_token = externalToken; - const keyMappingId = keys.keyMappingId; + const { keyMappingId } = keys; let accessToken; if (type === 'PRODUCTION') { accessToken = this.productionTokens.get(defaultKMTab); @@ -133,11 +132,11 @@ export default class Application extends Resource { validityPeriod, revokeToken: accessToken.accessToken, scopes: selectedScopes, - grantType: "TOKEN_EXCHANGE", + grantType: 'TOKEN_EXCHANGE', additionalProperties: keys.additionalProperties, }; - const payload = {applicationId: this.id, keyMappingId: keyMappingId}; - const body = {requestBody: requestContent}; + const payload = { applicationId: this.id, keyMappingId }; + const body = { requestBody: requestContent }; return client.apis['Application Tokens'] .post_applications__applicationId__oauth_keys__keyMappingId__generate_token(payload, body); }); @@ -160,7 +159,7 @@ export default class Application extends Resource { } else { keys = this.sandboxKeys.get(selectedTab); } - const keyMappingId = keys.keyMappingId; + const { keyMappingId } = keys; let accessToken; if (type === 'PRODUCTION') { accessToken = this.productionTokens.get(selectedTab); @@ -174,8 +173,8 @@ export default class Application extends Resource { scopes: selectedScopes, additionalProperties: keys.additionalProperties, }; - const payload = {applicationId: this.id, keyMappingId: keyMappingId}; - const body = {requestBody: requestContent}; + const payload = { applicationId: this.id, keyMappingId }; + const body = { requestBody: requestContent }; return client.apis['Application Tokens'] .post_applications__applicationId__oauth_keys__keyMappingId__generate_token(payload, body); }); @@ -236,7 +235,7 @@ export default class Application extends Resource { */ cleanUpKeys(keyType, keyManager, keyMappingId) { const requestContent = { - keyType, + keyType, keyMappingId, keyManager, }; @@ -253,6 +252,25 @@ export default class Application extends Resource { }); } + removeKeys(keyType, keyManager, keyMappingId) { + const requestContent = { + keyType, + keyMappingId, + keyManager, + }; + const payload = { applicationId: this.id, keyMappingId, body: requestContent }; + return this.client.then((client) => client.apis['Application Keys'] + .post_applications__applicationId__oauth_keys__keyMappingId__remove_keys(payload)) + .then((response) => { + if (keyType === 'PRODUCTION') { + this.productionKeys = new Map(); + } else { + this.sandboxKeys = new Map(); + } + return response.ok; + }); + } + /** * * Generate Consumer Secret and Consumer Key for this application instance * @param {string} tokenType Token Type either `OAUTH` or `JWT` @@ -276,7 +294,7 @@ export default class Application extends Resource { callbackUrl, keyType, tokenType, - additionalProperties + additionalProperties, }; const payload = { applicationId: this.id, keyMappingId }; return client.apis['Application Keys'].put_applications__applicationId__oauth_keys__keyMappingId_( @@ -336,7 +354,9 @@ export default class Application extends Resource { */ provideKeys(keyType, consumerKey, consumerSecret, keyManager) { const promisedKeys = this.client.then((client) => { - const requestContent = { consumerKey, consumerSecret, keyType, keyManager}; + const requestContent = { + consumerKey, consumerSecret, keyType, keyManager, + }; const payload = { applicationId: this.id }; const body = { requestBody: requestContent }; return client.apis['Application Keys'].post_applications__applicationId__map_keys(payload, body); From 0b5853fba19d194a2febf1d24fb8549fd3429e7e Mon Sep 17 00:00:00 2001 From: Prasanna Dangalla Date: Thu, 10 Aug 2023 14:54:54 +0530 Subject: [PATCH 06/26] Moved remove keys button to top. --- .../Shared/AppsAndKeys/TokenManager.jsx | 630 ++++++++++-------- .../Shared/AppsAndKeys/ViewKeys.jsx | 19 - 2 files changed, 356 insertions(+), 293 deletions(-) diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx index 5fb2e463b45..86a2eb3fade 100755 --- a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx @@ -34,15 +34,10 @@ import AuthManager from 'AppData/AuthManager'; import InlineMessage from 'AppComponents/Shared/InlineMessage'; import WarningIcon from '@mui/icons-material/Warning'; import API from 'AppData/api'; -import KeyConfiguration from './KeyConfiguration'; -import ViewKeys from './ViewKeys'; -import WaitingForApproval from './WaitingForApproval'; -import { ScopeValidation, resourceMethods, resourcePaths } from '../ScopeValidation'; -import TokenMangerSummary from './TokenManagerSummary'; -import Progress from '../Progress'; -import TokenExchangeKeyConfiguration from "AppComponents/Shared/AppsAndKeys/TokenExchangeKeyConfiguration"; -import Table from "@mui/material/Table"; -import TableRow from "@mui/material/TableRow"; +import Table from '@mui/material/Table'; +import TokenExchangeKeyConfiguration from 'AppComponents/Shared/AppsAndKeys/TokenExchangeKeyConfiguration'; +import TableRow from '@mui/material/TableRow'; +import DeleteIcon from '@mui/icons-material/Delete'; import { Dialog, DialogActions, DialogContent, @@ -50,10 +45,16 @@ import { FormControlLabel, Radio, RadioGroup, - TableCell -} from "@mui/material"; -import DialogTitle from "@mui/material/DialogTitle"; -import Grid from "@mui/material/Grid"; + TableCell, +} from '@mui/material'; +import DialogTitle from '@mui/material/DialogTitle'; +import Grid from '@mui/material/Grid'; +import KeyConfiguration from './KeyConfiguration'; +import ViewKeys from './ViewKeys'; +import WaitingForApproval from './WaitingForApproval'; +import { ScopeValidation, resourceMethods, resourcePaths } from '../ScopeValidation'; +import TokenMangerSummary from './TokenManagerSummary'; +import Progress from '../Progress'; const PREFIX = 'TokenManager'; @@ -72,14 +73,14 @@ const classes = { subTitle: `${PREFIX}-subTitle`, tabPanel: `${PREFIX}-tabPanel`, warningIcon: `${PREFIX}-warningIcon`, - leftCol: `${PREFIX}-leftCol` + leftCol: `${PREFIX}-leftCol`, }; // TODO jss-to-styled codemod: The Fragment root was replaced by div. Change the tag if needed. const Root = styled('div')(( { - theme - } + theme, + }, ) => ({ [`& .${classes.root}`]: { padding: theme.spacing(3), @@ -233,7 +234,7 @@ class TokenManager extends React.Component { importDisabled: false, mode: null, tokenType: 'DIRECT', - isExchangeTokenError:false, + isExchangeTokenError: false, }; this.keyStates = { COMPLETED: 'COMPLETED', @@ -270,6 +271,31 @@ class TokenManager extends React.Component { } } + /** + * Handle onCLick of remove keys + * */ + handleClickRemove = (keyMappingId) => { + const { + selectedTab, keyType, intl, + } = this.props; + this.application + .then((application) => { + return application.removeKeys(keyType, selectedTab, keyMappingId); + }) + .then((result) => { + if (result) { + this.loadApplication(); + Alert.info(intl.formatMessage({ + id: 'Shared.AppsAndKeys.TokenManager.key.cleanupall.success', + defaultMessage: 'Application keys removed successfully', + })); + } + }) + .catch((error) => { + throw (error); + }); + }; + getDefaultAdditionalProperties(selectedKM) { const { availableGrantTypes, applicationConfiguration } = selectedKM; // Fill the keyRequest.additionalProperties from the selectedKM.applicationConfiguration defaultValues. @@ -300,15 +326,17 @@ class TokenManager extends React.Component { const selectedKM = keyManagers.find((x) => x.name === newSelectedTab); const { availableGrantTypes } = selectedKM; const selectedGrantsByDefault = []; - if(availableGrantTypes.find( gt => gt ==='password')){ + if (availableGrantTypes.find((gt) => gt === 'password')) { selectedGrantsByDefault.push('password'); } - if(availableGrantTypes.find( gt => gt ==='client_credentials')){ + if (availableGrantTypes.find((gt) => gt === 'client_credentials')) { selectedGrantsByDefault.push('client_credentials'); } if (keys.size > 0 && keys.get(newSelectedTab) && keys.get(newSelectedTab).keyType === keyType) { - const { callbackUrl, supportedGrantTypes, additionalProperties, mode } = keys.get(newSelectedTab); + const { + callbackUrl, supportedGrantTypes, additionalProperties, mode, + } = keys.get(newSelectedTab); const newRequest = { ...keyRequest, callbackUrl, @@ -370,7 +398,9 @@ class TokenManager extends React.Component { const { keyRequest } = this.state; if (keys.size > 0 && keys.get(selectedTab) && keys.get(selectedTab).keyType === keyType) { - const { callbackUrl, supportedGrantTypes, additionalProperties, mode } = keys.get(selectedTab); + const { + callbackUrl, supportedGrantTypes, additionalProperties, mode, + } = keys.get(selectedTab); const newRequest = { ...keyRequest, callbackUrl: callbackUrl || '', @@ -378,16 +408,19 @@ class TokenManager extends React.Component { additionalProperties: additionalProperties || this.getDefaultAdditionalProperties(selectdKM), }; this.setState({ - keys, keyRequest: newRequest, keyManagers: responseKeyManagerList, selectedTab, + keys, + keyRequest: newRequest, + keyManagers: responseKeyManagerList, + selectedTab, importDisabled: (mode === 'MAPPED' || mode === 'CREATED'), mode, }); } else { const selectedGrantTypes = []; - if(selectdKM.availableGrantTypes.find( gt => gt ==='password')){ + if (selectdKM.availableGrantTypes.find((gt) => gt === 'password')) { selectedGrantTypes.push('password'); } - if(selectdKM.availableGrantTypes.find( gt => gt ==='client_credentials')){ + if (selectdKM.availableGrantTypes.find((gt) => gt === 'client_credentials')) { selectedGrantTypes.push('client_credentials'); } @@ -469,7 +502,9 @@ class TokenManager extends React.Component { const initialToken = response.token ? response.token.accessToken : ''; const initialValidityTime = response.token ? response.token.validityTime : 0; const initialScopes = response.token ? response.token.tokenScopes : []; - this.setState({ keys: newKeys, isKeyJWT, initialToken, initialValidityTime, initialScopes }); + this.setState({ + keys: newKeys, isKeyJWT, initialToken, initialValidityTime, initialScopes, + }); if (response.keyState === this.keyStates.CREATED || response.keyState === this.keyStates.REJECTED) { Alert.info(intl.formatMessage({ id: 'Shared.AppsAndKeys.TokenManager.key.generate.success.blocked', @@ -497,7 +532,7 @@ class TokenManager extends React.Component { || `${intl.formatMessage({ id: 'Shared.AppsAndKeys.TokenManager.key.generate.error', defaultMessage: 'Error occurred when generating application keys', - })}, ${error.response.body.message}`); + })}, ${error.response.body.message}`); }).finally(() => this.setState({ isLoading: false })); } @@ -588,8 +623,6 @@ class TokenManager extends React.Component { id: 'Shared.AppsAndKeys.TokenManager.key.cleanup.error', defaultMessage: 'Error occurred while cleaning up application keys', })); - - }); } @@ -682,6 +715,7 @@ class TokenManager extends React.Component { handleClose=() => { this.setState({ tokenType: 'DIRECT' }); } + /** * @returns {Component} * @memberof Tokenemanager @@ -693,8 +727,9 @@ class TokenManager extends React.Component { const { keys, keyRequest, isLoading, isKeyJWT, providedConsumerKey, providedConsumerSecret, selectedTab, keyManagers, validating, hasError, initialToken, - initialValidityTime, initialScopes, importDisabled, mode, tokenType + initialValidityTime, initialScopes, importDisabled, mode, tokenType, } = this.state; + if (keyManagers && keyManagers.length === 0) { return ( @@ -710,8 +745,10 @@ class TokenManager extends React.Component { - + ; } + const csCkKeys = keys.size > 0 && keys.get(selectedTab) + && (keys.get(selectedTab).keyType === keyType) && keys.get(selectedTab); + const keyMappingId = csCkKeys && csCkKeys.keyMappingId; + const username = AuthManager.getUser().name; let isUserOwner = false; @@ -757,10 +798,10 @@ class TokenManager extends React.Component { } let isResidentKeyManagerTokensAvailable = false; - if (keys.has('Resident Key Manager') && - keys.get('Resident Key Manager').supportedGrantTypes && - keys.get('Resident Key Manager').supportedGrantTypes. - includes("urn:ietf:params:oauth:grant-type:token-exchange")){ + if (keys.has('Resident Key Manager') + && keys.get('Resident Key Manager').supportedGrantTypes + && keys.get('Resident Key Manager').supportedGrantTypes + .includes('urn:ietf:params:oauth:grant-type:token-exchange')) { isResidentKeyManagerTokensAvailable = true; } @@ -768,7 +809,7 @@ class TokenManager extends React.Component { if (keyManagers.length > 0) { const residentKMs = keyManagers.filter((item) => item.name === 'Resident Key Manager'); - defaultTokenEndpoint = residentKMs.length > 0 ? (residentKMs)[0].tokenEndpoint: null; + defaultTokenEndpoint = residentKMs.length > 0 ? (residentKMs)[0].tokenEndpoint : null; } if (key && key.keyState === 'APPROVED' && !key.consumerKey) { @@ -801,26 +842,26 @@ class TokenManager extends React.Component { return ( {(keyManagers && keyManagers.length > 1) && ( - + {keyManagers.map((keymanager) => ( - + id={keymanager.name.replace(/\s/g, '')} + /> ))} @@ -861,6 +902,28 @@ class TokenManager extends React.Component { ) } + + {(keymanager.enableTokenGeneration && keys.get(selectedTab) + && keys.get(selectedTab).supportedGrantTypes.find((a) => a.includes('client_credentials'))) + && mode !== 'MAPPED' + && ( + + )} + + - {key ? - this.props.intl.formatMessage({ + {key + ? this.props.intl.formatMessage({ id: 'Shared.AppsAndKeys.TokenManager.update.keys', - defaultMessage: 'Update Keys'}) - : - this.props.intl.formatMessage({ + defaultMessage: 'Update Keys', + }) + : this.props.intl.formatMessage({ id: 'Shared.AppsAndKeys.TokenManager.generate.keys', - defaultMessage: 'Generate Keys'}) - } - {isLoading && } + defaultMessage: 'Generate Keys', + })} + {isLoading && } - {key ? - this.props.intl.formatMessage({ + {key + ? this.props.intl.formatMessage({ id: 'Shared.AppsAndKeys.TokenManager.update', - defaultMessage: 'Update'}) - : - this.props.intl.formatMessage({ + defaultMessage: 'Update', + }) + : this.props.intl.formatMessage({ id: 'Shared.AppsAndKeys.TokenManager.generate.keys', - defaultMessage: 'Generate Keys'}) - } - {isLoading && } + defaultMessage: 'Generate Keys', + })} + {isLoading && } {!keymanager.enableOAuthAppCreation && ( - + @@ -1011,8 +1078,10 @@ class TokenManager extends React.Component { {/* Token exchange grant flow enable/disable logic Given that in the key manager selected has the tokenType='EXCHANGE' - If 'Resident Key Manager' disabled we can't proceed with token exchange. So need to show a banner - If 'Resident Key Manager' enabled, we need to check if the resident key manager 'exchange grant' is selected. + If 'Resident Key Manager' disabled we can't proceed with token exchange. + So need to show a banner + If 'Resident Key Manager' enabled, + we need to check if the resident key manager 'exchange grant' is selected. So we need to ask the user to select 'exchange grant' for the 'Resident Key Manager'. If 'Resident Key Manager' enabled and 'exchange grant' is enabled the token exchange is possible */} @@ -1040,172 +1109,183 @@ class TokenManager extends React.Component { - - - - - - - - - } - label='Direct Token' id='direct-token'/> - } - label='Exchange Token' id='exchange-token'/> - - - -
-
+ + + + + + + + + } + label='Direct Token' + id='direct-token' + /> + } + label='Exchange Token' + id='exchange-token' + /> + + + +
+
- {tokenType === 'DIRECT' && ( - <> - - - + + + + + { + keymanager.enableMapOAuthConsumerApps && ( + + + + ) + } + + + + + + { + key + ? ( + + ) + : ( + + ) + } - { - keymanager.enableMapOAuthConsumerApps && ( - - - - ) - } - - - - - - { - key - ? ( - - ) - : ( - - ) - } - - - -
- - {!isUserOwner ? ( - <> - - - - - - ) : ( - - - {!keymanager.enableOAuthAppCreation && ( - - - - - - - )} - - )} - -
-
- - )} - {(tokenType === 'EXCHANGED' && isResidentKeyManagerTokensAvailable) && ( + + +
+ + {!isUserOwner ? ( + <> + + + + + + ) : ( + + + {!keymanager.enableOAuthAppCreation && ( + + + + + + + )} + + )} + +
+
+ + )} + {(tokenType === 'EXCHANGED' && isResidentKeyManagerTokensAvailable) && ( {(tokenType === 'EXCHANGED' && !isResidentKeyManagerTokensAvailable) && ( -
- - - - - {'Resident Key Manager Consumer Key and Secret Not Available '} - - - - - - - - - - - - - - - +
+ + + + + {'Resident Key Manager Consumer Key and Secret Not Available '} + + + + <> + + + + + + + + + + + + - -
+
)}
); diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/ViewKeys.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/ViewKeys.jsx index 80aed093959..583bd9090b6 100755 --- a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/ViewKeys.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/ViewKeys.jsx @@ -698,25 +698,6 @@ class ViewKeys extends React.Component { defaultMessage='CURL to Generate Access Token' /> - {(keyManagerConfig.enableTokenGeneration && supportedGrantTypesUnchanged - && supportedGrantTypesUnchanged.find((a) => a.includes('client_credentials'))) - && mode !== 'MAPPED' - && ( - - )}
)} {supportedGrantTypesUnchanged && !supportedGrantTypesUnchanged.includes('client_credentials') && !hashEnabled && ( From fd0807278314f2a226e641dd4cac2cce295be66c Mon Sep 17 00:00:00 2001 From: Prasanna Dangalla Date: Thu, 10 Aug 2023 14:56:48 +0530 Subject: [PATCH 07/26] Implemeted zero usage ui texts. --- .../app/components/Base/RouteMenuMapping.jsx | 7 + .../KeyManagers/ListKeyManagerUsages.jsx | 125 +++++++++++------- 2 files changed, 85 insertions(+), 47 deletions(-) diff --git a/portals/admin/src/main/webapp/source/src/app/components/Base/RouteMenuMapping.jsx b/portals/admin/src/main/webapp/source/src/app/components/Base/RouteMenuMapping.jsx index 0f49acc8411..e0f47e96285 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/Base/RouteMenuMapping.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/Base/RouteMenuMapping.jsx @@ -198,6 +198,13 @@ const RouteMenuMapping = (intl) => [ component: KeyManagers, icon: , addEditPageDetails: [ + { + id: intl.formatMessage({ + id: 'Base.RouteMenuMapping.keymanagers.items.Usage', + defaultMessage: 'Key Manager Usage', + }), + path: '/settings/key-managers/usages/(.*?)$', + }, { id: intl.formatMessage({ id: 'Base.RouteMenuMapping.keymanagers.items.Adding', diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx index 608b94ce059..f7cf5a9136a 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx @@ -354,30 +354,44 @@ function ListKeyManagerUsages() { + {data.apiCount > 0 + ? ( + <> + + + {data.apiCount === 1 ? '1 API is using this keymanager specifically.' + : data.apiCount + ' APIs are using this keymanager specifically.'} + + + + {data && data.apis.length > 0 && ( + + )} + {data && data.apis.length === 0 && ( +
+ + {noDataMessage} + +
+ )} +
- - - {data.apiCount === 1 ? '1 API is using this keymanager specifically.' - : data.apiCount + ' APIs are using this keymanager specifically.'} - - - - {data && data.apis.length > 0 && ( - - )} - {data && data.apis.length === 0 && ( -
- - {noDataMessage} - -
+ + ) + : ( + + + + No API usages for this keymanager specifically. + + + )} -
@@ -386,34 +400,51 @@ function ListKeyManagerUsages() { - - - - {data.applicationCount === 1 ? '1 Application is using this ' + {data.applicationCount > 0 + ? ( + <> + + + + {data.applicationCount === 1 ? '1 Application is using this ' + 'keymanager specifically.' - : data.applicationCount + ' Applications are using this ' + : data.applicationCount + ' Applications are using this ' + 'keymanager specifically.'} - - - - - {data && data.applications.length > 0 && ( - - )} - {data && data.applications.length === 0 && ( -
- - {noDataMessage} + + + + + + + {data && data.applications.length > 0 && ( + + )} + {data && data.applicationCount.length === 0 && ( +
+ + {noDataMessage} + +
+ )} +
+
+ + + ) + : ( + + + + No Application usages for this keymanager specifically. -
- )} -
-
+
+ + )} From 57796bb6875b45f1dc6ec8b46a3601a272ef3e02 Mon Sep 17 00:00:00 2001 From: Savindu Dimal Date: Thu, 7 Mar 2024 13:47:13 +0530 Subject: [PATCH 08/26] Added clean up token login to front end --- .../Shared/AppsAndKeys/TokenManager.jsx | 117 ++++++++++++------ 1 file changed, 80 insertions(+), 37 deletions(-) diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx index 86a2eb3fade..33f212bbafa 100755 --- a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx @@ -296,6 +296,31 @@ class TokenManager extends React.Component { }); }; + /** + * Handle onClick of remove keys + * */ + handleClickClean = (keyMappingId) => { + const { + selectedTab, keyType, intl, + } = this.props; + this.application + .then((application) => { + return application.cleanUpKeys(keyType, selectedTab, keyMappingId); + }) + .then((result) => { + if (result) { + this.loadApplication(); + Alert.info(intl.formatMessage({ + id: 'Shared.AppsAndKeys.TokenManager.key.cleanupall.success', + defaultMessage: 'Application keys removed successfully', + })); + } + }) + .catch((error) => { + throw (error); + }); + }; + getDefaultAdditionalProperties(selectedKM) { const { availableGrantTypes, applicationConfiguration } = selectedKM; // Fill the keyRequest.additionalProperties from the selectedKM.applicationConfiguration defaultValues. @@ -887,43 +912,61 @@ class TokenManager extends React.Component { id='Shared.AppsAndKeys.TokenManager.key.and.secret' /> - { - keymanager.enableMapOAuthConsumerApps && ( - - - - ) - } - - {(keymanager.enableTokenGeneration && keys.get(selectedTab) - && keys.get(selectedTab).supportedGrantTypes.find((a) => a.includes('client_credentials'))) - && mode !== 'MAPPED' - && ( - - )} - - + {keymanager.enableMapOAuthConsumerApps && ( + + + + )} + {console.log(mode)} + {(keymanager.enableTokenGeneration && keys.get(selectedTab) + && keys.get(selectedTab).supportedGrantTypes.find((a) => a.includes('client_credentials'))) + && ( + mode !== 'MAPPED' + ? ( + + + + ) : ( + + + + ))} Date: Fri, 11 Aug 2023 11:32:09 +0530 Subject: [PATCH 09/26] Moved remove keys and clean keys to different components. --- .../Shared/AppsAndKeys/CleanKeys.jsx | 46 +++++++++++++++++++ .../Shared/AppsAndKeys/RemoveKeys.jsx | 46 +++++++++++++++++++ .../Shared/AppsAndKeys/TokenManager.jsx | 45 ++++++------------ 3 files changed, 106 insertions(+), 31 deletions(-) create mode 100644 portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx create mode 100644 portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/RemoveKeys.jsx diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx new file mode 100644 index 00000000000..f72f3aa7c18 --- /dev/null +++ b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. + * + * WSO2 LLC. 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 Button from '@material-ui/core/Button'; +import { FormattedMessage } from 'react-intl'; +import DeleteIcon from '@material-ui/icons/Delete'; + +function CleanKeys(props) { + const { + keyMappingId, keys, selectedTab, handleClickClean, + } = props; + + return ( + + ); +} + +export default CleanKeys; diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/RemoveKeys.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/RemoveKeys.jsx new file mode 100644 index 00000000000..a30e473b52d --- /dev/null +++ b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/RemoveKeys.jsx @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. + * + * WSO2 LLC. 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 Button from '@material-ui/core/Button'; +import { FormattedMessage } from 'react-intl'; +import DeleteIcon from '@material-ui/icons/Delete'; + +function RemoveKeys(props) { + const { + keyMappingId, keys, selectedTab, handleClickRemove, + } = props; + + return ( + + ); +} + +export default RemoveKeys; diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx index 33f212bbafa..0bbbabeb212 100755 --- a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx @@ -37,7 +37,6 @@ import API from 'AppData/api'; import Table from '@mui/material/Table'; import TokenExchangeKeyConfiguration from 'AppComponents/Shared/AppsAndKeys/TokenExchangeKeyConfiguration'; import TableRow from '@mui/material/TableRow'; -import DeleteIcon from '@mui/icons-material/Delete'; import { Dialog, DialogActions, DialogContent, @@ -55,6 +54,8 @@ import WaitingForApproval from './WaitingForApproval'; import { ScopeValidation, resourceMethods, resourcePaths } from '../ScopeValidation'; import TokenMangerSummary from './TokenManagerSummary'; import Progress from '../Progress'; +import RemoveKeys from './RemoveKeys'; +import CleanKeys from './CleanKeys'; const PREFIX = 'TokenManager'; @@ -932,39 +933,21 @@ class TokenManager extends React.Component { mode !== 'MAPPED' ? ( - + ) : ( - + ))} From 0f35441b884c511302aa3fc4e038b01be706ce4a Mon Sep 17 00:00:00 2001 From: Prasanna Dangalla Date: Fri, 11 Aug 2023 12:25:22 +0530 Subject: [PATCH 10/26] Added delete confirmatiion. --- .../Shared/AppsAndKeys/CleanKeys.jsx | 69 +++++++++++++++---- .../Shared/AppsAndKeys/RemoveKeys.jsx | 69 +++++++++++++++---- 2 files changed, 110 insertions(+), 28 deletions(-) diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx index f72f3aa7c18..886764aacbc 100644 --- a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx @@ -19,27 +19,68 @@ import React from 'react'; import Button from '@material-ui/core/Button'; import { FormattedMessage } from 'react-intl'; import DeleteIcon from '@material-ui/icons/Delete'; +import Dialog from '@material-ui/core/Dialog'; +import DialogActions from '@material-ui/core/DialogActions'; +import DialogContent from '@material-ui/core/DialogContent'; +import DialogContentText from '@material-ui/core/DialogContentText'; +import DialogTitle from '@material-ui/core/DialogTitle'; function CleanKeys(props) { + const [open, setOpen] = React.useState(false); const { keyMappingId, keys, selectedTab, handleClickClean, } = props; + const handleClickOpen = () => { + setOpen(true); + }; + + const handleClose = () => { + setOpen(false); + }; + + const handleRemove = () => { + handleClickClean(keyMappingId); + }; + return ( - +
+ + + Do you really want to remove keys? + + + This will remove only the key entries stored in devportal, gateway and will not remove the service proveder keys. + + + + + + + +
); } diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/RemoveKeys.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/RemoveKeys.jsx index a30e473b52d..581d452af91 100644 --- a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/RemoveKeys.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/RemoveKeys.jsx @@ -19,27 +19,68 @@ import React from 'react'; import Button from '@material-ui/core/Button'; import { FormattedMessage } from 'react-intl'; import DeleteIcon from '@material-ui/icons/Delete'; +import Dialog from '@material-ui/core/Dialog'; +import DialogActions from '@material-ui/core/DialogActions'; +import DialogContent from '@material-ui/core/DialogContent'; +import DialogContentText from '@material-ui/core/DialogContentText'; +import DialogTitle from '@material-ui/core/DialogTitle'; function RemoveKeys(props) { + const [open, setOpen] = React.useState(false); const { keyMappingId, keys, selectedTab, handleClickRemove, } = props; + const handleClickOpen = () => { + setOpen(true); + }; + + const handleClose = () => { + setOpen(false); + }; + + const handleRemove = () => { + handleClickRemove(keyMappingId) + }; + return ( - +
+ + + Do you really want to remove keys? + + + This will remove the key entries stored in devportal, gateway as well as in the service provider. + + + + + + + +
); } From a606a9bc13e8941a64b54df005e1c9d748269ece Mon Sep 17 00:00:00 2001 From: Prasanna Dangalla Date: Fri, 11 Aug 2023 12:35:01 +0530 Subject: [PATCH 11/26] Added intl texts. --- .../Shared/AppsAndKeys/CleanKeys.jsx | 27 ++++++++++++++----- .../Shared/AppsAndKeys/RemoveKeys.jsx | 27 ++++++++++++++----- 2 files changed, 42 insertions(+), 12 deletions(-) diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx index 886764aacbc..a4cbb791c8f 100644 --- a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx @@ -39,7 +39,7 @@ function CleanKeys(props) { setOpen(false); }; - const handleRemove = () => { + const handleClean = () => { handleClickClean(keyMappingId); }; @@ -65,18 +65,33 @@ function CleanKeys(props) { aria-labelledby='alert-dialog-title' aria-describedby='alert-dialog-description' > - Do you really want to remove keys? + + + - This will remove only the key entries stored in devportal, gateway and will not remove the service proveder keys. + - diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/RemoveKeys.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/RemoveKeys.jsx index 581d452af91..38d7517e09c 100644 --- a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/RemoveKeys.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/RemoveKeys.jsx @@ -31,7 +31,7 @@ function RemoveKeys(props) { keyMappingId, keys, selectedTab, handleClickRemove, } = props; - const handleClickOpen = () => { + const handleClickOpen = () => { setOpen(true); }; @@ -40,7 +40,7 @@ function RemoveKeys(props) { }; const handleRemove = () => { - handleClickRemove(keyMappingId) + handleClickRemove(keyMappingId); }; return ( @@ -65,18 +65,33 @@ function RemoveKeys(props) { aria-labelledby='alert-dialog-title' aria-describedby='alert-dialog-description' > - Do you really want to remove keys? + + + - This will remove the key entries stored in devportal, gateway as well as in the service provider. + From 3f742cea9a10af048c64db97ec144645c5990698 Mon Sep 17 00:00:00 2001 From: Prasanna Dangalla Date: Sun, 13 Aug 2023 21:58:59 +0530 Subject: [PATCH 12/26] Changes to removeKeys from cleanUpKeys. --- .../src/app/components/Shared/AppsAndKeys/TokenManager.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx index 0bbbabeb212..2c1c8b2b9db 100755 --- a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx @@ -306,7 +306,7 @@ class TokenManager extends React.Component { } = this.props; this.application .then((application) => { - return application.cleanUpKeys(keyType, selectedTab, keyMappingId); + return application.removeKeys(keyType, selectedTab, keyMappingId); }) .then((result) => { if (result) { From ce072dfc8821a7c3b9485923064483a6394d5111 Mon Sep 17 00:00:00 2001 From: Prasanna Dangalla Date: Mon, 14 Aug 2023 12:37:46 +0530 Subject: [PATCH 13/26] Improved admin portal ui code. --- .../KeyManagers/DeleteKeyManager.jsx | 2 +- .../KeyManagers/ListKeyManagerUsages.jsx | 50 ++++++++++--------- .../main/webapp/source/src/app/data/api.js | 12 ----- .../Shared/AppsAndKeys/RemoveKeys.jsx | 2 +- 4 files changed, 28 insertions(+), 38 deletions(-) diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx index a1208e39097..427b8649d6d 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx @@ -38,7 +38,7 @@ function Delete({ updateList, dataRow }) { const isSuperAdmin = isSuperTenant && _scopes.includes('apim:admin_settings'); const fetchData = () => { const restApi = new API(); - restApi.isKeyManagerDeletable(id) + restApi.getKeyManagerUsages(id) .then((result) => { if (result.body) { setDeleteData(false); diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx index f7cf5a9136a..ba41abd58cc 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx @@ -358,29 +358,33 @@ function ListKeyManagerUsages() { ? ( <> - - {data.apiCount === 1 ? '1 API is using this keymanager specifically.' - : data.apiCount + ' APIs are using this keymanager specifically.'} - + + + {data.apiCount === 1 ? '1 API is using this keymanager specifically.' + : data.apiCount + ' APIs are using this keymanager specifically.'} + + - - {data && data.apis.length > 0 && ( - - )} - {data && data.apis.length === 0 && ( -
- - {noDataMessage} - -
- )} -
- + + + + {data && data.apis.length > 0 && ( + + )} + {data && data.apis.length === 0 && ( +
+ + {noDataMessage} + +
+ )} +
+
) : ( @@ -433,7 +437,6 @@ function ListKeyManagerUsages() { )}
- ) : ( @@ -447,7 +450,6 @@ function ListKeyManagerUsages() { )} - diff --git a/portals/admin/src/main/webapp/source/src/app/data/api.js b/portals/admin/src/main/webapp/source/src/app/data/api.js index 93fac1facb1..8f617f178c8 100644 --- a/portals/admin/src/main/webapp/source/src/app/data/api.js +++ b/portals/admin/src/main/webapp/source/src/app/data/api.js @@ -880,18 +880,6 @@ class API extends Resource { }); } - /** - * Check whether the key manager is deletable or not. - */ - isKeyManagerDeletable(keyManagerId) { - return this.client.then((client) => { - return client.apis['Key Manager (Individual)'].get_key_managers_is_deletable__keyManagerId_( - { keyManagerId: keyManagerId }, - this._requestMetaData(), - ); - }); - } - /** * Add an Key Manager */ diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/RemoveKeys.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/RemoveKeys.jsx index 38d7517e09c..ae6123f4d95 100644 --- a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/RemoveKeys.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/RemoveKeys.jsx @@ -75,7 +75,7 @@ function RemoveKeys(props) { From fab258e86726ca8dd8d226467a7f201334435d38 Mon Sep 17 00:00:00 2001 From: Prasanna Dangalla Date: Mon, 14 Aug 2023 15:28:24 +0530 Subject: [PATCH 14/26] Removed clean clean keys method. --- .../KeyManagers/DeleteKeyManager.jsx | 4 +-- .../Shared/AppsAndKeys/CleanKeys.jsx | 2 +- .../Shared/AppsAndKeys/TokenManager.jsx | 28 +------------------ .../source/src/app/data/Application.jsx | 26 ----------------- 4 files changed, 4 insertions(+), 56 deletions(-) diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx index 427b8649d6d..b586ee58102 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx @@ -32,7 +32,7 @@ import { useAppContext } from 'AppComponents/Shared/AppContext'; * @returns {JSX} Loading animation. */ function Delete({ updateList, dataRow }) { - const [deletaData, setDeleteData] = React.useState(true); + const [deletaData, setDeleteData] = React.useState(false); const { id, type, isGlobal } = dataRow; const { isSuperTenant, user: { _scopes } } = useAppContext(); const isSuperAdmin = isSuperTenant && _scopes.includes('apim:admin_settings'); @@ -41,7 +41,7 @@ function Delete({ updateList, dataRow }) { restApi.getKeyManagerUsages(id) .then((result) => { if (result.body) { - setDeleteData(false); + setDeleteData(true); } }) .catch((error) => { diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx index a4cbb791c8f..ec31375d49f 100644 --- a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx @@ -28,7 +28,7 @@ import DialogTitle from '@material-ui/core/DialogTitle'; function CleanKeys(props) { const [open, setOpen] = React.useState(false); const { - keyMappingId, keys, selectedTab, handleClickClean, + keyMappingId, keys, selectedTab, handleClickRemove, } = props; const handleClickOpen = () => { diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx index 2c1c8b2b9db..5f1462d39cf 100755 --- a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx @@ -297,31 +297,6 @@ class TokenManager extends React.Component { }); }; - /** - * Handle onClick of remove keys - * */ - handleClickClean = (keyMappingId) => { - const { - selectedTab, keyType, intl, - } = this.props; - this.application - .then((application) => { - return application.removeKeys(keyType, selectedTab, keyMappingId); - }) - .then((result) => { - if (result) { - this.loadApplication(); - Alert.info(intl.formatMessage({ - id: 'Shared.AppsAndKeys.TokenManager.key.cleanupall.success', - defaultMessage: 'Application keys removed successfully', - })); - } - }) - .catch((error) => { - throw (error); - }); - }; - getDefaultAdditionalProperties(selectedKM) { const { availableGrantTypes, applicationConfiguration } = selectedKM; // Fill the keyRequest.additionalProperties from the selectedKM.applicationConfiguration defaultValues. @@ -926,7 +901,6 @@ class TokenManager extends React.Component { /> )} - {console.log(mode)} {(keymanager.enableTokenGeneration && keys.get(selectedTab) && keys.get(selectedTab).supportedGrantTypes.find((a) => a.includes('client_credentials'))) && ( @@ -946,7 +920,7 @@ class TokenManager extends React.Component { keys={keys} selectedTab={selectedTab} keyMappingId={keyMappingId} - handleClickClean={this.handleClickClean} + handleClickRemove={this.handleClickRemove} /> ))} diff --git a/portals/devportal/src/main/webapp/source/src/app/data/Application.jsx b/portals/devportal/src/main/webapp/source/src/app/data/Application.jsx index 94e23bd298f..f0104d7cfbf 100644 --- a/portals/devportal/src/main/webapp/source/src/app/data/Application.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/data/Application.jsx @@ -226,32 +226,6 @@ export default class Application extends Resource { }); } - /** * - * Cleanup Consumer Secret and Consumer Key for this application instance - * @param {string} keyType Key type either `Production` or `SandBox` - * @param {object} keyManager keyManager configuration object - * @returns {promise} Set the generated token into current instance and return tokenObject - * received as Promise object - */ - cleanUpKeys(keyType, keyManager, keyMappingId) { - const requestContent = { - keyType, - keyMappingId, - keyManager, - }; - const payload = { applicationId: this.id, keyMappingId, body: requestContent }; - return this.client.then((client) => client.apis['Application Keys'] - .post_applications__applicationId__oauth_keys__keyMappingId__clean_up(payload)) - .then((response) => { - if (keyType === 'PRODUCTION') { - this.productionKeys = new Map(); - } else { - this.sandboxKeys = new Map(); - } - return response.ok; - }); - } - removeKeys(keyType, keyManager, keyMappingId) { const requestContent = { keyType, From 12949f3473e92bda7e71eeed4b82f0bbd04c17bc Mon Sep 17 00:00:00 2001 From: Prasanna Dangalla Date: Mon, 14 Aug 2023 15:57:35 +0530 Subject: [PATCH 15/26] MOdified the ui footer. --- .../app/components/KeyManagers/ListKeyManagerUsages.jsx | 9 +++++++++ .../src/main/webapp/site/public/locales/en.json | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx index ba41abd58cc..d4c65b6d76f 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx @@ -64,6 +64,15 @@ const useStyles = makeStyles((theme) => ({ textDecoration: 'none', backgroundColor: theme.palette.error.light, }, + pageTitle: { + minHeight: 43, + backgroundColor: '#f6f6f6', + }, + root: { + flexGrow: 1, + minHeight: 'calc(100vh - (100px))', + backgroundColor: '#eaeff1', + }, })); /** diff --git a/portals/devportal/src/main/webapp/site/public/locales/en.json b/portals/devportal/src/main/webapp/site/public/locales/en.json index 2c827e4f142..90a7bc44484 100644 --- a/portals/devportal/src/main/webapp/site/public/locales/en.json +++ b/portals/devportal/src/main/webapp/site/public/locales/en.json @@ -395,10 +395,15 @@ "Applications.Listing.AppsTableContent.inactive": "INACTIVE", "Applications.Listing.AppsTableContent.rejected": "REJECTED", "Applications.Listing.AppsTableContent.wait.approval": "waiting for approval", + "Applications.Listing.DeleteConfirmation.clean.keys.dialog.content": "This will remove only the key entries stored in devportal,\n gateway and will not remove the service proveder keys.", "Applications.Listing.DeleteConfirmation.dialog,delete": "Delete", "Applications.Listing.DeleteConfirmation.dialog.cancel": "Cancel", "Applications.Listing.DeleteConfirmation.dialog.text.description": "The application will be removed", "Applications.Listing.DeleteConfirmation.dialog.title": "Delete Application", + "Applications.Listing.DeleteConfirmation.remove.keys.dialog.Cancel": "Cancel", + "Applications.Listing.DeleteConfirmation.remove.keys.dialog.Delete": "Delete", + "Applications.Listing.DeleteConfirmation.remove.keys.dialog.content": "This will remove the key entries stored in devportal,\n gateway as well as in the service provider.", + "Applications.Listing.DeleteConfirmation.remove.keys.dialog.title": "Do you really want to remove keys?", "Applications.Listing.Listing.application.deleted.successfully": "Application {name} deleted successfully!", "Applications.Listing.Listing.application.deleting.error": "Error while deleting application {name}", "Applications.Listing.Listing.application.deleting.requested": "Delete request created for application {name}", @@ -555,6 +560,7 @@ "Shared.AppsAndKeys.TokenManager.key.and.user.owner": "Only owner can generate or update keys", "Shared.AppsAndKeys.TokenManager.key.cleanup.error": "Error occurred while cleaning up application keys", "Shared.AppsAndKeys.TokenManager.key.cleanup.success": "Application keys cleaned successfully", + "Shared.AppsAndKeys.TokenManager.key.cleanupall.success": "Application keys removed successfully", "Shared.AppsAndKeys.TokenManager.key.configuration": "Key Configuration", "Shared.AppsAndKeys.TokenManager.key.generate.bad.request.error": "Error occurred when generating Access Token", "Shared.AppsAndKeys.TokenManager.key.generate.error": "Error occurred when generating application keys", @@ -608,6 +614,7 @@ "Shared.AppsAndKeys.ViewKeys.curl.to.generate": "CURL to Generate Access Token", "Shared.AppsAndKeys.ViewKeys.generate.access.token": "Generate Access Token", "Shared.AppsAndKeys.ViewKeys.key.secret.title": "Key and Secret is not generated for this application", + "Shared.AppsAndKeys.ViewKeys.remove.keys": "Remove Keys", "Shared.AppsAndKeys.ViewSecret.consumer.secret": "Consumer Secret", "Shared.AppsAndKeys.ViewSecret.copied": "Copied", "Shared.AppsAndKeys.ViewSecret.copy.to.clipboard": "Copy to clipboard", From bca7e9aed7e7b103dc19488b0fa54719cf448796 Mon Sep 17 00:00:00 2001 From: Prasanna Dangalla Date: Mon, 14 Aug 2023 17:18:21 +0530 Subject: [PATCH 16/26] Fixed key manager delete ui issue. --- .../src/app/components/KeyManagers/DeleteKeyManager.jsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx index b586ee58102..f4d0ea54026 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx @@ -32,7 +32,7 @@ import { useAppContext } from 'AppComponents/Shared/AppContext'; * @returns {JSX} Loading animation. */ function Delete({ updateList, dataRow }) { - const [deletaData, setDeleteData] = React.useState(false); + const [deletaData, setDeleteData] = React.useState(true); const { id, type, isGlobal } = dataRow; const { isSuperTenant, user: { _scopes } } = useAppContext(); const isSuperAdmin = isSuperTenant && _scopes.includes('apim:admin_settings'); @@ -40,15 +40,14 @@ function Delete({ updateList, dataRow }) { const restApi = new API(); restApi.getKeyManagerUsages(id) .then((result) => { - if (result.body) { - setDeleteData(true); + if (result.body.apiCount === 0 && result.body.applicationCount === 0) { + setDeleteData(false); } }) .catch((error) => { const { status } = error; throw (error); }); - console.log(id); }; useEffect(() => { From 26ef6073bbd1e1a1b4d7121eb82b6934c9dd0850 Mon Sep 17 00:00:00 2001 From: Prasanna Dangalla Date: Mon, 14 Aug 2023 18:05:07 +0530 Subject: [PATCH 17/26] Improved UI code. --- portals/admin/src/main/webapp/site/public/locales/en.json | 2 +- .../app/components/KeyManagers/ListKeyManagerUsages.jsx | 7 ++++++- .../src/app/components/Shared/AppsAndKeys/CleanKeys.jsx | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/portals/admin/src/main/webapp/site/public/locales/en.json b/portals/admin/src/main/webapp/site/public/locales/en.json index 4b280dcc597..1443760612c 100644 --- a/portals/admin/src/main/webapp/site/public/locales/en.json +++ b/portals/admin/src/main/webapp/site/public/locales/en.json @@ -290,7 +290,7 @@ "KeyManagers.AddEditKeyManager.token.handling.options": "Token Handling Options", "KeyManagers.AddEditKeyManager.token.validation.method": "Token Validation Method", "KeyManagers.AddEditKeyManager.useIntrospect": "Use introspect", - "KeyManagers.AddEditKeyManager.usages": "Key Manager - usages", + "KeyManagers.AddEditKeyManager.usages": "Key Manager Usages - ", "KeyManagers.AddEditTokenExchangeIDP.form.Issuer": "Issuer", "KeyManagers.AddEditTokenExchangeIDP.form.issuer.help": "E.g.,: https://localhost:9443/oauth2/token", "KeyManagers.AddEditTokenExchangeIDP.form.tokenEndpoint": "Token Endpoint", diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx index d4c65b6d76f..59cc256fb5f 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx @@ -86,6 +86,7 @@ function ListKeyManagerUsages() { const restApi = new API(); const classes = useStyles(); const [hasListPermission, setHasListPermission] = useState(true); + const [kmName, setKmName] = useState(''); const [errorMessage, setError] = useState(null); const { id } = useParams(); @@ -128,6 +129,9 @@ function ListKeyManagerUsages() { useEffect(() => { fetchData(); + restApi.keyManagerGet(id).then((result) => { + setKmName(result.body.name); + }); }, []); const pageProps = { @@ -322,8 +326,9 @@ function ListKeyManagerUsages() { + {kmName} diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx index ec31375d49f..cb215479f68 100644 --- a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx @@ -40,7 +40,7 @@ function CleanKeys(props) { }; const handleClean = () => { - handleClickClean(keyMappingId); + handleClickRemove(keyMappingId); }; return ( From 4c2310b0ed5ffda43da711411df94120112b426d Mon Sep 17 00:00:00 2001 From: Prasanna Dangalla Date: Mon, 14 Aug 2023 18:09:28 +0530 Subject: [PATCH 18/26] Added intel texts. --- .../KeyManagers/ListKeyManagerUsages.jsx | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx index 59cc256fb5f..5dfb6da4670 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx @@ -364,7 +364,10 @@ function ListKeyManagerUsages() { - API Usages + @@ -405,7 +408,10 @@ function ListKeyManagerUsages() { - No API usages for this keymanager specifically. + @@ -414,7 +420,10 @@ function ListKeyManagerUsages() { - Application Usages + @@ -457,7 +466,10 @@ function ListKeyManagerUsages() { - No Application usages for this keymanager specifically. + From cf08d3ceb006d6b3aea840fa36636c33fed94958 Mon Sep 17 00:00:00 2001 From: Prasanna Dangalla Date: Mon, 14 Aug 2023 18:52:02 +0530 Subject: [PATCH 19/26] Improved delete ui function. --- .../source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx | 2 -- .../src/app/components/Shared/AppsAndKeys/RemoveKeys.jsx | 2 -- .../src/app/components/Shared/AppsAndKeys/TokenManager.jsx | 3 +-- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx index cb215479f68..998bcd8dabb 100644 --- a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx @@ -51,8 +51,6 @@ function CleanKeys(props) { color='secondary' startIcon={} onClick={handleClickOpen} - disabled={!keys.get(selectedTab) - .supportedGrantTypes.includes('client_credentials')} > } onClick={handleClickOpen} - disabled={!keys.get(selectedTab) - .supportedGrantTypes.includes('client_credentials')} > )} - {(keymanager.enableTokenGeneration && keys.get(selectedTab) - && keys.get(selectedTab).supportedGrantTypes.find((a) => a.includes('client_credentials'))) + {(keymanager.enableTokenGeneration && keys.get(selectedTab)) && ( mode !== 'MAPPED' ? ( From 8600a4bf08ad6364665556553e858aa517e64d1c Mon Sep 17 00:00:00 2001 From: Prasanna Dangalla Date: Tue, 15 Aug 2023 14:08:25 +0530 Subject: [PATCH 20/26] Added REST api changes to UI components. --- portals/admin/src/main/webapp/source/src/app/data/api.js | 2 +- .../src/main/webapp/source/src/app/data/Application.jsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/portals/admin/src/main/webapp/source/src/app/data/api.js b/portals/admin/src/main/webapp/source/src/app/data/api.js index 8f617f178c8..b0f47e9a365 100644 --- a/portals/admin/src/main/webapp/source/src/app/data/api.js +++ b/portals/admin/src/main/webapp/source/src/app/data/api.js @@ -873,7 +873,7 @@ class API extends Resource { */ getKeyManagerUsages(keyManagerId) { return this.client.then((client) => { - return client.apis['Key Manager (Individual)'].get_key_managers_usages__keyManagerId_( + return client.apis['Key Manager (Individual)'].get_key_managers__keyManagerId__usages( { keyManagerId: keyManagerId }, this._requestMetaData(), ); diff --git a/portals/devportal/src/main/webapp/source/src/app/data/Application.jsx b/portals/devportal/src/main/webapp/source/src/app/data/Application.jsx index f0104d7cfbf..231054e8402 100644 --- a/portals/devportal/src/main/webapp/source/src/app/data/Application.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/data/Application.jsx @@ -234,7 +234,7 @@ export default class Application extends Resource { }; const payload = { applicationId: this.id, keyMappingId, body: requestContent }; return this.client.then((client) => client.apis['Application Keys'] - .post_applications__applicationId__oauth_keys__keyMappingId__remove_keys(payload)) + .delete_applications__applicationId__oauth_keys__keyMappingId_(payload)) .then((response) => { if (keyType === 'PRODUCTION') { this.productionKeys = new Map(); From b8ef9b5fb1b74b54901c0d0ccdf12083f7dad870 Mon Sep 17 00:00:00 2001 From: Savindu Dimal Date: Mon, 18 Mar 2024 17:32:19 +0530 Subject: [PATCH 21/26] Fix multiple issues - Remove unnecessary eslint-disable - Fix spelling mistakes - Fix formatting issues - Add changes related to MUI v5 --- .../KeyManagers/DeleteKeyManager.jsx | 4 +- .../KeyManagers/ListKeyManagerUsages.jsx | 126 +++++++----------- .../KeyManagers/ListKeyManagers.jsx | 20 +-- .../Shared/AppsAndKeys/CleanKeys.jsx | 17 +-- .../Shared/AppsAndKeys/RemoveKeys.jsx | 17 +-- .../Shared/AppsAndKeys/TokenManager.jsx | 5 +- .../Shared/AppsAndKeys/ViewKeys.jsx | 47 ++++--- .../source/src/app/data/Application.jsx | 3 +- 8 files changed, 107 insertions(+), 132 deletions(-) diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx index f4d0ea54026..b87e85fa41f 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx @@ -1,4 +1,3 @@ -/* eslint-disable no-unused-vars */ /* * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * @@ -17,7 +16,7 @@ * under the License. */ -import React, { useEffect, useState } from 'react'; +import React, { useEffect } from 'react'; import API from 'AppData/api'; import PropTypes from 'prop-types'; import { FormattedMessage } from 'react-intl'; @@ -45,7 +44,6 @@ function Delete({ updateList, dataRow }) { } }) .catch((error) => { - const { status } = error; throw (error); }); }; diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx index 5dfb6da4670..b494e482711 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx @@ -1,4 +1,3 @@ -/* eslint-disable react/jsx-props-no-spreading */ /* * Copyright (c) 2023, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * @@ -19,51 +18,41 @@ import React, { useEffect, useState } from 'react'; import { FormattedMessage, useIntl } from 'react-intl'; -import Typography from '@material-ui/core/Typography'; -import Grid from '@material-ui/core/Grid'; -import { makeStyles } from '@material-ui/core/styles'; -import Card from '@material-ui/core/Card'; -import CardActions from '@material-ui/core/CardActions'; -import CardContent from '@material-ui/core/CardContent'; +import Typography from '@mui/material/Typography'; +import Grid from '@mui/material/Grid'; +import { styled, Alert as MUIAlert } from '@mui/material'; +import Card from '@mui/material/Card'; +import CardActions from '@mui/material/CardActions'; +import CardContent from '@mui/material/CardContent'; import MUIDataTable from 'mui-datatables'; import ContentBase from 'AppComponents/AdminPages/Addons/ContentBase'; import InlineProgress from 'AppComponents/AdminPages/Addons/InlineProgress'; import Alert from 'AppComponents/Shared/Alert'; -import List from '@material-ui/core/List'; -import Paper from '@material-ui/core/Paper'; -import ListItem from '@material-ui/core/ListItem'; -import ListItemIcon from '@material-ui/core/ListItemIcon'; -import ListItemText from '@material-ui/core/ListItemText'; -import HelpBase from 'AppComponents/AdminPages/Addons/HelpBase'; -import DescriptionIcon from '@material-ui/icons/Description'; -import Link from '@material-ui/core/Link'; -import Configurations from 'Config'; +import Paper from '@mui/material/Paper'; import API from 'AppData/api'; import WarningBase from 'AppComponents/AdminPages/Addons/WarningBase'; -import { Alert as MUIAlert } from '@material-ui/lab'; import { useParams } from 'react-router-dom'; -import Box from '@material-ui/core/Box'; -import clsx from 'clsx'; -import Toolbar from '@material-ui/core/Toolbar'; +import Box from '@mui/material/Box'; +import Toolbar from '@mui/material/Toolbar'; -const useStyles = makeStyles((theme) => ({ - searchInput: { +const styles = { + searchInput: (theme) => ({ fontSize: theme.typography.fontSize, - }, + }), block: { display: 'block', }, - contentWrapper: { + contentWrapper: (theme) => ({ margin: theme.spacing(2), - }, - approveButton: { + }), + approveButton: (theme) => ({ textDecoration: 'none', backgroundColor: theme.palette.success.light, - }, - rejectButton: { + }), + rejectButton: (theme) => ({ textDecoration: 'none', backgroundColor: theme.palette.error.light, - }, + }), pageTitle: { minHeight: 43, backgroundColor: '#f6f6f6', @@ -73,7 +62,9 @@ const useStyles = makeStyles((theme) => ({ minHeight: 'calc(100vh - (100px))', backgroundColor: '#eaeff1', }, -})); +}; + +const StyledDiv = styled('div')({}); /** * Render a list @@ -84,7 +75,6 @@ function ListKeyManagerUsages() { const intl = useIntl(); const [data, setData] = useState(null); const restApi = new API(); - const classes = useStyles(); const [hasListPermission, setHasListPermission] = useState(true); const [kmName, setKmName] = useState(''); const [errorMessage, setError] = useState(null); @@ -183,8 +173,8 @@ function ListKeyManagerUsages() { { name: 'name', label: intl.formatMessage({ - id: 'Aplication.Name', - defaultMessage: 'Aplication Name', + id: 'Application.Name', + defaultMessage: 'Application Name', }), options: { sort: false, @@ -194,8 +184,8 @@ function ListKeyManagerUsages() { { name: 'owner', label: intl.formatMessage({ - id: 'Aplication.Owner', - defaultMessage: 'Aplication Owner', + id: 'Application.Owner', + defaultMessage: 'Application Owner', }), options: { sort: false, @@ -205,8 +195,8 @@ function ListKeyManagerUsages() { { name: 'organization', label: intl.formatMessage({ - id: 'Aplication.organization', - defaultMessage: 'Aplication organization', + id: 'Application.organization', + defaultMessage: 'Application Organization', }), options: { sort: false, @@ -249,7 +239,7 @@ function ListKeyManagerUsages() { {...pageProps} pageStyle='small' > - + -
+ - + {kmName} - - - - - - - - - - )} - /> - - - - - @@ -377,8 +342,10 @@ function ListKeyManagerUsages() { - {data.apiCount === 1 ? '1 API is using this keymanager specifically.' - : data.apiCount + ' APIs are using this keymanager specifically.'} + {data.apiCount === 1 + ? '1 API is using this key manager specifically.' + : data.apiCount + + ' APIs are using this key manager specifically.'} @@ -394,11 +361,11 @@ function ListKeyManagerUsages() { /> )} {data && data.apis.length === 0 && ( -
+ {noDataMessage} -
+
)} @@ -410,7 +377,7 @@ function ListKeyManagerUsages() { @@ -421,7 +388,7 @@ function ListKeyManagerUsages() { @@ -434,9 +401,9 @@ function ListKeyManagerUsages() { {data.applicationCount === 1 ? '1 Application is using this ' - + 'keymanager specifically.' + + 'key manager specifically.' : data.applicationCount + ' Applications are using this ' - + 'keymanager specifically.'} + + 'key manager specifically.'} @@ -452,11 +419,11 @@ function ListKeyManagerUsages() { /> )} {data && data.applicationCount.length === 0 && ( -
+ {noDataMessage} -
+ )}
@@ -467,8 +434,9 @@ function ListKeyManagerUsages() { @@ -477,7 +445,7 @@ function ListKeyManagerUsages() { -
+ ); } diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagers.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagers.jsx index 4b4e7db8992..d82571bbfcc 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagers.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagers.jsx @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * WSO2 Inc. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -194,8 +194,8 @@ export default function ListKeyManagers() { const updateSomething = () => { const restApi = new API(); const kmName = rowData[0]; - const kmId = rowData[5]; - const isGlobal = rowData[6]; + const kmId = rowData[6]; + const isGlobal = rowData[7]; (isGlobal ? restApi.globalKeyManagerGet(kmId) : restApi.keyManagerGet(kmId)).then((result) => { let editState; if (result.body.name !== null) { @@ -223,10 +223,10 @@ export default function ListKeyManagers() { }); }); }; - const kmEnabled = rowData[4]; + const kmEnabled = rowData[5]; return ( { if (typeof tableMeta.rowData === 'object') { - const artifactId = tableMeta.rowData[5]; + const artifactId = tableMeta.rowData[6]; return ( {value} {' '} - {tableMeta.rowData[6] && ( + {tableMeta.rowData[7] && ( { if (typeof tableMeta.rowData === 'object') { - const artifactId = tableMeta.rowData[tableMeta.rowData.length - 2]; + const artifactId = tableMeta.rowData[6]; return ( @@ -337,7 +337,7 @@ export default function ListKeyManagers() { const itemName = (typeof tableMeta.rowData === 'object') ? tableMeta.rowData[0] : ''; if (editComponentProps && editComponentProps.routeTo) { if (typeof tableMeta.rowData === 'object') { - const artifactId = tableMeta.rowData[tableMeta.rowData.length - 2]; + const artifactId = tableMeta.rowData[6]; return (
diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx index 998bcd8dabb..f6a0b28ac7a 100644 --- a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/CleanKeys.jsx @@ -15,20 +15,21 @@ * specific language governing permissions and limitations * under the License. */ + import React from 'react'; -import Button from '@material-ui/core/Button'; +import Button from '@mui/material/Button'; import { FormattedMessage } from 'react-intl'; -import DeleteIcon from '@material-ui/icons/Delete'; -import Dialog from '@material-ui/core/Dialog'; -import DialogActions from '@material-ui/core/DialogActions'; -import DialogContent from '@material-ui/core/DialogContent'; -import DialogContentText from '@material-ui/core/DialogContentText'; -import DialogTitle from '@material-ui/core/DialogTitle'; +import DeleteIcon from '@mui/icons-material/Delete'; +import Dialog from '@mui/material/Dialog'; +import DialogActions from '@mui/material/DialogActions'; +import DialogContent from '@mui/material/DialogContent'; +import DialogContentText from '@mui/material/DialogContentText'; +import DialogTitle from '@mui/material/DialogTitle'; function CleanKeys(props) { const [open, setOpen] = React.useState(false); const { - keyMappingId, keys, selectedTab, handleClickRemove, + keyMappingId, handleClickRemove, } = props; const handleClickOpen = () => { diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/RemoveKeys.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/RemoveKeys.jsx index e0f9ef18ccc..15cf707972f 100644 --- a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/RemoveKeys.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/RemoveKeys.jsx @@ -15,20 +15,21 @@ * specific language governing permissions and limitations * under the License. */ + import React from 'react'; -import Button from '@material-ui/core/Button'; +import Button from '@mui/material/Button'; import { FormattedMessage } from 'react-intl'; -import DeleteIcon from '@material-ui/icons/Delete'; -import Dialog from '@material-ui/core/Dialog'; -import DialogActions from '@material-ui/core/DialogActions'; -import DialogContent from '@material-ui/core/DialogContent'; -import DialogContentText from '@material-ui/core/DialogContentText'; -import DialogTitle from '@material-ui/core/DialogTitle'; +import DeleteIcon from '@mui/icons-material/Delete'; +import Dialog from '@mui/material/Dialog'; +import DialogActions from '@mui/material/DialogActions'; +import DialogContent from '@mui/material/DialogContent'; +import DialogContentText from '@mui/material/DialogContentText'; +import DialogTitle from '@mui/material/DialogTitle'; function RemoveKeys(props) { const [open, setOpen] = React.useState(false); const { - keyMappingId, keys, selectedTab, handleClickRemove, + keyMappingId, handleClickRemove, } = props; const handleClickOpen = () => { diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx index d0482709f89..a360c285f46 100755 --- a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/TokenManager.jsx @@ -15,6 +15,7 @@ * specific language governing permissions and limitations * under the License. */ + import React from 'react'; import { styled } from '@mui/material/styles'; import PropTypes from 'prop-types'; @@ -165,7 +166,7 @@ const Root = styled('div')(( [`& .${classes.leftCol}`]: { width: 180, - } + }, })); function TabPanel(props) { @@ -235,7 +236,6 @@ class TokenManager extends React.Component { importDisabled: false, mode: null, tokenType: 'DIRECT', - isExchangeTokenError: false, }; this.keyStates = { COMPLETED: 'COMPLETED', @@ -1309,7 +1309,6 @@ class TokenManager extends React.Component { callbackError={hasError} setValidating={this.setValidating} defaultTokenEndpoint={defaultTokenEndpoint} - selectedApp={selectedApp} /> diff --git a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/ViewKeys.jsx b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/ViewKeys.jsx index 583bd9090b6..92dfa9c45d2 100755 --- a/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/ViewKeys.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/components/Shared/AppsAndKeys/ViewKeys.jsx @@ -15,9 +15,9 @@ * specific language governing permissions and limitations * under the License. */ + import React from 'react'; import { styled } from '@mui/material/styles'; -import API from 'AppData/api'; import { withRouter } from 'react-router-dom'; import PropTypes from 'prop-types'; import IconButton from '@mui/material/IconButton'; @@ -247,7 +247,9 @@ class ViewKeys extends React.Component { * Handle onCLick of remove keys * */ handleClickRemove = (keyMappingId) => { - const { selectedTab, keyType, intl, loadApplication } = this.props; + const { + selectedTab, keyType, intl, loadApplication, + } = this.props; this.applicationPromise .then((application) => { return application.removeKeys(keyType, selectedTab, keyMappingId); @@ -394,24 +396,26 @@ class ViewKeys extends React.Component { } placement='right' > - {navigator.clipboard.writeText(consumerKey). - then(() => this.onCopy('keyCopied'))}} - > - - file_copy - - + { + navigator.clipboard.writeText(consumerKey) + .then(() => this.onCopy('keyCopied')); + }} + > + + file_copy + + ), }} /> - + this.handleShowHidden('showCS')} onMouseDown={this.handleMouseDownGeneric} id='visibility-toggle-btn' - size="large"> + size='large' + > {showCS ? visibility_off : visibility} {navigator.clipboard. - writeText(consumerSecret).then(() => this.onCopy('secretCopied'))}} + size='large' + onClick={() => { + navigator.clipboard + .writeText(consumerSecret).then(() => this.onCopy('secretCopied')); + }} > file_copy @@ -493,7 +500,7 @@ class ViewKeys extends React.Component { )} {!hashEnabled && ( - + { const requestContent = { keyManager, From ff36659bbcb5f371c2f85ccecfc73479964a9990 Mon Sep 17 00:00:00 2001 From: Savindu Dimal Date: Thu, 21 Mar 2024 14:31:13 +0530 Subject: [PATCH 22/26] Add popup for key manager usages --- .../KeyManagers/DeleteKeyManager.jsx | 22 +- .../KeyManagers/ListKeyManagerUsages.jsx | 342 ++++++++++-------- .../KeyManagers/ListKeyManagers.jsx | 92 ++++- .../src/app/components/KeyManagers/index.jsx | 2 - .../main/webapp/source/src/app/data/api.js | 24 ++ .../source/src/app/data/Application.jsx | 27 ++ 6 files changed, 319 insertions(+), 190 deletions(-) diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx index b87e85fa41f..8330fdeb774 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/DeleteKeyManager.jsx @@ -16,7 +16,7 @@ * under the License. */ -import React, { useEffect } from 'react'; +import React from 'react'; import API from 'AppData/api'; import PropTypes from 'prop-types'; import { FormattedMessage } from 'react-intl'; @@ -30,27 +30,11 @@ import { useAppContext } from 'AppComponents/Shared/AppContext'; * @param {JSON} props component props. * @returns {JSX} Loading animation. */ -function Delete({ updateList, dataRow }) { - const [deletaData, setDeleteData] = React.useState(true); +function Delete({ updateList, dataRow, isDisabled }) { const { id, type, isGlobal } = dataRow; const { isSuperTenant, user: { _scopes } } = useAppContext(); const isSuperAdmin = isSuperTenant && _scopes.includes('apim:admin_settings'); - const fetchData = () => { - const restApi = new API(); - restApi.getKeyManagerUsages(id) - .then((result) => { - if (result.body.apiCount === 0 && result.body.applicationCount === 0) { - setDeleteData(false); - } - }) - .catch((error) => { - throw (error); - }); - }; - useEffect(() => { - fetchData(); - }, []); const formSaveCallback = () => { // todo: don't create a new promise const promiseAPICall = new Promise((resolve, reject) => { @@ -84,7 +68,7 @@ function Delete({ updateList, dataRow }) { triggerIconProps={{ color: 'primary', component: 'span', - disabled: type === 'default' || (isGlobal && !isSuperAdmin) || deletaData, + disabled: type === 'default' || (isGlobal && !isSuperAdmin) || isDisabled, }} > diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx index b494e482711..c62e81b6f59 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx @@ -17,6 +17,7 @@ */ import React, { useEffect, useState } from 'react'; +import PropTypes from 'prop-types'; import { FormattedMessage, useIntl } from 'react-intl'; import Typography from '@mui/material/Typography'; import Grid from '@mui/material/Grid'; @@ -31,9 +32,11 @@ import Alert from 'AppComponents/Shared/Alert'; import Paper from '@mui/material/Paper'; import API from 'AppData/api'; import WarningBase from 'AppComponents/AdminPages/Addons/WarningBase'; -import { useParams } from 'react-router-dom'; import Box from '@mui/material/Box'; -import Toolbar from '@mui/material/Toolbar'; +import Tab from '@mui/material/Tab'; +import TabContext from '@mui/lab/TabContext'; +import TabList from '@mui/lab/TabList'; +import TabPanel from '@mui/lab/TabPanel'; const styles = { searchInput: (theme) => ({ @@ -57,11 +60,11 @@ const styles = { minHeight: 43, backgroundColor: '#f6f6f6', }, - root: { - flexGrow: 1, - minHeight: 'calc(100vh - (100px))', - backgroundColor: '#eaeff1', - }, + // root: { + // flexGrow: 1, + // minHeight: 'calc(100vh - (100px))', + // backgroundColor: '#eaeff1', + // }, }; const StyledDiv = styled('div')({}); @@ -71,14 +74,19 @@ const StyledDiv = styled('div')({}); * @param {JSON} props props passed from parent * @returns {JSX} Header AppBar components. */ -function ListKeyManagerUsages() { +function ListKeyManagerUsages(props) { const intl = useIntl(); const [data, setData] = useState(null); + const [appData, setAppData] = useState(null); const restApi = new API(); const [hasListPermission, setHasListPermission] = useState(true); - const [kmName, setKmName] = useState(''); const [errorMessage, setError] = useState(null); - const { id } = useParams(); + const { id } = props; + const [value, setValue] = useState('1'); + + const handleChange = (event, newValue) => { + setValue(newValue); + }; /** * API call to get Detected Data @@ -86,7 +94,31 @@ function ListKeyManagerUsages() { */ function apiCall() { return restApi - .getKeyManagerUsages(id) + .getKeyManagerApiUsages(id) + .then((result) => { + return result.body; + }) + .catch((error) => { + const { status } = error; + if (status === 401) { + setHasListPermission(false); + } else { + Alert.error(intl.formatMessage({ + id: 'KeyManagers.ListKeyManagerAPIUsages.error', + defaultMessage: 'Unable to get Key Manager API usage details', + })); + throw (error); + } + }); + } + + /** + * API call to get Application usage data + * @returns {Promise}. + */ + function applicationApiCall() { + return restApi + .getKeyManagerApplicationUsages(id) .then((result) => { return result.body; }) @@ -96,8 +128,8 @@ function ListKeyManagerUsages() { setHasListPermission(false); } else { Alert.error(intl.formatMessage({ - id: 'KeyManagers.ListKeyManagerUsages.error', - defaultMessage: 'Unable to get Key Manager usage details', + id: 'KeyManagers.ListKeyManagerApplicationUsages.error', + defaultMessage: 'Unable to get Key Manager application usage details', })); throw (error); } @@ -115,13 +147,20 @@ function ListKeyManagerUsages() { console.error('Unable to fetch data. ', e.message); setError(e.message); }); + + setAppData(null); + const promiseApplicationAPICall = applicationApiCall(); + promiseApplicationAPICall.then((LocalData) => { + setAppData(LocalData); + }) + .catch((e) => { + console.error('Unable to fetch data. ', e.message); + setError(e.message); + }); }; useEffect(() => { fetchData(); - restApi.keyManagerGet(id).then((result) => { - setKmName(result.body.name); - }); }, []); const pageProps = { @@ -243,14 +282,14 @@ function ListKeyManagerUsages() { @@ -270,15 +309,15 @@ function ListKeyManagerUsages() { pageProps={pageProps} title={( )} content={( )} /> @@ -302,152 +341,145 @@ function ListKeyManagerUsages() { } return ( <> - - - - - - - - - {kmName} - - - - - - - - - - - - - - - {data.apiCount > 0 - ? ( - <> + + + + + + + + + + + + {data.apiCount > 0 + ? ( + <> + + + + {data.apiCount === 1 + ? '1 API is using this key manager specifically.' + : data.apiCount + + ' APIs are using this key manager specifically.'} + + + + + + + {data && data.apis.length > 0 && ( + + )} + {data && data.apis.length === 0 && ( + + + {noDataMessage} + + + )} + + + + ) + : ( - {data.apiCount === 1 - ? '1 API is using this key manager specifically.' - : data.apiCount - + ' APIs are using this key manager specifically.'} + - - - - {data && data.apis.length > 0 && ( - - )} - {data && data.apis.length === 0 && ( - - - {noDataMessage} - - - )} - - - - ) - : ( - - - - - - - - )} - - - - - - - - - {data.applicationCount > 0 - ? ( - <> + )} + + + + + + + + + {appData.applicationCount > 0 + ? ( + <> + + + + {appData.applicationCount === 1 ? '1 Application is using this ' + + 'key manager specifically.' + : appData.applicationCount + ' Applications are using this ' + + 'key manager specifically.'} + + + + + + + {appData && appData.applications.length > 0 && ( + + )} + {appData && appData.applicationCount.length === 0 && ( + + + {noDataMessage} + + + )} + + + + ) + : ( - {data.applicationCount === 1 ? '1 Application is using this ' - + 'key manager specifically.' - : data.applicationCount + ' Applications are using this ' - + 'key manager specifically.'} + - - - - {data && data.applications.length > 0 && ( - - )} - {data && data.applicationCount.length === 0 && ( - - - {noDataMessage} - - - )} - - - - ) - : ( - - - - - - - - )} - + )} + + - - + + ); } +ListKeyManagerUsages.propTypes = { + id: PropTypes.string.isRequired, + name: PropTypes.string.isRequired, + dialogOpen: PropTypes.bool.isRequired, + closeDialog: PropTypes.func.isRequired, +}; + export default ListKeyManagerUsages; diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagers.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagers.jsx index d82571bbfcc..f9a9905f4db 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagers.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagers.jsx @@ -1,3 +1,4 @@ +/* eslint-disable require-jsdoc */ /* * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * @@ -26,7 +27,8 @@ import Alert from 'AppComponents/Shared/Alert'; import Switch from '@mui/material/Switch'; import Button from '@mui/material/Button'; import { - Chip, ButtonGroup, ClickAwayListener, MenuItem, MenuList, Popper, Paper, styled, + Chip, ButtonGroup, ClickAwayListener, MenuItem, MenuList, + Popper, Paper, styled, Dialog, DialogTitle, DialogContent, DialogActions, } from '@mui/material'; import { useAppContext } from 'AppComponents/Shared/AppContext'; import ContentBase from 'AppComponents/AdminPages/Addons/ContentBase'; @@ -46,6 +48,7 @@ import CardActions from '@mui/material/CardActions'; import CardContent from '@mui/material/CardContent'; import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown'; import FormatListBulletedIcon from '@mui/icons-material/FormatListBulleted'; +import ListKeyManagerUsages from './ListKeyManagerUsages'; const styles = { searchBar: { @@ -132,6 +135,9 @@ export default function ListKeyManagers() { const [open, setOpen] = useState(false); const anchorRef = React.useRef(null); const [selectedIndex, setSelectedIndex] = useState(0); + const [dialogOpen, setDialogOpen] = useState(false); + const [selectedArtifactId, setSelectedArtifactId] = useState(null); + const [selectedKMName, setSelectedKMName] = useState(null); const setKeyManagerState = (localKmList, globalKmList) => { const localKMArray = localKmList || []; @@ -236,6 +242,17 @@ export default function ListKeyManagers() { }, ]; + const openDialog = (artifactId, kmName) => { + setSelectedArtifactId(artifactId); + setSelectedKMName(kmName); + setDialogOpen(true); + }; + + const closeDialog = () => { + setSelectedArtifactId(null); + setDialogOpen(false); + }; + const columns = [ { name: 'name', @@ -312,10 +329,15 @@ export default function ListKeyManagers() { customBodyRender: (value, tableMeta) => { if (typeof tableMeta.rowData === 'object') { const artifactId = tableMeta.rowData[6]; + const kmName = tableMeta.rowData[0]; + const isGlobal = tableMeta.rowData[7]; return ( - - - + openDialog(artifactId, kmName)} + > + + ); } else { return
; @@ -338,6 +360,12 @@ export default function ListKeyManagers() { if (editComponentProps && editComponentProps.routeTo) { if (typeof tableMeta.rowData === 'object') { const artifactId = tableMeta.rowData[6]; + let tooltipTitle = ''; + if (dataRow.isGlobal && !isSuperAdmin) { + tooltipTitle = 'Global Key Manager only can be deleted by the super admin user'; + } else if (dataRow.isUsed) { + tooltipTitle = 'Key manager is used by an API or an Application'; + } return (
@@ -345,11 +373,17 @@ export default function ListKeyManagers() { - + + + + + {addedActions && addedActions.map((action) => { const AddedComponent = action; return ( @@ -362,13 +396,25 @@ export default function ListKeyManagers() { return (
); } } + let tooltipTitle = ''; + if (dataRow.isGlobal && !isSuperAdmin) { + tooltipTitle = 'Global Key Manager only can be deleted by the super admin user'; + } else if (dataRow.isUsed) { + tooltipTitle = 'Key manager is used by an API or an Application'; + } return (
- + + + + + {addedActions && addedActions.map((action) => { const AddedComponent = action; return ( @@ -660,6 +706,24 @@ export default function ListKeyManagers() { )} + + + Key Manager Usages - + {' '} + {selectedKMName} + + + + + + + +
diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/index.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/index.jsx index 6e8a2f0fa88..e64ce98547e 100755 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/index.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/index.jsx @@ -3,7 +3,6 @@ import { Route, Switch, withRouter } from 'react-router-dom'; import ResourceNotFound from 'AppComponents/Base/Errors/ResourceNotFound'; import ListKeyManagers from './ListKeyManagers'; import AddEditKeyManager from './AddEditKeyManager'; -import ListKeyManagerUsages from './ListKeyManagerUsages'; /** * Render a list @@ -15,7 +14,6 @@ function KeyManagers() { - ); diff --git a/portals/admin/src/main/webapp/source/src/app/data/api.js b/portals/admin/src/main/webapp/source/src/app/data/api.js index b0f47e9a365..16ff428088c 100644 --- a/portals/admin/src/main/webapp/source/src/app/data/api.js +++ b/portals/admin/src/main/webapp/source/src/app/data/api.js @@ -879,6 +879,30 @@ class API extends Resource { ); }); } + + /** + * Get key manager application usages + */ + getKeyManagerApplicationUsages(keyManagerId) { + return this.client.then((client) => { + return client.apis["Key Manager (Individual)"].get_key_managers__keyManagerId__app_usages( + { keyManagerId: keyManagerId }, + this._requestMetaData(), + ); + }); + } + + /** + * Get key manager api usages + */ + getKeyManagerApiUsages(keyManagerId) { + return this.client.then((client) => { + return client.apis["Key Manager (Individual)"].get_key_managers__keyManagerId__api_usages( + { keyManagerId: keyManagerId }, + this._requestMetaData(), + ); + }); + } /** * Add an Key Manager diff --git a/portals/devportal/src/main/webapp/source/src/app/data/Application.jsx b/portals/devportal/src/main/webapp/source/src/app/data/Application.jsx index 8c1d7a78374..6d9f5f1acc5 100644 --- a/portals/devportal/src/main/webapp/source/src/app/data/Application.jsx +++ b/portals/devportal/src/main/webapp/source/src/app/data/Application.jsx @@ -226,6 +226,33 @@ export default class Application extends Resource { }); } + /** * + * Cleanup Consumer Secret and Consumer Key for this application instance + * @param {string} keyType Key type either `Production` or `SandBox` + * @param {object} keyManager keyManager configuration object + * @param {string} keyMappingId Key mapping id of the application + * @returns {promise} Set the generated token into current instance and return tokenObject + * received as Promise object + */ + cleanUpKeys(keyType, keyManager, keyMappingId) { + const requestContent = { + keyType, + keyMappingId, + keyManager, + }; + const payload = { applicationId: this.id, keyMappingId, body: requestContent }; + return this.client.then((client) => client.apis['Application Keys'] + .post_applications__applicationId__oauth_keys__keyMappingId__clean_up(payload)) + .then((response) => { + if (keyType === 'PRODUCTION') { + this.productionKeys = new Map(); + } else { + this.sandboxKeys = new Map(); + } + return response.ok; + }); + } + removeKeys(keyType, keyManager, keyMappingId) { const requestContent = { keyType, From b6c825ab0b926f8f06c22149c6cca8acb8d717fb Mon Sep 17 00:00:00 2001 From: Savindu Dimal Date: Fri, 22 Mar 2024 12:16:26 +0530 Subject: [PATCH 23/26] Add locales file changes --- .../main/webapp/site/public/locales/en.json | 31 ++++++++++++------- .../main/webapp/site/public/locales/fr.json | 17 ++++++++++ .../main/webapp/site/public/locales/en.json | 3 +- .../main/webapp/site/public/locales/en.json | 6 ---- .../webapp/site/public/locales/raw.en.json | 3 -- 5 files changed, 38 insertions(+), 22 deletions(-) diff --git a/portals/admin/src/main/webapp/site/public/locales/en.json b/portals/admin/src/main/webapp/site/public/locales/en.json index 1443760612c..e0f0acda410 100644 --- a/portals/admin/src/main/webapp/site/public/locales/en.json +++ b/portals/admin/src/main/webapp/site/public/locales/en.json @@ -91,6 +91,9 @@ "AdminPagesGatewayEnvironments.AddEditGWEnvironment.form.environment.displayName.empty": "Display Name is Empty", "AdminPagesGatewayEnvironments.AddEditGWEnvironment.form.environment.vhost.duplicate": "VHosts are duplicated", "AdminPagesGatewayEnvironments.AddEditGWEnvironment.form.environment.vhost.empty": "VHost is empty", + "Api.Name": "API Name", + "Api.Provider": "Provider", + "Api.Version": "Version", "Apis.Details.Scopes.CreateScope.roles.help": "Enter a valid role and press `Enter`.", "Apis.Details.Scopes.Roles.Invalid": "A Role is invalid", "Apis.Listing.Listing.apis.search": "Search", @@ -112,6 +115,9 @@ "Apis.Shared.ConfirmDialog.ok": "OK", "Apis.Shared.ConfirmDialog.please.confirm": "Please Confirm", "Apis.Shared.RedirectToLogin.you.will.be.redirected.to": "You will be redirected to {page}", + "Application.Name": "Application Name", + "Application.Owner": "Application Owner", + "Application.organization": "Application Organization", "Applications.Listing.ApplicationTableHead.actions": "Actions", "Applications.Listing.ApplicationTableHead.name": "Name", "Applications.Listing.ApplicationTableHead.owner": "Owner", @@ -147,6 +153,7 @@ "Base.RouteMenuMapping.keymanagers": "Key Managers", "Base.RouteMenuMapping.keymanagers.items.Adding": "Add Key Manager", "Base.RouteMenuMapping.keymanagers.items.Editing": "Edit Key Manager", + "Base.RouteMenuMapping.keymanagers.items.Usage": "Key Manager Usage", "Base.RouteMenuMapping.role.permissions": "Scope Assignments", "Base.RouteMenuMapping.settings": "Settings", "Base.RouteMenuMapping.subscription.creation": "Subscription Creation", @@ -217,8 +224,8 @@ "KeyManager.add.success": "Key Manager added successfully.", "KeyManager.add.success.msg": " - Key Manager added successfully.", "KeyManager.edit.success": " - Key Manager edited successfully.", - "KeyManager.enter.permission.allowed": "Use of this Key-Manager is\n \"Allowed\" for above roles.", - "KeyManager.enter.permission.denied": "Use of this Key-Manager is\n \"Denied\" for above roles.", + "KeyManager.enter.permission.allowed": "Use of this Key-Manager is\n \"Allowed\" for above roles.", + "KeyManager.enter.permission.denied": "Use of this Key-Manager is\n \"Denied\" for above roles.", "KeyManager.permissions": "Permissions", "KeyManagers.AddEditKeyManager.\n form.scopeManagementEndpoint": "Scope Management Endpoint", "KeyManagers.AddEditKeyManager.\n form.displayRevokeEndpoint": "Display Revoke Endpoint", @@ -227,6 +234,8 @@ "KeyManagers.AddEditKeyManager.advanced": "Advanced Configurations", "KeyManagers.AddEditKeyManager.advanced.description": "Advanced options for the Key Manager", "KeyManagers.AddEditKeyManager.api.invocation.method": "API Invocation Method", + "KeyManagers.AddEditKeyManager.api.no.usages": "No API usages for\n this key manager specifically.", + "KeyManagers.AddEditKeyManager.application.no.usages": "No Application usages\n for this key manager specifically.", "KeyManagers.AddEditKeyManager.certificate": "Certificates", "KeyManagers.AddEditKeyManager.certificate.description": "Upload or provide the certificate inline.", "KeyManagers.AddEditKeyManager.claim.mappings.hidden.help": "Expand to add edit claim mappings", @@ -289,8 +298,8 @@ "KeyManagers.AddEditKeyManager.title.newGlobal": "Global Key Manager - Create new", "KeyManagers.AddEditKeyManager.token.handling.options": "Token Handling Options", "KeyManagers.AddEditKeyManager.token.validation.method": "Token Validation Method", + "KeyManagers.AddEditKeyManager.usages": "Key Manager Usage", "KeyManagers.AddEditKeyManager.useIntrospect": "Use introspect", - "KeyManagers.AddEditKeyManager.usages": "Key Manager Usages - ", "KeyManagers.AddEditTokenExchangeIDP.form.Issuer": "Issuer", "KeyManagers.AddEditTokenExchangeIDP.form.issuer.help": "E.g.,: https://localhost:9443/oauth2/token", "KeyManagers.AddEditTokenExchangeIDP.form.tokenEndpoint": "Token Endpoint", @@ -308,6 +317,12 @@ "KeyManagers.ImportConfig.dialog.trigger.import": "Import", "KeyManagers.ImportConfig.form.url": "Url", "KeyManagers.ImportConfig.form.url.help": "Provide Url", + "KeyManagers.ListKeyManagerAPIUsages.error": "Unable to get Key Manager API usage details", + "KeyManagers.ListKeyManagerApplicationUsages.error": "Unable to get Key Manager application usage details", + "KeyManagers.ListKeyManagerUsages.empty.content": "There are no Key Manger usages.", + "KeyManagers.ListKeyManagerUsages.empty.title": "Key Manager Usages", + "KeyManagers.ListKeyManagerUsages.permission.denied.content": "You dont have enough permission to view Key Manager Usages. Please contact the site administrator.", + "KeyManagers.ListKeyManagerUsages.permission.denied.title": "Permission Denied", "KeyManagers.ListKeyManagers.List.title": "Key Managers", "KeyManagers.ListKeyManagers.addButtonProps.triggerButtonText": "Add Key Manager", "KeyManagers.ListKeyManagers.addGlobalKeyManager": "Add Global Key Manager", @@ -792,13 +807,5 @@ "error.list.404": "404 : The page cannot be found.", "error.list.404.description": "The page you are looking for might have been removed, had its name changed or is temporarily unavailable.", "error.list.500": "500 : The page cannot be displayed.", - "error.list.500.description": "The server encountered an internal error or misconfiguration and was unable to complete your request.", - "Api.Name": "API Name", - "Api.Version": "Version", - "Api.Context": "Context", - "Api.Status": "Status", - "Api.SubscriptionCount": "Subscription Count", - "Api.Owner": "Owner", - "KeyManagers.ListKeyManagerUsages.quota.apis.count": "APIs Count", - "KeyManagers.ListKeyManagerUsages.quota.applications.count": "Applications Count" + "error.list.500.description": "The server encountered an internal error or misconfiguration and was unable to complete your request." } diff --git a/portals/admin/src/main/webapp/site/public/locales/fr.json b/portals/admin/src/main/webapp/site/public/locales/fr.json index db815b4f4c2..7eea47cc099 100644 --- a/portals/admin/src/main/webapp/site/public/locales/fr.json +++ b/portals/admin/src/main/webapp/site/public/locales/fr.json @@ -91,6 +91,9 @@ "AdminPagesGatewayEnvironments.AddEditGWEnvironment.form.environment.displayName.empty": "", "AdminPagesGatewayEnvironments.AddEditGWEnvironment.form.environment.vhost.duplicate": "", "AdminPagesGatewayEnvironments.AddEditGWEnvironment.form.environment.vhost.empty": "", + "Api.Name": "", + "Api.Provider": "", + "Api.Version": "", "Apis.Details.Scopes.CreateScope.roles.help": "", "Apis.Details.Scopes.Roles.Invalid": "", "Apis.Listing.Listing.apis.search": "", @@ -112,6 +115,9 @@ "Apis.Shared.ConfirmDialog.ok": "", "Apis.Shared.ConfirmDialog.please.confirm": "", "Apis.Shared.RedirectToLogin.you.will.be.redirected.to": "", + "Application.Name": "", + "Application.Owner": "", + "Application.organization": "", "Applications.Listing.ApplicationTableHead.actions": "", "Applications.Listing.ApplicationTableHead.name": "", "Applications.Listing.ApplicationTableHead.owner": "", @@ -147,6 +153,7 @@ "Base.RouteMenuMapping.keymanagers": "", "Base.RouteMenuMapping.keymanagers.items.Adding": "", "Base.RouteMenuMapping.keymanagers.items.Editing": "", + "Base.RouteMenuMapping.keymanagers.items.Usage": "", "Base.RouteMenuMapping.role.permissions": "", "Base.RouteMenuMapping.settings": "", "Base.RouteMenuMapping.subscription.creation": "", @@ -227,6 +234,8 @@ "KeyManagers.AddEditKeyManager.advanced": "", "KeyManagers.AddEditKeyManager.advanced.description": "", "KeyManagers.AddEditKeyManager.api.invocation.method": "", + "KeyManagers.AddEditKeyManager.api.no.usages": "", + "KeyManagers.AddEditKeyManager.application.no.usages": "", "KeyManagers.AddEditKeyManager.certificate": "", "KeyManagers.AddEditKeyManager.certificate.description": "", "KeyManagers.AddEditKeyManager.claim.mappings.hidden.help": "", @@ -289,6 +298,7 @@ "KeyManagers.AddEditKeyManager.title.newGlobal": "", "KeyManagers.AddEditKeyManager.token.handling.options": "", "KeyManagers.AddEditKeyManager.token.validation.method": "", + "KeyManagers.AddEditKeyManager.usages": "", "KeyManagers.AddEditKeyManager.useIntrospect": "", "KeyManagers.AddEditTokenExchangeIDP.form.Issuer": "", "KeyManagers.AddEditTokenExchangeIDP.form.issuer.help": "", @@ -307,6 +317,12 @@ "KeyManagers.ImportConfig.dialog.trigger.import": "", "KeyManagers.ImportConfig.form.url": "", "KeyManagers.ImportConfig.form.url.help": "", + "KeyManagers.ListKeyManagerAPIUsages.error": "", + "KeyManagers.ListKeyManagerApplicationUsages.error": "", + "KeyManagers.ListKeyManagerUsages.empty.content": "", + "KeyManagers.ListKeyManagerUsages.empty.title": "", + "KeyManagers.ListKeyManagerUsages.permission.denied.content": "", + "KeyManagers.ListKeyManagerUsages.permission.denied.title": "", "KeyManagers.ListKeyManagers.List.title": "", "KeyManagers.ListKeyManagers.addButtonProps.triggerButtonText": "", "KeyManagers.ListKeyManagers.addGlobalKeyManager": "", @@ -316,6 +332,7 @@ "KeyManagers.ListKeyManagers.table.header.label.name": "", "KeyManagers.ListKeyManagers.table.header.label.provider": "", "KeyManagers.ListKeyManagers.table.header.label.tokenType": "", + "KeyManagers.ListKeyManagers.table.header.label.usage": "", "Keymanager.Claim.Action": "", "Keymanager.KeyValidation.Action": "", "Keymanager.KeyValidation.ClaimKey": "", diff --git a/portals/devportal/src/main/webapp/site/public/locales/en.json b/portals/devportal/src/main/webapp/site/public/locales/en.json index 90a7bc44484..14d135935b0 100644 --- a/portals/devportal/src/main/webapp/site/public/locales/en.json +++ b/portals/devportal/src/main/webapp/site/public/locales/en.json @@ -551,7 +551,8 @@ "Shared.AppsAndKeys.TokenExchangeKeyConfiguration.copied": "Copied", "Shared.AppsAndKeys.TokenExchangeKeyConfiguration.copy.to.clipboard": "Copy to clipboard", "Shared.AppsAndKeys.TokenManager.ExchangeToken.key.configuration": "Token Generation", - "Shared.AppsAndKeys.TokenManager.app.creation.disable.warn": "Oauth app creation disabled for {kmName} key manager", + "Shared.AppsAndKeys.TokenManager.app.creation.disable\n .warn": "Oauth app creation disabled for\n {kmName} key manager", + "Shared.AppsAndKeys.TokenManager.app.creation.disable.warn": "Oauth app creation\n disabled for {kmName} key manager", "Shared.AppsAndKeys.TokenManager.cleanup": "Clean up", "Shared.AppsAndKeys.TokenManager.cleanup.text": "Error! You have partially-created keys.\n Please click `Clean Up` button and try again.", "Shared.AppsAndKeys.TokenManager.generate.keys": "Generate Keys", diff --git a/portals/publisher/src/main/webapp/site/public/locales/en.json b/portals/publisher/src/main/webapp/site/public/locales/en.json index 7a4f2740de9..82b73919e6d 100644 --- a/portals/publisher/src/main/webapp/site/public/locales/en.json +++ b/portals/publisher/src/main/webapp/site/public/locales/en.json @@ -1971,12 +1971,6 @@ "value": "Certificate Deleted Successfully" } ], - "Apis.Details.Configuration.components.APISecurity.allOptional": [ - { - "type": 0, - "value": "Please select at least one API security level as 'Mandatory'!" - } - ], "Apis.Details.Configuration.components.APISecurity.api.unsecured": [ { "type": 0, diff --git a/portals/publisher/src/main/webapp/site/public/locales/raw.en.json b/portals/publisher/src/main/webapp/site/public/locales/raw.en.json index 61cecae5498..e800fd19ca5 100644 --- a/portals/publisher/src/main/webapp/site/public/locales/raw.en.json +++ b/portals/publisher/src/main/webapp/site/public/locales/raw.en.json @@ -882,9 +882,6 @@ "Apis.Details.Configuration.components.APISecurity.TranportLevel.certificate.delete.success": { "defaultMessage": "Certificate Deleted Successfully" }, - "Apis.Details.Configuration.components.APISecurity.allOptional": { - "defaultMessage": "Please select at least one API security level as 'Mandatory'!" - }, "Apis.Details.Configuration.components.APISecurity.api.unsecured": { "defaultMessage": "Application level security is not required since API has no secured resources" }, From 5cca1d62623bd6e7c1f5ac6d240031074596c7b8 Mon Sep 17 00:00:00 2001 From: Savindu Dimal Date: Fri, 22 Mar 2024 14:12:32 +0530 Subject: [PATCH 24/26] Remove /settings/key-managers/usages path --- portals/admin/src/main/webapp/site/public/locales/en.json | 1 - portals/admin/src/main/webapp/site/public/locales/fr.json | 1 - .../source/src/app/components/Base/RouteMenuMapping.jsx | 7 ------- 3 files changed, 9 deletions(-) diff --git a/portals/admin/src/main/webapp/site/public/locales/en.json b/portals/admin/src/main/webapp/site/public/locales/en.json index e0f0acda410..9f8b935610a 100644 --- a/portals/admin/src/main/webapp/site/public/locales/en.json +++ b/portals/admin/src/main/webapp/site/public/locales/en.json @@ -153,7 +153,6 @@ "Base.RouteMenuMapping.keymanagers": "Key Managers", "Base.RouteMenuMapping.keymanagers.items.Adding": "Add Key Manager", "Base.RouteMenuMapping.keymanagers.items.Editing": "Edit Key Manager", - "Base.RouteMenuMapping.keymanagers.items.Usage": "Key Manager Usage", "Base.RouteMenuMapping.role.permissions": "Scope Assignments", "Base.RouteMenuMapping.settings": "Settings", "Base.RouteMenuMapping.subscription.creation": "Subscription Creation", diff --git a/portals/admin/src/main/webapp/site/public/locales/fr.json b/portals/admin/src/main/webapp/site/public/locales/fr.json index 7eea47cc099..537f2b25e37 100644 --- a/portals/admin/src/main/webapp/site/public/locales/fr.json +++ b/portals/admin/src/main/webapp/site/public/locales/fr.json @@ -153,7 +153,6 @@ "Base.RouteMenuMapping.keymanagers": "", "Base.RouteMenuMapping.keymanagers.items.Adding": "", "Base.RouteMenuMapping.keymanagers.items.Editing": "", - "Base.RouteMenuMapping.keymanagers.items.Usage": "", "Base.RouteMenuMapping.role.permissions": "", "Base.RouteMenuMapping.settings": "", "Base.RouteMenuMapping.subscription.creation": "", diff --git a/portals/admin/src/main/webapp/source/src/app/components/Base/RouteMenuMapping.jsx b/portals/admin/src/main/webapp/source/src/app/components/Base/RouteMenuMapping.jsx index e0f47e96285..0f49acc8411 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/Base/RouteMenuMapping.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/Base/RouteMenuMapping.jsx @@ -198,13 +198,6 @@ const RouteMenuMapping = (intl) => [ component: KeyManagers, icon: , addEditPageDetails: [ - { - id: intl.formatMessage({ - id: 'Base.RouteMenuMapping.keymanagers.items.Usage', - defaultMessage: 'Key Manager Usage', - }), - path: '/settings/key-managers/usages/(.*?)$', - }, { id: intl.formatMessage({ id: 'Base.RouteMenuMapping.keymanagers.items.Adding', From f9b6e75977ba52e111419fe5d9f51d12c0c7706f Mon Sep 17 00:00:00 2001 From: Savindu Dimal Date: Fri, 22 Mar 2024 15:14:22 +0530 Subject: [PATCH 25/26] Fix global key manager token type view issue --- .../KeyManagers/ListKeyManagers.jsx | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagers.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagers.jsx index f9a9905f4db..487ace24bb5 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagers.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagers.jsx @@ -1,4 +1,3 @@ -/* eslint-disable require-jsdoc */ /* * Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * @@ -108,7 +107,25 @@ function globalAPICall() { return new API() .getGlobalKeyManagersList() .then((result) => { - return result.body.list; + const resultList = result.body.list; + resultList.forEach((item) => { + if (item.tokenType === 'DIRECT') { + // eslint-disable-next-line no-param-reassign + item.tokenType = ; + } else if (item.tokenType === 'BOTH') { + // eslint-disable-next-line no-param-reassign + item.tokenType = ( +
+ + +
+ ); + } else { + // eslint-disable-next-line no-param-reassign + item.tokenType = ; + } + }); + return resultList; }) .catch((error) => { throw error; From 04b8ced43a5ae7fea10a867841e7e6e403c77a94 Mon Sep 17 00:00:00 2001 From: Savindu Dimal Date: Fri, 22 Mar 2024 21:22:41 +0530 Subject: [PATCH 26/26] Add requested changes from review --- .../app/components/KeyManagers/ListKeyManagerUsages.jsx | 9 ++------- portals/admin/src/main/webapp/source/src/app/data/api.js | 4 ++-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx index c62e81b6f59..00e0d9c410b 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/KeyManagers/ListKeyManagerUsages.jsx @@ -1,7 +1,7 @@ /* - * Copyright (c) 2023, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com) All Rights Reserved. * - * WSO2 Inc. licenses this file to you under the Apache License, + * WSO2 LLC. 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 @@ -60,11 +60,6 @@ const styles = { minHeight: 43, backgroundColor: '#f6f6f6', }, - // root: { - // flexGrow: 1, - // minHeight: 'calc(100vh - (100px))', - // backgroundColor: '#eaeff1', - // }, }; const StyledDiv = styled('div')({}); diff --git a/portals/admin/src/main/webapp/source/src/app/data/api.js b/portals/admin/src/main/webapp/source/src/app/data/api.js index 16ff428088c..a4d9684ad91 100644 --- a/portals/admin/src/main/webapp/source/src/app/data/api.js +++ b/portals/admin/src/main/webapp/source/src/app/data/api.js @@ -885,7 +885,7 @@ class API extends Resource { */ getKeyManagerApplicationUsages(keyManagerId) { return this.client.then((client) => { - return client.apis["Key Manager (Individual)"].get_key_managers__keyManagerId__app_usages( + return client.apis['Key Manager (Individual)'].get_key_managers__keyManagerId__app_usages( { keyManagerId: keyManagerId }, this._requestMetaData(), ); @@ -897,7 +897,7 @@ class API extends Resource { */ getKeyManagerApiUsages(keyManagerId) { return this.client.then((client) => { - return client.apis["Key Manager (Individual)"].get_key_managers__keyManagerId__api_usages( + return client.apis['Key Manager (Individual)'].get_key_managers__keyManagerId__api_usages( { keyManagerId: keyManagerId }, this._requestMetaData(), );