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

@@ -0,0 +1,2 @@
- type: changed
description: Show "CUSTOM" name instead empty entry for permission roles ([#1597](https://github.com/scm-manager/scm-manager/pull/1597))

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

View File

@@ -164,6 +164,7 @@ const CreatePermissionForm: FC<Props> = ({
selectedVerbs={selectedVerbs || []}
onClose={() => setShowAdvancedDialog(false)}
onSubmit={submitAdvancedPermissionsDialog}
readOnly={!create}
/>
) : null}
<ErrorNotification error={error} />
@@ -212,6 +213,7 @@ const CreatePermissionForm: FC<Props> = ({
helpText={t("permission.help.roleHelpText")}
handleRoleChange={handleRoleChange}
role={permission.role || ""}
emptyLabel={t("permission.custom")}
/>
</div>
<div className="column">

View File

@@ -111,6 +111,7 @@ const SinglePermission: FC<Props> = ({
availableRoles={availableRoleNames}
role={permission.role || ""}
loading={isLoading}
emptyLabel={t("permission.custom")}
/>
</td>
)}