Skip to content

Commit

Permalink
Federation page improvements for dark mode and last_entry without a date
Browse files Browse the repository at this point in the history
This is almost a copy of Awesome-Technologies/synapse-admin#583 PR
authored by @rkfg
  • Loading branch information
beastafk committed Sep 5, 2024
1 parent 01e3947 commit cd73633
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/resources/destinations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,19 @@ import {
useNotify,
useRefresh,
useTranslate,
DateFieldProps,
} from "react-admin";

import { DATE_FORMAT } from "../components/date";
import { get } from "lodash";

const DestinationPagination = () => <Pagination rowsPerPageOptions={[10, 25, 50, 100, 500, 1000]} />;

const destinationRowSx = (record: RaRecord) => ({
backgroundColor: record.retry_last_ts > 0 ? "#ffcccc" : "white",
backgroundColor: record.retry_last_ts > 0 ? "warning.light" : "primary.contrastText",
"& .MuiButtonBase-root": {
color: "primary.dark",
},
});

const destinationFilters = [<SearchInput source="destination" alwaysOn />];
Expand Down Expand Up @@ -92,6 +97,14 @@ const DestinationTitle = () => {
);
};

const RetryDateField = (props: DateFieldProps) => {
const record = useRecordContext(props);
if (props.source && get(record, props.source) === 0) {
return <DateField {...props} record={{ ...record, [props.source]: null }} />;
}
return <DateField {...props} />;
};

export const DestinationList = (props: ListProps) => {
return (
<List
Expand All @@ -103,7 +116,7 @@ export const DestinationList = (props: ListProps) => {
<Datagrid rowSx={destinationRowSx} rowClick={id => `${id}/show/rooms`} bulkActionButtons={false}>
<TextField source="destination" />
<DateField source="failure_ts" showTime options={DATE_FORMAT} />
<DateField source="retry_last_ts" showTime options={DATE_FORMAT} />
<RetryDateField source="retry_last_ts" showTime options={DATE_FORMAT} />
<TextField source="retry_interval" />
<TextField source="last_successful_stream_ordering" />
<DestinationReconnectButton />
Expand Down

0 comments on commit cd73633

Please sign in to comment.