diff --git a/.changeset/purple-icons-deny.md b/.changeset/purple-icons-deny.md new file mode 100644 index 00000000000..f1318a2d75c --- /dev/null +++ b/.changeset/purple-icons-deny.md @@ -0,0 +1,5 @@ +--- +"@wso2is/console": patch +--- + +role permission, api resource not displaying bug fixed diff --git a/apps/console/src/features/roles/components/edit-role/edit-role-basic.tsx b/apps/console/src/features/roles/components/edit-role/edit-role-basic.tsx index 839fd55b558..2655f732762 100644 --- a/apps/console/src/features/roles/components/edit-role/edit-role-basic.tsx +++ b/apps/console/src/features/roles/components/edit-role/edit-role-basic.tsx @@ -62,7 +62,7 @@ export const BasicRoleDetails: FunctionComponent = (props: Basic isLoading: isRolesListLoading, error: rolesListError, isValidating: isRolesListValidating - } = useRolesList( undefined, undefined, roleNameSearchQuery); + } = useRolesList(undefined, undefined, roleNameSearchQuery); /** * Dispatches the alert object to the redux store. diff --git a/apps/console/src/features/roles/components/edit-role/edit-role-permission.tsx b/apps/console/src/features/roles/components/edit-role/edit-role-permission.tsx index 51cf862408b..7e927dbd567 100644 --- a/apps/console/src/features/roles/components/edit-role/edit-role-permission.tsx +++ b/apps/console/src/features/roles/components/edit-role/edit-role-permission.tsx @@ -34,6 +34,7 @@ import { addAlert } from "@wso2is/core/store"; import { Field, Form } from "@wso2is/form"; import { EmphasizedSegment, Heading } from "@wso2is/react-components"; import debounce, { DebouncedFunc } from "lodash-es/debounce"; +import isEmpty from "lodash-es/isEmpty"; import React, { FunctionComponent, ReactElement, @@ -303,10 +304,13 @@ export const UpdatedRolePermissionDetails: FunctionComponent void> = useCallback(debounce((query: string) => { - setAPIResourceSearchQuery(`name co ${query}`); + setAPIResourceSearchQuery( + !isEmpty(query) + ? `name co ${query}` + : null + ); mutateAPIResourcesListFetchRequest().finally(() => { setAPIResourcesSearching(false); - setAPIResourceSearchQuery(undefined); }); }, RoleConstants.DEBOUNCE_TIMEOUT), []); @@ -314,7 +318,9 @@ export const UpdatedRolePermissionDetails: FunctionComponent, data: DropdownProps): void => { + event.preventDefault(); setSelectedAPIResourceId(data.value.toString()); + setAPIResourceSearchQuery(undefined); }; /** @@ -366,12 +372,14 @@ export const UpdatedRolePermissionDetails: FunctionComponent = } }); } - + setAPIResourcesListOptions(options); }, [ authorizedAPIListForApplication, apiResourcesList, selectedAPIResources ]); @@ -199,10 +200,13 @@ export const RolePermissionsList: FunctionComponent = */ const searchAPIResources: DebouncedFunc<(query: string) => void> = useCallback(debounce((query: string) => { - setAPIResourceSearchQuery(`name co ${query}`); + setAPIResourceSearchQuery( + !isEmpty(query) + ? `name co ${query}` + : null + ); mutateAPIResourcesListFetchRequest().finally(() => { setAPIResourcesSearching(false); - setAPIResourceSearchQuery(undefined); }); }, RoleConstants.DEBOUNCE_TIMEOUT), []); @@ -224,6 +228,7 @@ export const RolePermissionsList: FunctionComponent = * else add the API resource to the selected API resources list from the authorized API list. */ const onAPIResourceSelected = (event: SyntheticEvent, data: DropdownProps): void => { + event.preventDefault(); if(roleAudience === RoleAudienceTypes.ORGANIZATION) { setSelectedAPIResourceId(data.value.toString()); } else { @@ -240,6 +245,7 @@ export const RolePermissionsList: FunctionComponent = ...selectedAPIResources ]); } + setAPIResourceSearchQuery(undefined); }; /** @@ -304,12 +310,14 @@ export const RolePermissionsList: FunctionComponent = onSubmit={ undefined } > = (props: CreateRoleP const roleAudience: string = stepperState[ CreateRoleStepsFormTypes.BASIC_DETAILS ].roleAudience; const organizationId: string = store.getState().organization.organization.id; + const selectedPermissionsList: CreateRolePermissionInterface[] = selectedPermissions?.flatMap( + (permission: SelectedPermissionsInterface) => ( + permission?.scopes?.map((scope: ScopeInterface) => ({ value: scope?.name })) || [] + )) || []; const roleData: CreateRoleInterface = { audience: roleAudience === RoleAudienceTypes.ORGANIZATION @@ -100,7 +106,7 @@ const CreateRoleWizard: FunctionComponent = (props: CreateRoleP value: stepperState[ CreateRoleStepsFormTypes.BASIC_DETAILS ].assignedApplicationId }, displayName: stepperState[ CreateRoleStepsFormTypes.BASIC_DETAILS ].roleName, - permissions: [], + permissions: selectedPermissionsList, schemas: [] };