Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): fix search not working in roles input in user profile page #13897

Merged
merged 4 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,9 @@ describe('Prerequisite for data steward role tests', () => {

cy.get('[data-testid="edit-roles-button"]').click();

cy.get('[data-testid="inline-edit-container"] #select-role').click();
cy.get('[data-testid="inline-edit-container"] #select-role')
.click()
.type(role.name);

cy.get(`[title=${role.name}]`).click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { EntityReference } from '../../generated/entity/type';
import { AuthProvider } from '../../generated/settings/settings';
import { checkEmailInUse, generateRandomPwd } from '../../rest/auth-API';
import { getJWTTokenExpiryOptions } from '../../utils/BotsUtils';
import { handleSearchFilterOption } from '../../utils/CommonUtils';
import { getEntityName } from '../../utils/EntityUtils';
import SVGIcons, { Icons } from '../../utils/SvgUtils';
import { showErrorToast } from '../../utils/ToastUtils';
Expand Down Expand Up @@ -346,9 +347,7 @@ const CreateUser = ({
<Select
data-testid="roles-dropdown"
disabled={isEmpty(roles)}
filterOption={(input, option) =>
(option?.label ?? '').includes(input)
}
filterOption={handleSearchFilterOption}
mode="multiple"
options={roleOptions}
placeholder={t('label.please-select-entity', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
ZOOM_SLIDER_STEP,
ZOOM_TRANSITION_DURATION,
} from '../../../constants/Lineage.constants';
import { handleSearchFilterOption } from '../../../utils/CommonUtils';
import { getLoadingStatusValue } from '../../../utils/EntityLineageUtils';
import { getEntityName } from '../../../utils/EntityUtils';
import SVGIcons, { Icons } from '../../../utils/SvgUtils';
Expand Down Expand Up @@ -100,16 +101,6 @@ const CustomControls: FC<ControlProps> = ({
fitView?.(fitViewParams);
}, [fitView, fitViewParams]);

const handleSearchFilterOption = (
input: string,
option?: {
label: string;
value: string;
}
) => {
return (option?.label || '').toLowerCase().includes(input.toLowerCase());
};

const onRangeChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const zoomValue = parseFloat(event.target.value);
onZoomHandler(zoomValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
import { Role } from '../../../../generated/entity/teams/role';
import { useAuth } from '../../../../hooks/authHooks';
import { getRoles } from '../../../../rest/rolesAPIV1';
import { handleSearchFilterOption } from '../../../../utils/CommonUtils';
import { getEntityName } from '../../../../utils/EntityUtils';
import { showErrorToast } from '../../../../utils/ToastUtils';
import { UserProfileRolesProps } from './UserProfileRoles.interface';
Expand Down Expand Up @@ -172,6 +173,8 @@ const UserProfileRoles = ({
showSearch
aria-label="Select roles"
className="w-full"
data-testid="select-user-roles"
filterOption={handleSearchFilterOption}
id="select-role"
loading={isRolesLoading}
maxTagCount={4}
Expand Down
14 changes: 14 additions & 0 deletions openmetadata-ui/src/main/resources/ui/src/utils/CommonUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -868,3 +868,17 @@ export const getUniqueArray = (count: number) =>
[...Array(count)].map((_, index) => ({
key: `key${index}`,
}));

/**
* @param searchValue search input
* @param option select options list
* @returns boolean
*/
export const handleSearchFilterOption = (
searchValue: string,
option?: {
label: string;
value: string;
}
) => (option?.label ?? '').toLowerCase().includes(searchValue.toLowerCase());
// Check label while searching anything and filter that options out if found matching
Loading