Show "CUSTOM" on permission roles instead of empty entry (#1597)

This commit is contained in:
Eduard Heimbuch
2021-03-23 08:47:29 +01:00
committed by GitHub
parent 7b6dfb3880
commit e132aab7c4
4 changed files with 10 additions and 7 deletions

View File

@@ -31,11 +31,7 @@ type Props = {
label?: string;
helpText?: string;
loading?: boolean;
};
const emptyOption = {
label: "",
value: ""
emptyLabel?: string;
};
const createSelectOptions = (roles: string[]) => {
@@ -47,11 +43,13 @@ const createSelectOptions = (roles: string[]) => {
});
};
const RoleSelector: FC<Props> = ({ availableRoles, role, handleRoleChange, loading, label, helpText }) => {
const RoleSelector: FC<Props> = ({ availableRoles, role, handleRoleChange, loading, label, helpText, emptyLabel }) => {
if (!availableRoles) {
return null;
}
const options = role ? createSelectOptions(availableRoles) : [emptyOption, ...createSelectOptions(availableRoles)];
const options = role
? createSelectOptions(availableRoles)
: [{ label: emptyLabel || "", value: "" }, ...createSelectOptions(availableRoles)];
return (
<Select