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 => (
|
const UserFilter = props => (
|
||||||
<Filter {...props}>
|
<Filter {...props}>
|
||||||
<SearchInput source="q" alwaysOn />
|
<SearchInput source="user_id" alwaysOn />
|
||||||
<BooleanInput source="guests" alwaysOn />
|
<BooleanInput source="guests" alwaysOn />
|
||||||
<BooleanInput
|
<BooleanInput
|
||||||
label="resources.users.fields.show_deactivated"
|
label="resources.users.fields.show_deactivated"
|
||||||
@ -71,24 +71,9 @@ export const UserList = props => (
|
|||||||
pagination={<UserPagination />}
|
pagination={<UserPagination />}
|
||||||
>
|
>
|
||||||
<Datagrid rowClick="edit">
|
<Datagrid rowClick="edit">
|
||||||
<ReferenceField
|
<ImageField source="avatar_url" title="displayname" />
|
||||||
source="Avatar"
|
<TextField source="id" sortable={false} />
|
||||||
reference="users"
|
<TextField source="displayname" />
|
||||||
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>
|
|
||||||
<BooleanField source="is_guest" sortable={false} />
|
<BooleanField source="is_guest" sortable={false} />
|
||||||
<BooleanField source="admin" sortable={false} />
|
<BooleanField source="admin" sortable={false} />
|
||||||
<BooleanField source="deactivated" sortable={false} />
|
<BooleanField source="deactivated" sortable={false} />
|
||||||
|
@ -25,11 +25,7 @@ const resourceMap = {
|
|||||||
deactivated: !!u.deactivated,
|
deactivated: !!u.deactivated,
|
||||||
}),
|
}),
|
||||||
data: "users",
|
data: "users",
|
||||||
total: (json, from, perPage) => {
|
total: json => json.total,
|
||||||
return json.next_token
|
|
||||||
? parseInt(json.next_token, 10) + perPage
|
|
||||||
: from + json.users.length;
|
|
||||||
},
|
|
||||||
delete: id => ({
|
delete: id => ({
|
||||||
endpoint: `/_synapse/admin/v1/deactivate/${id}`,
|
endpoint: `/_synapse/admin/v1/deactivate/${id}`,
|
||||||
body: { erase: true },
|
body: { erase: true },
|
||||||
@ -96,25 +92,6 @@ const dataProvider = {
|
|||||||
const homeserver_url = homeserver + res.path;
|
const homeserver_url = homeserver + res.path;
|
||||||
const url = `${homeserver_url}?${stringify(query)}`;
|
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 }) => ({
|
return jsonClient(url).then(({ json }) => ({
|
||||||
data: json[res.data].map(res.map),
|
data: json[res.data].map(res.map),
|
||||||
total: res.total(json, from, perPage),
|
total: res.total(json, from, perPage),
|
||||||
|
Loading…
Reference in New Issue
Block a user