Add edit user_type to user

This commit is contained in:
dklimpel 2021-11-19 10:15:09 +01:00
parent abc9d5154e
commit 8df2b55c9d
5 changed files with 32 additions and 13 deletions

View File

@ -5,7 +5,7 @@
This project is built using [react-admin](https://marmelab.com/react-admin/). This project is built using [react-admin](https://marmelab.com/react-admin/).
It needs at least Synapse v1.41.0 for all functions to work as expected! It needs at least Synapse v1.46.0 for all functions to work as expected!
You get your server version with the request `/_synapse/admin/v1/server_version`. You get your server version with the request `/_synapse/admin/v1/server_version`.
See also [Synapse version API](https://matrix-org.github.io/synapse/develop/admin_api/version_api.html). See also [Synapse version API](https://matrix-org.github.io/synapse/develop/admin_api/version_api.html).

View File

@ -71,6 +71,16 @@ const useStyles = makeStyles({
}, },
}); });
const choices_medium = [
{ id: "email", name: "resources.users.email" },
{ id: "msisdn", name: "resources.users.msisdn" },
];
const choices_type = [
{ id: "bot", name: "bot" },
{ id: "support", name: "support" },
];
const UserListActions = ({ const UserListActions = ({
currentSort, currentSort,
className, className,
@ -261,15 +271,19 @@ export const UserCreate = props => (
autoComplete="new-password" autoComplete="new-password"
validate={maxLength(512)} validate={maxLength(512)}
/> />
<SelectInput
source="user_type"
choices={choices_type}
translateChoice={false}
allowEmpty={true}
resettable
/>
<BooleanInput source="admin" /> <BooleanInput source="admin" />
<ArrayInput source="threepids"> <ArrayInput source="threepids">
<SimpleFormIterator> <SimpleFormIterator>
<SelectInput <SelectInput
source="medium" source="medium"
choices={[ choices={choices_medium}
{ id: "email", name: "resources.users.email" },
{ id: "msisdn", name: "resources.users.msisdn" },
]}
validate={required()} validate={required()}
/> />
<TextInput source="address" validate={validateAddress} /> <TextInput source="address" validate={validateAddress} />
@ -300,6 +314,7 @@ const UserTitle = ({ record }) => {
</span> </span>
); );
}; };
export const UserEdit = props => { export const UserEdit = props => {
const classes = useStyles(); const classes = useStyles();
const translate = useTranslate(); const translate = useTranslate();
@ -318,6 +333,13 @@ export const UserEdit = props => {
<TextInput source="id" disabled /> <TextInput source="id" disabled />
<TextInput source="displayname" /> <TextInput source="displayname" />
<PasswordInput source="password" autoComplete="new-password" /> <PasswordInput source="password" autoComplete="new-password" />
<SelectInput
source="user_type"
choices={choices_type}
translateChoice={false}
allowEmpty={true}
resettable
/>
<BooleanInput source="admin" /> <BooleanInput source="admin" />
<BooleanInput <BooleanInput
source="deactivated" source="deactivated"
@ -345,13 +367,7 @@ export const UserEdit = props => {
> >
<ArrayInput source="threepids"> <ArrayInput source="threepids">
<SimpleFormIterator> <SimpleFormIterator>
<SelectInput <SelectInput source="medium" choices={choices_medium} />
source="medium"
choices={[
{ id: "email", name: "resources.users.email" },
{ id: "msisdn", name: "resources.users.msisdn" },
]}
/>
<TextInput source="address" /> <TextInput source="address" />
</SimpleFormIterator> </SimpleFormIterator>
</ArrayInput> </ArrayInput>

View File

@ -121,6 +121,7 @@ const de = {
creation_ts_ms: "Zeitpunkt der Erstellung", creation_ts_ms: "Zeitpunkt der Erstellung",
consent_version: "Zugestimmte Geschäftsbedingungen", consent_version: "Zugestimmte Geschäftsbedingungen",
auth_provider: "Provider", auth_provider: "Provider",
user_type: "Benutzertyp",
}, },
helper: { helper: {
deactivate: deactivate:

View File

@ -120,6 +120,7 @@ const en = {
creation_ts_ms: "Creation timestamp", creation_ts_ms: "Creation timestamp",
consent_version: "Consent version", consent_version: "Consent version",
auth_provider: "Provider", auth_provider: "Provider",
user_type: "User type",
}, },
helper: { helper: {
deactivate: "You must provide a password to re-activate an account.", deactivate: "You must provide a password to re-activate an account.",

View File

@ -279,7 +279,8 @@ const resourceMap = {
function filterNullValues(key, value) { function filterNullValues(key, value) {
// Filtering out null properties // Filtering out null properties
if (value === null) { // to reset user_type from user, it must be null
if (value === null && key !== "user_type") {
return undefined; return undefined;
} }
return value; return value;