mirror of
https://github.com/UA-Fediland/synapse-admin.git
synced 2024-11-22 14:31:27 +00:00
Shows encrypted status with icons
This commit is contained in:
parent
3884c50012
commit
3fd615943c
1 changed files with 36 additions and 1 deletions
|
@ -5,12 +5,43 @@ import {
|
||||||
TextField,
|
TextField,
|
||||||
Pagination,
|
Pagination,
|
||||||
BooleanField,
|
BooleanField,
|
||||||
|
useTranslate,
|
||||||
} from "react-admin";
|
} from "react-admin";
|
||||||
|
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";
|
||||||
|
|
||||||
const RoomPagination = props => (
|
const RoomPagination = props => (
|
||||||
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
|
<Pagination {...props} rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />
|
||||||
);
|
);
|
||||||
|
|
||||||
|
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>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const RoomList = props => (
|
export const RoomList = props => (
|
||||||
<List
|
<List
|
||||||
{...props}
|
{...props}
|
||||||
|
@ -18,6 +49,11 @@ export const RoomList = props => (
|
||||||
sort={{ field: "name", order: "ASC" }}
|
sort={{ field: "name", order: "ASC" }}
|
||||||
>
|
>
|
||||||
<Datagrid>
|
<Datagrid>
|
||||||
|
<EncryptionField
|
||||||
|
source="is_encrypted"
|
||||||
|
sortBy="encryption"
|
||||||
|
label={<HttpsIcon />}
|
||||||
|
/>
|
||||||
<TextField source="room_id" sortable={false} />
|
<TextField source="room_id" sortable={false} />
|
||||||
<TextField source="name" />
|
<TextField source="name" />
|
||||||
<TextField source="canonical_alias" />
|
<TextField source="canonical_alias" />
|
||||||
|
@ -25,7 +61,6 @@ export const RoomList = props => (
|
||||||
<TextField source="joined_local_members" />
|
<TextField source="joined_local_members" />
|
||||||
<TextField source="state_events" />
|
<TextField source="state_events" />
|
||||||
<TextField source="version" />
|
<TextField source="version" />
|
||||||
<BooleanField source="is_encrypted" />
|
|
||||||
<BooleanField source="federatable" />
|
<BooleanField source="federatable" />
|
||||||
<BooleanField source="public" />
|
<BooleanField source="public" />
|
||||||
</Datagrid>
|
</Datagrid>
|
||||||
|
|
Loading…
Reference in a new issue