From 00ecb29d6bdc11972a8df548cb5c1365784d2637 Mon Sep 17 00:00:00 2001
From: dklimpel <5740567+dklimpel@users.noreply.github.com>
Date: Tue, 6 Feb 2024 12:01:25 +0100
Subject: [PATCH] Refactor RoomDirectory
Change-Id: Ie3bd606fc91b2673d2a3422f8fd465258d3211b0
---
src/components/RoomDirectory.js | 66 +++++++++++++++++----------------
src/components/rooms.js | 21 ++++-------
2 files changed, 42 insertions(+), 45 deletions(-)
diff --git a/src/components/RoomDirectory.js b/src/components/RoomDirectory.js
index bb30e75..2b338a6 100644
--- a/src/components/RoomDirectory.js
+++ b/src/components/RoomDirectory.js
@@ -13,6 +13,7 @@ import {
TextField,
TopToolbar,
useCreate,
+ useDataProvider,
useListContext,
useNotify,
useTranslate,
@@ -28,7 +29,7 @@ const RoomDirectoryPagination = () => (
);
-export const RoomDirectoryDeleteButton = props => {
+export const RoomDirectoryUnpublishButton = props => {
const translate = useTranslate();
return (
@@ -49,7 +50,7 @@ export const RoomDirectoryDeleteButton = props => {
);
};
-export const RoomDirectoryBulkDeleteButton = props => (
+export const RoomDirectoryBulkUnpublishButton = props => (
(
/>
);
-export const RoomDirectoryBulkSaveButton = () => {
+export const RoomDirectoryBulkPublishButton = props => {
const { selectedIds } = useListContext();
const notify = useNotify();
const refresh = useRefresh();
const unselectAllRooms = useUnselectAll("rooms");
- const { createMany, isloading } = useMutation();
-
- const handleSend = values => {
- createMany(
- ["room_directory", "createMany", { ids: selectedIds, data: {} }],
- {
- onSuccess: data => {
- notify("resources.room_directory.action.send_success");
- unselectAllRooms();
- refresh();
- },
- onError: error =>
- notify("resources.room_directory.action.send_failure", {
- type: "error",
- }),
- }
- );
- };
+ const dataProvider = useDataProvider();
+ const { mutate, isLoading } = useMutation(
+ () =>
+ dataProvider.createMany("room_directory", {
+ ids: selectedIds,
+ data: {},
+ }),
+ {
+ onSuccess: () => {
+ notify("resources.room_directory.action.send_success");
+ unselectAllRooms();
+ refresh();
+ },
+ onError: () =>
+ notify("resources.room_directory.action.send_failure", {
+ type: "error",
+ }),
+ }
+ );
return (
);
};
-export const RoomDirectorySaveButton = () => {
+export const RoomDirectoryPublishButton = props => {
const record = useRecordContext();
const notify = useNotify();
const refresh = useRefresh();
- const [create, { isloading }] = useCreate();
+ const [create, { isLoading }] = useCreate();
const handleSend = () => {
create(
"room_directory",
{ data: { id: record.id } },
{
- onSuccess: _data => {
+ onSuccess: () => {
notify("resources.room_directory.action.send_success");
refresh();
},
- onError: _error =>
+ onError: () =>
notify("resources.room_directory.action.send_failure", {
type: "error",
}),
@@ -121,17 +124,16 @@ export const RoomDirectorySaveButton = () => {
return (
);
};
-const RoomDirectoryBulkActionButtons = () => ;
-
const RoomDirectoryListActions = () => (
@@ -146,8 +148,8 @@ export const RoomDirectoryList = () => (
actions={}
>
"/rooms/" + id + "/show"}
- bulkActionButtons={}
+ rowClick={(id, _resource, _record) => "/rooms/" + id + "/show"}
+ bulkActionButtons={}
omit={["room_id", "canonical_alias", "topic"]}
>
{
return (
- {roomDirectoryStatus === false && (
-
- )}
- {roomDirectoryStatus === true && (
-
- )}
+ {roomDirectoryStatus === false && }
+ {roomDirectoryStatus === true && }
{
const RoomBulkActionButtons = () => (
<>
-
-
+
+