From d57e2af403f1f90d44c7ec965ef75f6a20ded518 Mon Sep 17 00:00:00 2001 From: shnrndk Date: Tue, 28 Nov 2023 11:25:07 +0530 Subject: [PATCH] User validation and Api Version Column added --- .../APISettings/ApisTableContent.jsx | 1 + .../components/APISettings/ApisTableHead.jsx | 10 ++++ .../app/components/APISettings/EditApi.jsx | 46 ++++--------------- 3 files changed, 20 insertions(+), 37 deletions(-) diff --git a/portals/admin/src/main/webapp/source/src/app/components/APISettings/ApisTableContent.jsx b/portals/admin/src/main/webapp/source/src/app/components/APISettings/ApisTableContent.jsx index 5ef97e46308..909aff1bfbd 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/APISettings/ApisTableContent.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/APISettings/ApisTableContent.jsx @@ -141,6 +141,7 @@ class ApisTableContent extends Component { {app.name} + {app.version} {app.provider} { />), sorting: true, }, + { + id: 'version', + numeric: false, + disablePadding: true, + label: (), + sorting: true, + }, { id: 'provider', numeric: false, diff --git a/portals/admin/src/main/webapp/source/src/app/components/APISettings/EditApi.jsx b/portals/admin/src/main/webapp/source/src/app/components/APISettings/EditApi.jsx index 183b96427c8..05edb617c7a 100644 --- a/portals/admin/src/main/webapp/source/src/app/components/APISettings/EditApi.jsx +++ b/portals/admin/src/main/webapp/source/src/app/components/APISettings/EditApi.jsx @@ -75,40 +75,6 @@ function EditApi(props) { dispatch({ field: e.target.name, value: e.target.value }); }; - const validateProvider = () => { - let validationError = 'Something went wrong when validating user'; - - const apisWithSameName = apiList.filter( - (app) => app.name === name && app.provider === provider, - ); - - const promiseValidation = new Promise((resolve, reject) => { - if (apisWithSameName.length > 0) { - validationError = `${provider} already has an api with name: ${name}`; - reject(validationError); - } - const basicScope = 'apim:subscribe'; - restApi.getUserScope(provider, basicScope) - .then(() => { - // This api returns 200 when only the $provider has the $basicScope. - resolve(); - }).catch((error) => { - const { response } = error; - // This api returns 404 when the $provider is not found. - // error codes: 901502, 901500 for user not found and scope not found - if (response?.body?.code === 901502 || response?.body?.code === 901500) { - validationError = `${provider} is not a valid Subscriber`; - } - }).finally(() => { - if (validationError) { - reject(validationError); - } - }); - }); - - return promiseValidation; - }; - const formSaveCallback = () => { return restApi.updateApiProvider(dataRow.id, provider) .then(() => { @@ -120,12 +86,18 @@ function EditApi(props) { ); }) .catch((error) => { + let validationError = 'Something went wrong when validating the user'; const { response } = error; + // This api returns 404 when the $provider is not found. + // error codes: 901502, 901500 for user not found and scope not found + if (response?.body?.code === 901502 || response?.body?.code === 901500) { + validationError = `${provider} is not a valid User`; + } if (response?.body?.code === 500) { - const notValidSubscriber = 'Error while updating providership to ' + provider; - throw notValidSubscriber; + const notValidUser = 'Error while updating the provider name to ' + provider; + throw notValidUser; } else { - const updateError = 'Something went wrong when updating provider'; + const updateError = validationError; throw updateError; } })