feat: make authentication role mappings emptiable

This commit is contained in:
Rıdvan Akca
2023-09-12 13:51:46 +03:00
committed by Ali BARIN
parent b96ba69a72
commit 9fbc9d59f5
2 changed files with 5 additions and 3 deletions

View File

@@ -245,5 +245,6 @@
"roleMappingsForm.role": "Role", "roleMappingsForm.role": "Role",
"roleMappingsForm.appendRoleMapping": "Append", "roleMappingsForm.appendRoleMapping": "Append",
"roleMappingsForm.save": "Save", "roleMappingsForm.save": "Save",
"roleMappingsForm.notFound": "No role mappings have found.",
"roleMappingsForm.successfullySaved": "Role mappings have been saved." "roleMappingsForm.successfullySaved": "Role mappings have been saved."
} }

View File

@@ -11,7 +11,7 @@ import useFormatMessage from 'hooks/useFormatMessage';
import ControlledAutocomplete from 'components/ControlledAutocomplete'; import ControlledAutocomplete from 'components/ControlledAutocomplete';
import TextField from 'components/TextField'; import TextField from 'components/TextField';
import { Divider } from '@mui/material'; import { Divider, Typography } from '@mui/material';
function generateRoleOptions(roles: IRole[]) { function generateRoleOptions(roles: IRole[]) {
return roles?.map(({ name: label, id: value }) => ({ label, value })); return roles?.map(({ name: label, id: value }) => ({ label, value }));
@@ -28,9 +28,11 @@ function RoleMappingsFieldArray() {
const handleAppendMapping = () => append({ roleId: '', remoteRoleName: '' }); const handleAppendMapping = () => append({ roleId: '', remoteRoleName: '' });
const handleRemoveMapping = (index: number) => () => remove(index); const handleRemoveMapping = (index: number) => () => remove(index);
return ( return (
<> <>
{fields.length === 0 && (
<Typography>{formatMessage('roleMappingsForm.notFound')}</Typography>
)}
{fields.map((field, index) => ( {fields.map((field, index) => (
<div key={field.id}> <div key={field.id}>
<Stack <Stack
@@ -74,7 +76,6 @@ function RoleMappingsFieldArray() {
size="large" size="large"
sx={{ alignSelf: 'flex-start' }} sx={{ alignSelf: 'flex-start' }}
onClick={handleRemoveMapping(index)} onClick={handleRemoveMapping(index)}
disabled={fields.length === 1}
> >
<DeleteIcon /> <DeleteIcon />
</IconButton> </IconButton>