mirror of
https://github.com/UA-Fediland/synapse-admin.git
synced 2024-11-09 16:24:51 +00:00
Add buttons to erase users (#32)
Change-Id: I9b5644394d213dc66b30e39f19e9e392b69a0be3
This commit is contained in:
parent
2240559f74
commit
b7f009e559
4 changed files with 91 additions and 20 deletions
|
@ -1,4 +1,4 @@
|
||||||
import React from "react";
|
import React, { Fragment } from "react";
|
||||||
import PersonPinIcon from "@material-ui/icons/PersonPin";
|
import PersonPinIcon from "@material-ui/icons/PersonPin";
|
||||||
import SettingsInputComponentIcon from "@material-ui/icons/SettingsInputComponent";
|
import SettingsInputComponentIcon from "@material-ui/icons/SettingsInputComponent";
|
||||||
import {
|
import {
|
||||||
|
@ -10,6 +10,7 @@ import {
|
||||||
Edit,
|
Edit,
|
||||||
List,
|
List,
|
||||||
Filter,
|
Filter,
|
||||||
|
Toolbar,
|
||||||
SimpleForm,
|
SimpleForm,
|
||||||
SimpleFormIterator,
|
SimpleFormIterator,
|
||||||
TabbedForm,
|
TabbedForm,
|
||||||
|
@ -22,7 +23,11 @@ import {
|
||||||
TextInput,
|
TextInput,
|
||||||
ReferenceField,
|
ReferenceField,
|
||||||
SelectInput,
|
SelectInput,
|
||||||
|
BulkDeleteButton,
|
||||||
|
DeleteButton,
|
||||||
|
SaveButton,
|
||||||
regex,
|
regex,
|
||||||
|
useTranslate,
|
||||||
Pagination,
|
Pagination,
|
||||||
} from "react-admin";
|
} from "react-admin";
|
||||||
|
|
||||||
|
@ -41,12 +46,25 @@ const UserFilter = props => (
|
||||||
</Filter>
|
</Filter>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const UserBulkActionButtons = props => {
|
||||||
|
const translate = useTranslate();
|
||||||
|
return (
|
||||||
|
<Fragment>
|
||||||
|
<BulkDeleteButton
|
||||||
|
{...props}
|
||||||
|
label="resources.users.action.erase"
|
||||||
|
title={translate("resources.users.helper.erase")}
|
||||||
|
/>
|
||||||
|
</Fragment>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const UserList = props => (
|
export const UserList = props => (
|
||||||
<List
|
<List
|
||||||
{...props}
|
{...props}
|
||||||
filters={<UserFilter />}
|
filters={<UserFilter />}
|
||||||
filterDefaultValues={{ guests: true, deactivated: false }}
|
filterDefaultValues={{ guests: true, deactivated: false }}
|
||||||
bulkActionButtons={false}
|
bulkActionButtons={<UserBulkActionButtons />}
|
||||||
pagination={<UserPagination />}
|
pagination={<UserPagination />}
|
||||||
>
|
>
|
||||||
<Datagrid rowClick="edit">
|
<Datagrid rowClick="edit">
|
||||||
|
@ -81,6 +99,19 @@ const validateUser = regex(
|
||||||
"synapseadmin.users.invalid_user_id"
|
"synapseadmin.users.invalid_user_id"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const UserEditToolbar = props => {
|
||||||
|
const translate = useTranslate();
|
||||||
|
return (
|
||||||
|
<Toolbar {...props}>
|
||||||
|
<SaveButton submitOnEnter={true} />
|
||||||
|
<DeleteButton
|
||||||
|
label="resources.users.action.erase"
|
||||||
|
title={translate("resources.users.helper.erase")}
|
||||||
|
/>
|
||||||
|
</Toolbar>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const UserCreate = props => (
|
export const UserCreate = props => (
|
||||||
<Create {...props}>
|
<Create {...props}>
|
||||||
<SimpleForm>
|
<SimpleForm>
|
||||||
|
@ -106,7 +137,7 @@ export const UserCreate = props => (
|
||||||
|
|
||||||
export const UserEdit = props => (
|
export const UserEdit = props => (
|
||||||
<Edit {...props}>
|
<Edit {...props}>
|
||||||
<TabbedForm>
|
<TabbedForm toolbar={<UserEditToolbar />}>
|
||||||
<FormTab label="resources.users.name" icon={<PersonPinIcon />}>
|
<FormTab label="resources.users.name" icon={<PersonPinIcon />}>
|
||||||
<TextInput source="id" disabled />
|
<TextInput source="id" disabled />
|
||||||
<TextInput source="displayname" />
|
<TextInput source="displayname" />
|
||||||
|
|
|
@ -37,6 +37,10 @@ export default {
|
||||||
},
|
},
|
||||||
helper: {
|
helper: {
|
||||||
deactivate: "Deaktivierte Nutzer können nicht wieder aktiviert werden.",
|
deactivate: "Deaktivierte Nutzer können nicht wieder aktiviert werden.",
|
||||||
|
erase: "DSGVO konformes Löschen der Benutzerdaten",
|
||||||
|
},
|
||||||
|
action: {
|
||||||
|
erase: "Lösche Benutzerdaten",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
|
|
|
@ -37,6 +37,10 @@ export default {
|
||||||
},
|
},
|
||||||
helper: {
|
helper: {
|
||||||
deactivate: "Deactivated users cannot be reactivated",
|
deactivate: "Deactivated users cannot be reactivated",
|
||||||
|
erase: "Mark the user as GDPR-erased",
|
||||||
|
},
|
||||||
|
action: {
|
||||||
|
erase: "Erase user data",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
|
|
|
@ -30,6 +30,11 @@ const resourceMap = {
|
||||||
? parseInt(json.next_token, 10) + perPage
|
? parseInt(json.next_token, 10) + perPage
|
||||||
: from + json.users.length;
|
: from + json.users.length;
|
||||||
},
|
},
|
||||||
|
delete: id => ({
|
||||||
|
endpoint: `/_synapse/admin/v1/deactivate/${id}`,
|
||||||
|
body: { erase: true },
|
||||||
|
method: "POST",
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
rooms: {
|
rooms: {
|
||||||
path: "/_synapse/admin/v1/rooms",
|
path: "/_synapse/admin/v1/rooms",
|
||||||
|
@ -202,12 +207,24 @@ const dataProvider = {
|
||||||
|
|
||||||
const res = resourceMap[resource];
|
const res = resourceMap[resource];
|
||||||
|
|
||||||
const homeserver_url = homeserver + res.path;
|
if ("delete" in res) {
|
||||||
return jsonClient(`${homeserver_url}/${params.id}`, {
|
const del = res["delete"](params.id);
|
||||||
method: "DELETE",
|
const homeserver_url = homeserver + del.endpoint;
|
||||||
|
return jsonClient(homeserver_url, {
|
||||||
|
method: del.method,
|
||||||
|
body: JSON.stringify(del.body),
|
||||||
}).then(({ json }) => ({
|
}).then(({ json }) => ({
|
||||||
data: json,
|
data: json,
|
||||||
}));
|
}));
|
||||||
|
} else {
|
||||||
|
const homeserver_url = homeserver + res.path;
|
||||||
|
return jsonClient(`${homeserver_url}/${params.id}`, {
|
||||||
|
method: "DELETE",
|
||||||
|
body: JSON.stringify(params.data, filterNullValues),
|
||||||
|
}).then(({ json }) => ({
|
||||||
|
data: json,
|
||||||
|
}));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
deleteMany: (resource, params) => {
|
deleteMany: (resource, params) => {
|
||||||
|
@ -217,17 +234,32 @@ const dataProvider = {
|
||||||
|
|
||||||
const res = resourceMap[resource];
|
const res = resourceMap[resource];
|
||||||
|
|
||||||
|
if ("delete" in res) {
|
||||||
|
return Promise.all(
|
||||||
|
params.ids.map(id => {
|
||||||
|
const del = res["delete"](id);
|
||||||
|
const homeserver_url = homeserver + del.endpoint;
|
||||||
|
return jsonClient(homeserver_url, {
|
||||||
|
method: del.method,
|
||||||
|
body: JSON.stringify(del.body),
|
||||||
|
});
|
||||||
|
})
|
||||||
|
).then(responses => ({
|
||||||
|
data: responses.map(({ json }) => json),
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
const homeserver_url = homeserver + res.path;
|
const homeserver_url = homeserver + res.path;
|
||||||
return Promise.all(
|
return Promise.all(
|
||||||
params.ids.map(id =>
|
params.ids.map(id =>
|
||||||
jsonClient(`${homeserver_url}/${id}`, {
|
jsonClient(`${homeserver_url}/${id}`, {
|
||||||
method: "DELETE",
|
method: "DELETE",
|
||||||
body: JSON.stringify(params.data, filterNullValues),
|
body: JSON.stringify(params.data, filterNullValues),
|
||||||
}).then(responses => ({
|
})
|
||||||
data: responses.map(({ json }) => json),
|
|
||||||
}))
|
|
||||||
)
|
)
|
||||||
);
|
).then(responses => ({
|
||||||
|
data: responses.map(({ json }) => json),
|
||||||
|
}));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue