diff --git a/frontend/src/component/common/RoleSelect/RoleSelect2.tsx b/frontend/src/component/common/RoleSelect/RoleSelect2.tsx new file mode 100644 index 0000000000..23fad25b48 --- /dev/null +++ b/frontend/src/component/common/RoleSelect/RoleSelect2.tsx @@ -0,0 +1,71 @@ +import { + Autocomplete, + AutocompleteProps, + TextField, + styled, +} from '@mui/material'; +import { useRoles } from 'hooks/api/getters/useRoles/useRoles'; +import { IRole, PredefinedRoleType } from 'interfaces/role'; +import { RoleDescription } from '../RoleDescription/RoleDescription'; +import { ConditionallyRender } from '../ConditionallyRender/ConditionallyRender'; + +const StyledRoleOption = styled('div')(({ theme }) => ({ + display: 'flex', + flexDirection: 'column', + '& > span:last-of-type': { + fontSize: theme.fontSizes.smallerBody, + color: theme.palette.text.secondary, + }, +})); + +interface IRoleSelectProps + extends Partial> { + value: IRole | null; + setValue: (role: IRole | null) => void; + roles: IRole[]; + required?: boolean; +} + +export const RoleSelect = ({ + value, + setValue, + required, + roles, + ...rest +}: IRoleSelectProps) => { + const renderRoleOption = ( + props: React.HTMLAttributes, + option: IRole + ) => ( +
  • + + {option.name} + {option.description} + +
  • + ); + + return ( + <> + setValue(role || null)} + options={roles} + renderOption={renderRoleOption} + getOptionLabel={option => option.name} + renderInput={params => ( + + )} + {...rest} + /> + ( + + )} + /> + + ); +}; diff --git a/frontend/src/component/project/ProjectAccess/ProjectAccessAssign/ProjectAccessAssign.tsx b/frontend/src/component/project/ProjectAccess/ProjectAccessAssign/ProjectAccessAssign.tsx index 6a2f3fa5ea..31cf96f194 100644 --- a/frontend/src/component/project/ProjectAccess/ProjectAccessAssign/ProjectAccessAssign.tsx +++ b/frontend/src/component/project/ProjectAccess/ProjectAccessAssign/ProjectAccessAssign.tsx @@ -35,7 +35,7 @@ import { } from 'utils/testIds'; import { caseInsensitiveSearch } from 'utils/search'; import { IServiceAccount } from 'interfaces/service-account'; -import { RoleSelect } from 'component/common/RoleSelect/RoleSelect'; +import { RoleSelect } from 'component/common/RoleSelect/RoleSelect2'; import { PROJECT_ROLE_TYPE } from '@server/util/constants'; const StyledForm = styled('form')(() => ({ @@ -433,7 +433,7 @@ export const ProjectAccessAssign = ({ setRole(role || null)} />