Skip to content

Commit

Permalink
role permission, api resource not displaying bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Achintha Isuru committed Oct 27, 2023
1 parent c1f15e8 commit 481348a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const BasicRoleDetails: FunctionComponent<BasicRoleProps> = (props: Basic
isLoading: isRolesListLoading,
error: rolesListError,
isValidating: isRolesListValidating
} = useRolesList( undefined, undefined, roleNameSearchQuery);
} = useRolesList(undefined, undefined, roleNameSearchQuery);

/**
* Dispatches the alert object to the redux store.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,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, SyntheticEvent, useCallback, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { useDispatch } from "react-redux";
Expand Down Expand Up @@ -287,18 +288,23 @@ export const UpdatedRolePermissionDetails: FunctionComponent<RolePermissionDetai
*/
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), []);

/**
* Handles the selection of an API resource.
*/
const onAPIResourceSelected = (event: SyntheticEvent<HTMLElement>, data: DropdownProps): void => {
event.preventDefault();
setSelectedAPIResourceId(data.value.toString());
setAPIResourceSearchQuery(undefined);
};

/**
Expand Down Expand Up @@ -359,12 +365,14 @@ export const UpdatedRolePermissionDetails: FunctionComponent<RolePermissionDetai
onSubmit={ undefined }
>
<Field.Dropdown
search
selection
selectOnNavigation={ false }
ariaLabel="assignedApplication"
name="assignedApplication"
label={ t("console:manage.features.roles.addRoleWizard.forms.rolePermission." +
"apiResource.label") }
options={ apiResourcesListOptions }
search
data-componentid={ `${componentId}-typography-font-family-dropdown` }
placeholder={ t("console:manage.features.roles.addRoleWizard.forms.rolePermission." +
"apiResource.placeholder") }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
* under the License.
*/

import { Autocomplete, AutocompleteRenderGetTagProps, AutocompleteRenderInputParams } from "@mui/material";
import Autocomplete, {
AutocompleteRenderGetTagProps,
AutocompleteRenderInputParams
} from "@oxygen-ui/react/Autocomplete";
import TextField from "@oxygen-ui/react/TextField";
import { IdentifiableComponentInterface } from "@wso2is/core/models";
import React, { FunctionComponent, HTMLAttributes, ReactElement, SyntheticEvent } from "react";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { addAlert } from "@wso2is/core/store";
import { Field, Form } from "@wso2is/form";
import { EmphasizedSegment } from "@wso2is/react-components";
import debounce, { DebouncedFunc } from "lodash-es/debounce";
import isEmpty from "lodash-es/isEmpty";
import React, { FunctionComponent, ReactElement, SyntheticEvent, useCallback, useEffect, useState } from "react";
import { Trans, useTranslation } from "react-i18next";
import { useDispatch } from "react-redux";
Expand Down Expand Up @@ -173,7 +174,7 @@ export const RolePermissionsList: FunctionComponent<RolePermissionsListProp> =
}
});
}

setAPIResourcesListOptions(options);
}, [ authorizedAPIListForApplication, apiResourcesList, selectedAPIResources ]);

Expand All @@ -199,10 +200,13 @@ export const RolePermissionsList: FunctionComponent<RolePermissionsListProp> =
*/
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), []);

Expand All @@ -224,6 +228,7 @@ export const RolePermissionsList: FunctionComponent<RolePermissionsListProp> =
* else add the API resource to the selected API resources list from the authorized API list.
*/
const onAPIResourceSelected = (event: SyntheticEvent<HTMLElement>, data: DropdownProps): void => {
event.preventDefault();
if(roleAudience === RoleAudienceTypes.ORGANIZATION) {
setSelectedAPIResourceId(data.value.toString());
} else {
Expand All @@ -240,6 +245,7 @@ export const RolePermissionsList: FunctionComponent<RolePermissionsListProp> =
...selectedAPIResources
]);
}
setAPIResourceSearchQuery(undefined);
};

/**
Expand Down Expand Up @@ -304,12 +310,14 @@ export const RolePermissionsList: FunctionComponent<RolePermissionsListProp> =
onSubmit={ undefined }
>
<Field.Dropdown
search
selection
selectOnNavigation={ false }
ariaLabel="assignedApplication"
name="assignedApplication"
label={ t("console:manage.features.roles.addRoleWizard.forms.rolePermission." +
"apiResource.label") }
options={ apiResourcesListOptions }
search
data-componentid={ `${componentId}-typography-font-family-dropdown` }
placeholder={ t("console:manage.features.roles.addRoleWizard.forms.rolePermission." +
"apiResource.placeholder") }
Expand Down

0 comments on commit 481348a

Please sign in to comment.