From a620ab4f13c7a5ae31474b1e43ed7497493ad2f8 Mon Sep 17 00:00:00 2001 From: Yasasr1 Date: Wed, 8 May 2024 13:14:10 +0530 Subject: [PATCH 1/3] Fix error during user fetch. --- .../admin.groups.v1/components/edit-group/edit-group.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/features/admin.groups.v1/components/edit-group/edit-group.tsx b/features/admin.groups.v1/components/edit-group/edit-group.tsx index 275692dc796..7e4fd92b8ff 100644 --- a/features/admin.groups.v1/components/edit-group/edit-group.tsx +++ b/features/admin.groups.v1/components/edit-group/edit-group.tsx @@ -16,7 +16,6 @@ * under the License. */ -import useUIConfig from "../../../admin.core.v1/hooks/use-ui-configs"; import { hasRequiredScopes, isFeatureEnabled } from "@wso2is/core/helpers"; import { AlertLevels, FeatureAccessConfigInterface, SBACInterface } from "@wso2is/core/models"; import { addAlert } from "@wso2is/core/store"; @@ -32,6 +31,7 @@ import { BasicGroupDetails } from "./edit-group-basic"; import { EditGroupRoles } from "./edit-group-roles"; import { GroupRolesV1List } from "./edit-group-roles-v1"; import { GroupUsersList } from "./edit-group-users"; +import useUIConfig from "../../../admin.core.v1/hooks/use-ui-configs"; import { FeatureConfigInterface } from "../../../admin.core.v1/models"; import { AppState } from "../../../admin.core.v1/store"; import { getUsersList } from "../../../admin.users.v1/api"; @@ -139,8 +139,10 @@ export const EditGroup: FunctionComponent = (props: EditGroupPro getUsersList(null, null, null, null, userstore) .then((response: UserListInterface) => { - setUsersList(response.Resources); - setSelectedUsersList(filterUsersList([ ...response.Resources ])); + if (response.Resources?.length > 0) { + setUsersList(response.Resources); + setSelectedUsersList(filterUsersList([ ...response.Resources ])); + } }) .catch((error: AxiosError) => { if (error?.response?.data?.description) { From 1161a8b83249f2a4b2074fa6e9f9462556184f75 Mon Sep 17 00:00:00 2001 From: Yasasr1 Date: Wed, 8 May 2024 13:18:07 +0530 Subject: [PATCH 2/3] Add changeset --- .changeset/angry-falcons-wait.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/angry-falcons-wait.md diff --git a/.changeset/angry-falcons-wait.md b/.changeset/angry-falcons-wait.md new file mode 100644 index 00000000000..c9d30a106b5 --- /dev/null +++ b/.changeset/angry-falcons-wait.md @@ -0,0 +1,5 @@ +--- +"@wso2is/features": patch +--- + +Fix error during user fetch From 832c26bb7175705170d2c817c8f49f21e2d91280 Mon Sep 17 00:00:00 2001 From: Yasasr1 Date: Wed, 8 May 2024 15:05:43 +0530 Subject: [PATCH 3/3] Address review comments --- .../admin.groups.v1/components/edit-group/edit-group.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/features/admin.groups.v1/components/edit-group/edit-group.tsx b/features/admin.groups.v1/components/edit-group/edit-group.tsx index 7e4fd92b8ff..efa376051de 100644 --- a/features/admin.groups.v1/components/edit-group/edit-group.tsx +++ b/features/admin.groups.v1/components/edit-group/edit-group.tsx @@ -139,10 +139,8 @@ export const EditGroup: FunctionComponent = (props: EditGroupPro getUsersList(null, null, null, null, userstore) .then((response: UserListInterface) => { - if (response.Resources?.length > 0) { - setUsersList(response.Resources); - setSelectedUsersList(filterUsersList([ ...response.Resources ])); - } + setUsersList(response.Resources); + setSelectedUsersList(filterUsersList(response.Resources)); }) .catch((error: AxiosError) => { if (error?.response?.data?.description) { @@ -178,7 +176,7 @@ export const EditGroup: FunctionComponent = (props: EditGroupPro */ const filterUsersList = (usersToFilter: UserBasicInterface[]): UserBasicInterface[] => { - if (!group?.members || !Array.isArray(group.members) || group.members.length < 1) { + if (!group?.members || !Array.isArray(group.members) || group.members.length < 1 || !usersToFilter) { return; }