2020-02-07 18:19:01 +03:00
|
|
|
import React from "react";
|
2020-05-23 18:43:33 +03:00
|
|
|
import {
|
|
|
|
Datagrid,
|
|
|
|
List,
|
|
|
|
TextField,
|
|
|
|
Pagination,
|
|
|
|
BooleanField,
|
2020-07-01 23:36:15 +03:00
|
|
|
useTranslate,
|
2020-05-23 18:43:33 +03:00
|
|
|
} from "react-admin";
|
2020-07-01 23:36:15 +03:00
|
|
|
import get from "lodash/get";
|
|
|
|
import { Tooltip, Typography } from "@material-ui/core";
|
|
|
|
import HttpsIcon from "@material-ui/icons/Https";
|
|
|
|
import NoEncryptionIcon from "@material-ui/icons/NoEncryption";
|
2020-03-27 23:02:37 +03:00
|
|
|
|
|
|
|
const RoomPagination = props => (
|
|
|
|
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
|
|
|
|
);
|
2020-02-07 18:19:01 +03:00
|
|
|
|
2020-07-01 23:36:15 +03:00
|
|
|
const EncryptionField = ({ source, record = {}, emptyText }) => {
|
|
|
|
const translate = useTranslate();
|
|
|
|
const value = get(record, source);
|
|
|
|
let ariaLabel = value === false ? "ra.boolean.false" : "ra.boolean.true";
|
|
|
|
|
|
|
|
if (value === false || value === true) {
|
|
|
|
return (
|
|
|
|
<Typography component="span" variant="body2">
|
|
|
|
<Tooltip title={translate(ariaLabel, { _: ariaLabel })}>
|
|
|
|
{value === true ? (
|
|
|
|
<HttpsIcon data-testid="true" htmlColor="limegreen" />
|
|
|
|
) : (
|
|
|
|
<NoEncryptionIcon data-testid="false" color="error" />
|
|
|
|
)}
|
|
|
|
</Tooltip>
|
|
|
|
</Typography>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Typography component="span" variant="body2">
|
|
|
|
{emptyText}
|
|
|
|
</Typography>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2020-02-07 18:19:01 +03:00
|
|
|
export const RoomList = props => (
|
2020-05-23 18:43:33 +03:00
|
|
|
<List
|
|
|
|
{...props}
|
|
|
|
pagination={<RoomPagination />}
|
|
|
|
sort={{ field: "name", order: "ASC" }}
|
|
|
|
>
|
2020-02-07 18:19:01 +03:00
|
|
|
<Datagrid>
|
2020-07-01 23:36:15 +03:00
|
|
|
<EncryptionField
|
|
|
|
source="is_encrypted"
|
|
|
|
sortBy="encryption"
|
|
|
|
label={<HttpsIcon />}
|
|
|
|
/>
|
2020-05-23 18:43:33 +03:00
|
|
|
<TextField source="room_id" sortable={false} />
|
2020-02-07 18:19:01 +03:00
|
|
|
<TextField source="name" />
|
|
|
|
<TextField source="canonical_alias" />
|
|
|
|
<TextField source="joined_members" />
|
2020-05-23 18:43:33 +03:00
|
|
|
<TextField source="joined_local_members" />
|
|
|
|
<TextField source="state_events" />
|
|
|
|
<TextField source="version" />
|
|
|
|
<BooleanField source="federatable" />
|
|
|
|
<BooleanField source="public" />
|
2020-02-07 18:19:01 +03:00
|
|
|
</Datagrid>
|
|
|
|
</List>
|
|
|
|
);
|