noBasicRole feature: Change RolePickerInput to not show the "None" role (#76300)

Change RolePickerInput to only show the basic role when it's not the None role (no basic role feature)
This commit is contained in:
Aaron Godin 2023-10-11 09:42:09 -05:00 committed by GitHub
parent 2049ffc718
commit c2cbb0a924
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -49,18 +49,22 @@ export const RolePickerInput = ({
onQueryChange(query);
};
const numberOfRoles = appliedRoles.length;
const showBasicRoleOnLabel = showBasicRole && basicRole !== 'None';
return !isFocused ? (
// TODO: fix keyboard a11y
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
<div className={cx(styles.wrapper, styles.selectedRoles)} onMouseDown={onOpen}>
{showBasicRole && <ValueContainer>{basicRole}</ValueContainer>}
<RolesLabel appliedRoles={appliedRoles} numberOfRoles={numberOfRoles} showBuiltInRole={showBasicRole} />
{showBasicRoleOnLabel && <ValueContainer>{basicRole}</ValueContainer>}
<RolesLabel
appliedRoles={appliedRoles}
numberOfRoles={appliedRoles.length}
showBuiltInRole={showBasicRoleOnLabel}
/>
</div>
) : (
<div className={styles.wrapper}>
{showBasicRole && <ValueContainer>{basicRole}</ValueContainer>}
{showBasicRoleOnLabel && <ValueContainer>{basicRole}</ValueContainer>}
{appliedRoles.map((role) => (
<ValueContainer key={role.uid}>{role.displayName || role.name}</ValueContainer>
))}