mirror of
https://github.com/UA-Fediland/synapse-admin.git
synced 2024-12-22 04:53:17 +00:00
Update dataProvider hooks
Change-Id: Ic19f7a6ad97b1392c96c91a19e76b8983c9d0fd2
This commit is contained in:
parent
51def5775d
commit
a222af273f
5 changed files with 35 additions and 27 deletions
|
@ -50,7 +50,7 @@ const ServerNoticeDialog = ({ open, loading, onClose, onSend }) => {
|
|||
<SimpleForm
|
||||
toolbar={<ServerNoticeToolbar />}
|
||||
redirect={false}
|
||||
save={onSend}
|
||||
onSubmit={onSend}
|
||||
>
|
||||
<TextInput
|
||||
source="body"
|
||||
|
@ -71,14 +71,15 @@ export const ServerNoticeButton = () => {
|
|||
const record = useRecordContext();
|
||||
const [open, setOpen] = useState(false);
|
||||
const notify = useNotify();
|
||||
const [create, { isloading }] = useCreate("servernotices");
|
||||
const [create, { isloading }] = useCreate();
|
||||
|
||||
const handleDialogOpen = () => setOpen(true);
|
||||
const handleDialogClose = () => setOpen(false);
|
||||
|
||||
const handleSend = values => {
|
||||
create(
|
||||
{ payload: { data: { id: record.id, ...values } } },
|
||||
"servernotices",
|
||||
{ data: { id: record.id, ...values } },
|
||||
{
|
||||
onSuccess: () => {
|
||||
notify("resources.servernotices.action.send_success");
|
||||
|
|
|
@ -53,7 +53,7 @@ export const DestinationReconnectButton = props => {
|
|||
const record = useRecordContext();
|
||||
const refresh = useRefresh();
|
||||
const notify = useNotify();
|
||||
const [handleReconnect, { isLoading }] = useDelete("destinations");
|
||||
const [handleReconnect, { isLoading }] = useDelete();
|
||||
|
||||
// Reconnect is not required if no error has occurred. (`failure_ts`)
|
||||
if (!record || !record.failure_ts) return null;
|
||||
|
@ -63,7 +63,8 @@ export const DestinationReconnectButton = props => {
|
|||
e.stopPropagation();
|
||||
|
||||
handleReconnect(
|
||||
{ payload: { id: record.id } },
|
||||
"destinations",
|
||||
{ id: record.id },
|
||||
{
|
||||
onSuccess: () => {
|
||||
notify("ra.notification.updated", {
|
||||
|
|
|
@ -17,7 +17,7 @@ export const DeviceRemoveButton = props => {
|
|||
const refresh = useRefresh();
|
||||
const notify = useNotify();
|
||||
|
||||
const [removeDevice, { isLoading }] = useDelete("devices");
|
||||
const [removeDevice, { isLoading }] = useDelete();
|
||||
|
||||
if (!record) return null;
|
||||
|
||||
|
@ -26,7 +26,8 @@ export const DeviceRemoveButton = props => {
|
|||
|
||||
const handleConfirm = () => {
|
||||
removeDevice(
|
||||
{ payload: { id: record.id, user_id: record.user_id } },
|
||||
"devices",
|
||||
{ id: record.id, meta: { user_id: record.user_id } },
|
||||
{
|
||||
onSuccess: () => {
|
||||
notify("resources.devices.action.erase.success");
|
||||
|
|
|
@ -97,14 +97,15 @@ export const DeleteMediaButton = props => {
|
|||
const theme = useTheme();
|
||||
const [open, setOpen] = useState(false);
|
||||
const notify = useNotify();
|
||||
const [deleteOne, { isLoading }] = useDelete("delete_media");
|
||||
const [deleteOne, { isLoading }] = useDelete();
|
||||
|
||||
const handleDialogOpen = () => setOpen(true);
|
||||
const handleDialogClose = () => setOpen(false);
|
||||
|
||||
const handleSend = values => {
|
||||
deleteOne(
|
||||
{ payload: { ...values } },
|
||||
"delete_media",
|
||||
{ id: values.id },
|
||||
{
|
||||
onSuccess: () => {
|
||||
notify("resources.delete_media.action.send_success");
|
||||
|
@ -151,14 +152,15 @@ export const ProtectMediaButton = props => {
|
|||
const translate = useTranslate();
|
||||
const refresh = useRefresh();
|
||||
const notify = useNotify();
|
||||
const [create, { loading }] = useCreate("protect_media");
|
||||
const [deleteOne] = useDelete("protect_media");
|
||||
const [create, { isLoading }] = useCreate();
|
||||
const [deleteOne] = useDelete();
|
||||
|
||||
if (!record) return null;
|
||||
|
||||
const handleProtect = () => {
|
||||
create(
|
||||
{ payload: { data: record } },
|
||||
"protect_media",
|
||||
{ data: record },
|
||||
{
|
||||
onSuccess: () => {
|
||||
notify("resources.protect_media.action.send_success");
|
||||
|
@ -174,7 +176,8 @@ export const ProtectMediaButton = props => {
|
|||
|
||||
const handleUnprotect = () => {
|
||||
deleteOne(
|
||||
{ payload: { ...record } },
|
||||
"protect_media",
|
||||
{ id: record.id },
|
||||
{
|
||||
onSuccess: () => {
|
||||
notify("resources.protect_media.action.send_success");
|
||||
|
@ -219,7 +222,7 @@ export const ProtectMediaButton = props => {
|
|||
arrow
|
||||
>
|
||||
<div>
|
||||
<Button onClick={handleUnprotect} disabled={loading}>
|
||||
<Button onClick={handleUnprotect} disabled={isLoading}>
|
||||
<LockIcon />
|
||||
</Button>
|
||||
</div>
|
||||
|
@ -232,7 +235,7 @@ export const ProtectMediaButton = props => {
|
|||
})}
|
||||
>
|
||||
<div>
|
||||
<Button onClick={handleProtect} disabled={loading}>
|
||||
<Button onClick={handleProtect} disabled={isLoading}>
|
||||
<LockOpenIcon />
|
||||
</Button>
|
||||
</div>
|
||||
|
@ -247,14 +250,15 @@ export const QuarantineMediaButton = props => {
|
|||
const translate = useTranslate();
|
||||
const refresh = useRefresh();
|
||||
const notify = useNotify();
|
||||
const [create, { loading }] = useCreate("quarantine_media");
|
||||
const [deleteOne] = useDelete("quarantine_media");
|
||||
const [create, { isLoading }] = useCreate();
|
||||
const [deleteOne] = useDelete();
|
||||
|
||||
if (!record) return null;
|
||||
|
||||
const handleQuarantaine = () => {
|
||||
create(
|
||||
{ payload: { data: record } },
|
||||
"quarantine_media",
|
||||
{ data: record },
|
||||
{
|
||||
onSuccess: () => {
|
||||
notify("resources.quarantine_media.action.send_success");
|
||||
|
@ -270,7 +274,8 @@ export const QuarantineMediaButton = props => {
|
|||
|
||||
const handleRemoveQuarantaine = () => {
|
||||
deleteOne(
|
||||
{ payload: { ...record } },
|
||||
"quarantine_media",
|
||||
{ id: record.id },
|
||||
{
|
||||
onSuccess: () => {
|
||||
notify("resources.quarantine_media.action.send_success");
|
||||
|
@ -306,7 +311,7 @@ export const QuarantineMediaButton = props => {
|
|||
})}
|
||||
>
|
||||
<div>
|
||||
<Button onClick={handleRemoveQuarantaine} disabled={loading}>
|
||||
<Button onClick={handleRemoveQuarantaine} disabled={isLoading}>
|
||||
<BlockIcon color="error" />
|
||||
</Button>
|
||||
</div>
|
||||
|
@ -319,7 +324,7 @@ export const QuarantineMediaButton = props => {
|
|||
})}
|
||||
>
|
||||
<div>
|
||||
<Button onClick={handleQuarantaine} disabled={loading}>
|
||||
<Button onClick={handleQuarantaine} disabled={isLoading}>
|
||||
<BlockIcon />
|
||||
</Button>
|
||||
</div>
|
||||
|
|
|
@ -98,7 +98,7 @@ const resourceMap = {
|
|||
}),
|
||||
delete: params => ({
|
||||
endpoint: `/_synapse/admin/v2/users/${encodeURIComponent(
|
||||
params.user_id
|
||||
params.meta.user_id
|
||||
)}/devices/${params.id}`,
|
||||
}),
|
||||
},
|
||||
|
@ -184,9 +184,9 @@ const resourceMap = {
|
|||
delete: params => ({
|
||||
endpoint: `/_synapse/admin/v1/media/${localStorage.getItem(
|
||||
"home_server"
|
||||
)}/delete?before_ts=${params.before_ts}&size_gt=${
|
||||
params.size_gt
|
||||
}&keep_profiles=${params.keep_profiles}`,
|
||||
)}/delete?before_ts=${params.meta.before_ts}&size_gt=${
|
||||
params.meta.size_gt
|
||||
}&keep_profiles=${params.meta.keep_profiles}`,
|
||||
method: "POST",
|
||||
}),
|
||||
},
|
||||
|
@ -197,7 +197,7 @@ const resourceMap = {
|
|||
method: "POST",
|
||||
}),
|
||||
delete: params => ({
|
||||
endpoint: `/_synapse/admin/v1/media/unprotect/${params.media_id}`,
|
||||
endpoint: `/_synapse/admin/v1/media/unprotect/${params.id}`,
|
||||
method: "POST",
|
||||
}),
|
||||
},
|
||||
|
@ -212,7 +212,7 @@ const resourceMap = {
|
|||
delete: params => ({
|
||||
endpoint: `/_synapse/admin/v1/media/unquarantine/${localStorage.getItem(
|
||||
"home_server"
|
||||
)}/${params.media_id}`,
|
||||
)}/${params.id}`,
|
||||
method: "POST",
|
||||
}),
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue