mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-03 22:23:16 +00:00
fix(ui): fix search not working in roles input in user profile page (#13897)
* fix search in roles input in user profile page * minor change * changes as per comments * minor changes
This commit is contained in:
parent
2577490700
commit
2adce103f4
@ -257,7 +257,9 @@ describe('Prerequisite for data steward role tests', () => {
|
|||||||
|
|
||||||
cy.get('[data-testid="edit-roles-button"]').click();
|
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();
|
cy.get(`[title=${role.name}]`).click();
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ import { EntityReference } from '../../generated/entity/type';
|
|||||||
import { AuthProvider } from '../../generated/settings/settings';
|
import { AuthProvider } from '../../generated/settings/settings';
|
||||||
import { checkEmailInUse, generateRandomPwd } from '../../rest/auth-API';
|
import { checkEmailInUse, generateRandomPwd } from '../../rest/auth-API';
|
||||||
import { getJWTTokenExpiryOptions } from '../../utils/BotsUtils';
|
import { getJWTTokenExpiryOptions } from '../../utils/BotsUtils';
|
||||||
|
import { handleSearchFilterOption } from '../../utils/CommonUtils';
|
||||||
import { getEntityName } from '../../utils/EntityUtils';
|
import { getEntityName } from '../../utils/EntityUtils';
|
||||||
import SVGIcons, { Icons } from '../../utils/SvgUtils';
|
import SVGIcons, { Icons } from '../../utils/SvgUtils';
|
||||||
import { showErrorToast } from '../../utils/ToastUtils';
|
import { showErrorToast } from '../../utils/ToastUtils';
|
||||||
@ -346,9 +347,7 @@ const CreateUser = ({
|
|||||||
<Select
|
<Select
|
||||||
data-testid="roles-dropdown"
|
data-testid="roles-dropdown"
|
||||||
disabled={isEmpty(roles)}
|
disabled={isEmpty(roles)}
|
||||||
filterOption={(input, option) =>
|
filterOption={handleSearchFilterOption}
|
||||||
(option?.label ?? '').includes(input)
|
|
||||||
}
|
|
||||||
mode="multiple"
|
mode="multiple"
|
||||||
options={roleOptions}
|
options={roleOptions}
|
||||||
placeholder={t('label.please-select-entity', {
|
placeholder={t('label.please-select-entity', {
|
||||||
|
@ -38,6 +38,7 @@ import {
|
|||||||
ZOOM_SLIDER_STEP,
|
ZOOM_SLIDER_STEP,
|
||||||
ZOOM_TRANSITION_DURATION,
|
ZOOM_TRANSITION_DURATION,
|
||||||
} from '../../../constants/Lineage.constants';
|
} from '../../../constants/Lineage.constants';
|
||||||
|
import { handleSearchFilterOption } from '../../../utils/CommonUtils';
|
||||||
import { getLoadingStatusValue } from '../../../utils/EntityLineageUtils';
|
import { getLoadingStatusValue } from '../../../utils/EntityLineageUtils';
|
||||||
import { getEntityName } from '../../../utils/EntityUtils';
|
import { getEntityName } from '../../../utils/EntityUtils';
|
||||||
import SVGIcons, { Icons } from '../../../utils/SvgUtils';
|
import SVGIcons, { Icons } from '../../../utils/SvgUtils';
|
||||||
@ -100,16 +101,6 @@ const CustomControls: FC<ControlProps> = ({
|
|||||||
fitView?.(fitViewParams);
|
fitView?.(fitViewParams);
|
||||||
}, [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 onRangeChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
const zoomValue = parseFloat(event.target.value);
|
const zoomValue = parseFloat(event.target.value);
|
||||||
onZoomHandler(zoomValue);
|
onZoomHandler(zoomValue);
|
||||||
|
@ -29,6 +29,7 @@ import {
|
|||||||
import { Role } from '../../../../generated/entity/teams/role';
|
import { Role } from '../../../../generated/entity/teams/role';
|
||||||
import { useAuth } from '../../../../hooks/authHooks';
|
import { useAuth } from '../../../../hooks/authHooks';
|
||||||
import { getRoles } from '../../../../rest/rolesAPIV1';
|
import { getRoles } from '../../../../rest/rolesAPIV1';
|
||||||
|
import { handleSearchFilterOption } from '../../../../utils/CommonUtils';
|
||||||
import { getEntityName } from '../../../../utils/EntityUtils';
|
import { getEntityName } from '../../../../utils/EntityUtils';
|
||||||
import { showErrorToast } from '../../../../utils/ToastUtils';
|
import { showErrorToast } from '../../../../utils/ToastUtils';
|
||||||
import { UserProfileRolesProps } from './UserProfileRoles.interface';
|
import { UserProfileRolesProps } from './UserProfileRoles.interface';
|
||||||
@ -172,6 +173,8 @@ const UserProfileRoles = ({
|
|||||||
showSearch
|
showSearch
|
||||||
aria-label="Select roles"
|
aria-label="Select roles"
|
||||||
className="w-full"
|
className="w-full"
|
||||||
|
data-testid="select-user-roles"
|
||||||
|
filterOption={handleSearchFilterOption}
|
||||||
id="select-role"
|
id="select-role"
|
||||||
loading={isRolesLoading}
|
loading={isRolesLoading}
|
||||||
maxTagCount={4}
|
maxTagCount={4}
|
||||||
|
@ -25,6 +25,7 @@ import {
|
|||||||
isNull,
|
isNull,
|
||||||
isString,
|
isString,
|
||||||
isUndefined,
|
isUndefined,
|
||||||
|
toLower,
|
||||||
toNumber,
|
toNumber,
|
||||||
} from 'lodash';
|
} from 'lodash';
|
||||||
import {
|
import {
|
||||||
@ -871,3 +872,17 @@ export const getUniqueArray = (count: number) =>
|
|||||||
[...Array(count)].map((_, index) => ({
|
[...Array(count)].map((_, index) => ({
|
||||||
key: `key${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;
|
||||||
|
}
|
||||||
|
) => toLower(option?.label).includes(toLower(searchValue));
|
||||||
|
// Check label while searching anything and filter that options out if found matching
|
||||||
|
Loading…
x
Reference in New Issue
Block a user