From d282e2a718a84ae957c612bc5e302b84a301df1e Mon Sep 17 00:00:00 2001 From: SujanSanjula96 Date: Thu, 26 Oct 2023 17:27:18 +0530 Subject: [PATCH 1/3] Fix API authorization issue --- .../features/applications/api/use-scopes-of-api-resources.ts | 5 +++-- .../applications/components/api-authorization/scope-form.tsx | 2 +- .../api-authorization/wizard/authorize-api-resource.tsx | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/console/src/features/applications/api/use-scopes-of-api-resources.ts b/apps/console/src/features/applications/api/use-scopes-of-api-resources.ts index 6c7b8b3a051..8b724bc88a1 100644 --- a/apps/console/src/features/applications/api/use-scopes-of-api-resources.ts +++ b/apps/console/src/features/applications/api/use-scopes-of-api-resources.ts @@ -33,7 +33,8 @@ import { AuthorizedPermissionListItemInterface } from "../models/api-authorizati * @throws `IdentityAppsApiException` */ const useScopesOfAPIResources = ( - apiResourceId: string + apiResourceId: string, + shouldFetch?: boolean ): RequestResultInterface => { const requestConfig: AxiosRequestConfig = { @@ -45,7 +46,7 @@ const useScopesOfAPIResources = (requestConfig); + const { data, error, isValidating, mutate } = useRequest(shouldFetch ? requestConfig: null); return { data, diff --git a/apps/console/src/features/applications/components/api-authorization/scope-form.tsx b/apps/console/src/features/applications/components/api-authorization/scope-form.tsx index 7949eb338ce..17b18258a96 100644 --- a/apps/console/src/features/applications/components/api-authorization/scope-form.tsx +++ b/apps/console/src/features/applications/components/api-authorization/scope-form.tsx @@ -99,7 +99,7 @@ export const ScopeForm: FunctionComponent = ( data: currentAPIResourceScopeListData, isLoading: isCurrentAPIResourceScopeListDataLoading, error: currentAPIResourceScopeListFetchError - } = useScopesOfAPIResources(subscribedAPIResource?.id); + } = useScopesOfAPIResources(subscribedAPIResource?.id, subscribedAPIResource?.id != null); /** * The following useEffect is used to handle if any error occurs while fetching API resource scopes. diff --git a/apps/console/src/features/applications/components/api-authorization/wizard/authorize-api-resource.tsx b/apps/console/src/features/applications/components/api-authorization/wizard/authorize-api-resource.tsx index a5e6e8a25e7..1b36cb148c4 100644 --- a/apps/console/src/features/applications/components/api-authorization/wizard/authorize-api-resource.tsx +++ b/apps/console/src/features/applications/components/api-authorization/wizard/authorize-api-resource.tsx @@ -116,7 +116,7 @@ export const AuthorizeAPIResource: FunctionComponent Date: Thu, 26 Oct 2023 17:31:43 +0530 Subject: [PATCH 2/3] =?UTF-8?q?Add=20changeset=20=F0=9F=A6=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/happy-carpets-wonder.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/happy-carpets-wonder.md diff --git a/.changeset/happy-carpets-wonder.md b/.changeset/happy-carpets-wonder.md new file mode 100644 index 00000000000..fd7e008fc9d --- /dev/null +++ b/.changeset/happy-carpets-wonder.md @@ -0,0 +1,5 @@ +--- +"@wso2is/console": patch +--- + +Fix API Authorization issue From 8998fa5e7c206333ac11815fc90704f20d6cd06e Mon Sep 17 00:00:00 2001 From: SujanSanjula96 Date: Thu, 26 Oct 2023 17:37:59 +0530 Subject: [PATCH 3/3] Fix review comments --- .../features/applications/api/use-scopes-of-api-resources.ts | 5 ++--- .../applications/components/api-authorization/scope-form.tsx | 2 +- .../api-authorization/wizard/authorize-api-resource.tsx | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/console/src/features/applications/api/use-scopes-of-api-resources.ts b/apps/console/src/features/applications/api/use-scopes-of-api-resources.ts index 8b724bc88a1..31b7edbea16 100644 --- a/apps/console/src/features/applications/api/use-scopes-of-api-resources.ts +++ b/apps/console/src/features/applications/api/use-scopes-of-api-resources.ts @@ -33,8 +33,7 @@ import { AuthorizedPermissionListItemInterface } from "../models/api-authorizati * @throws `IdentityAppsApiException` */ const useScopesOfAPIResources = ( - apiResourceId: string, - shouldFetch?: boolean + apiResourceId: string ): RequestResultInterface => { const requestConfig: AxiosRequestConfig = { @@ -46,7 +45,7 @@ const useScopesOfAPIResources = (shouldFetch ? requestConfig: null); + const { data, error, isValidating, mutate } = useRequest(apiResourceId ? requestConfig: null); return { data, diff --git a/apps/console/src/features/applications/components/api-authorization/scope-form.tsx b/apps/console/src/features/applications/components/api-authorization/scope-form.tsx index 17b18258a96..7949eb338ce 100644 --- a/apps/console/src/features/applications/components/api-authorization/scope-form.tsx +++ b/apps/console/src/features/applications/components/api-authorization/scope-form.tsx @@ -99,7 +99,7 @@ export const ScopeForm: FunctionComponent = ( data: currentAPIResourceScopeListData, isLoading: isCurrentAPIResourceScopeListDataLoading, error: currentAPIResourceScopeListFetchError - } = useScopesOfAPIResources(subscribedAPIResource?.id, subscribedAPIResource?.id != null); + } = useScopesOfAPIResources(subscribedAPIResource?.id); /** * The following useEffect is used to handle if any error occurs while fetching API resource scopes. diff --git a/apps/console/src/features/applications/components/api-authorization/wizard/authorize-api-resource.tsx b/apps/console/src/features/applications/components/api-authorization/wizard/authorize-api-resource.tsx index 1b36cb148c4..a5e6e8a25e7 100644 --- a/apps/console/src/features/applications/components/api-authorization/wizard/authorize-api-resource.tsx +++ b/apps/console/src/features/applications/components/api-authorization/wizard/authorize-api-resource.tsx @@ -116,7 +116,7 @@ export const AuthorizeAPIResource: FunctionComponent