Adapt for changes in v2/users API
Change-Id: I927b81882fa20e5b3de3d9fc216e2136f7036bba
This commit is contained in:
parent
0823976edd
commit
662735a91f
@ -39,7 +39,7 @@ const UserPagination = props => (
|
||||
|
||||
const UserFilter = props => (
|
||||
<Filter {...props}>
|
||||
<SearchInput source="q" alwaysOn />
|
||||
<SearchInput source="user_id" alwaysOn />
|
||||
<BooleanInput source="guests" alwaysOn />
|
||||
<BooleanInput
|
||||
label="resources.users.fields.show_deactivated"
|
||||
@ -71,24 +71,9 @@ export const UserList = props => (
|
||||
pagination={<UserPagination />}
|
||||
>
|
||||
<Datagrid rowClick="edit">
|
||||
<ReferenceField
|
||||
source="Avatar"
|
||||
reference="users"
|
||||
link={false}
|
||||
sortable={false}
|
||||
>
|
||||
<ImageField source="avatar_url" title="displayname" />
|
||||
</ReferenceField>
|
||||
<TextField source="id" />
|
||||
{/* Hack since the users endpoint does not give displaynames in the list*/}
|
||||
<ReferenceField
|
||||
source="name"
|
||||
reference="users"
|
||||
link={false}
|
||||
sortable={false}
|
||||
>
|
||||
<TextField source="displayname" />
|
||||
</ReferenceField>
|
||||
<ImageField source="avatar_url" title="displayname" />
|
||||
<TextField source="id" sortable={false} />
|
||||
<TextField source="displayname" />
|
||||
<BooleanField source="is_guest" sortable={false} />
|
||||
<BooleanField source="admin" sortable={false} />
|
||||
<BooleanField source="deactivated" sortable={false} />
|
||||
|
@ -25,11 +25,7 @@ const resourceMap = {
|
||||
deactivated: !!u.deactivated,
|
||||
}),
|
||||
data: "users",
|
||||
total: (json, from, perPage) => {
|
||||
return json.next_token
|
||||
? parseInt(json.next_token, 10) + perPage
|
||||
: from + json.users.length;
|
||||
},
|
||||
total: json => json.total,
|
||||
delete: id => ({
|
||||
endpoint: `/_synapse/admin/v1/deactivate/${id}`,
|
||||
body: { erase: true },
|
||||
@ -96,25 +92,6 @@ const dataProvider = {
|
||||
const homeserver_url = homeserver + res.path;
|
||||
const url = `${homeserver_url}?${stringify(query)}`;
|
||||
|
||||
// searching for users is not implemented in admin api
|
||||
if (params.filter.q) {
|
||||
console.log("searching");
|
||||
const search_query = { limit: perPage, search_term: params.filter.q };
|
||||
const search_url =
|
||||
homeserver + `/_matrix/client/r0/user_directory/search`;
|
||||
return jsonClient(search_url, {
|
||||
method: "POST",
|
||||
body: JSON.stringify(search_query),
|
||||
}).then(({ json }) => ({
|
||||
data: json["results"].map(u => ({
|
||||
...u,
|
||||
id: u.user_id,
|
||||
name: u.user_id,
|
||||
})),
|
||||
total: json.limited ? perPage * 2 : json.results.length,
|
||||
}));
|
||||
}
|
||||
|
||||
return jsonClient(url).then(({ json }) => ({
|
||||
data: json[res.data].map(res.map),
|
||||
total: res.total(json, from, perPage),
|
||||
|
Loading…
Reference in New Issue
Block a user