make linter happy
This commit is contained in:
parent
ef41275cf0
commit
bad79df298
12
package.json
12
package.json
@ -122,6 +122,18 @@
|
|||||||
"root": true,
|
"root": true,
|
||||||
"rules": {
|
"rules": {
|
||||||
"prettier/prettier": "error",
|
"prettier/prettier": "error",
|
||||||
|
"@typescript-eslint/no-unused-vars": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"args": "all",
|
||||||
|
"argsIgnorePattern": "^_",
|
||||||
|
"caughtErrors": "all",
|
||||||
|
"caughtErrorsIgnorePattern": "^_",
|
||||||
|
"destructuredArrayIgnorePattern": "^_",
|
||||||
|
"varsIgnorePattern": "^_",
|
||||||
|
"ignoreRestSiblings": true
|
||||||
|
}
|
||||||
|
],
|
||||||
"import/no-extraneous-dependencies": [
|
"import/no-extraneous-dependencies": [
|
||||||
"error",
|
"error",
|
||||||
{
|
{
|
||||||
|
@ -83,11 +83,11 @@ const AdminMenu = props => {
|
|||||||
setEtkeRoutesEnabled(true);
|
setEtkeRoutesEnabled(true);
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
const [serverProcess, setServerProcess] = useStore<ServerProcessResponse>("serverProcess", {
|
const [serverProcess, _setServerProcess] = useStore<ServerProcessResponse>("serverProcess", {
|
||||||
command: "",
|
command: "",
|
||||||
locked_at: "",
|
locked_at: "",
|
||||||
});
|
});
|
||||||
const [serverStatus, setServerStatus] = useStore<ServerStatusResponse>("serverStatus", {
|
const [serverStatus, _setServerStatus] = useStore<ServerStatusResponse>("serverStatus", {
|
||||||
success: false,
|
success: false,
|
||||||
ok: false,
|
ok: false,
|
||||||
host: "",
|
host: "",
|
||||||
@ -124,6 +124,7 @@ const AdminMenu = props => {
|
|||||||
{menu &&
|
{menu &&
|
||||||
menu.map((item, index) => {
|
menu.map((item, index) => {
|
||||||
const { url, icon, label } = item;
|
const { url, icon, label } = item;
|
||||||
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
||||||
const IconComponent = Icons[icon] as React.ComponentType<any> | undefined;
|
const IconComponent = Icons[icon] as React.ComponentType<any> | undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -7,10 +7,8 @@ import {
|
|||||||
SimpleForm,
|
SimpleForm,
|
||||||
BooleanInput,
|
BooleanInput,
|
||||||
useTranslate,
|
useTranslate,
|
||||||
RaRecord,
|
|
||||||
useNotify,
|
useNotify,
|
||||||
useRedirect,
|
useRedirect,
|
||||||
useDelete,
|
|
||||||
NotificationType,
|
NotificationType,
|
||||||
useDeleteMany,
|
useDeleteMany,
|
||||||
Identifier,
|
Identifier,
|
||||||
@ -51,7 +49,7 @@ const DeleteRoomButton: React.FC<DeleteRoomButtonProps> = props => {
|
|||||||
unselectAll();
|
unselectAll();
|
||||||
redirect("/rooms");
|
redirect("/rooms");
|
||||||
},
|
},
|
||||||
onError: error => notify("resources.rooms.action.erase.failure", { type: "error" as NotificationType }),
|
onError: _error => notify("resources.rooms.action.erase.failure", { type: "error" as NotificationType }),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -7,10 +7,8 @@ import {
|
|||||||
SimpleForm,
|
SimpleForm,
|
||||||
BooleanInput,
|
BooleanInput,
|
||||||
useTranslate,
|
useTranslate,
|
||||||
RaRecord,
|
|
||||||
useNotify,
|
useNotify,
|
||||||
useRedirect,
|
useRedirect,
|
||||||
useDelete,
|
|
||||||
NotificationType,
|
NotificationType,
|
||||||
useDeleteMany,
|
useDeleteMany,
|
||||||
Identifier,
|
Identifier,
|
||||||
@ -57,7 +55,7 @@ const DeleteUserButton: React.FC<DeleteUserButtonProps> = props => {
|
|||||||
unselectAll();
|
unselectAll();
|
||||||
redirect("/users");
|
redirect("/users");
|
||||||
},
|
},
|
||||||
onError: error => notify("ra.notification.data_provider_error", { type: "error" as NotificationType }),
|
onError: _error => notify("ra.notification.data_provider_error", { type: "error" as NotificationType }),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -74,7 +74,7 @@ export const ExperimentalFeaturesList = () => {
|
|||||||
const updateFeature = async (feature_name: string, feature_value: boolean) => {
|
const updateFeature = async (feature_name: string, feature_value: boolean) => {
|
||||||
const updatedFeatures = { ...features, [feature_name]: feature_value } as ExperimentalFeaturesModel;
|
const updatedFeatures = { ...features, [feature_name]: feature_value } as ExperimentalFeaturesModel;
|
||||||
setFeatures(updatedFeatures);
|
setFeatures(updatedFeatures);
|
||||||
const response = await dataProvider.updateFeatures(record.id, updatedFeatures);
|
await dataProvider.updateFeatures(record.id, updatedFeatures);
|
||||||
notify("ra.notification.updated", {
|
notify("ra.notification.updated", {
|
||||||
messageArgs: { smart_count: 1 },
|
messageArgs: { smart_count: 1 },
|
||||||
type: "success",
|
type: "success",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { Avatar, Box, Link, Typography } from "@mui/material";
|
import { Avatar, Box, Link } from "@mui/material";
|
||||||
import { useTheme } from "@mui/material/styles";
|
import { useTheme } from "@mui/material/styles";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Stack, Typography } from "@mui/material";
|
import { Stack, Typography } from "@mui/material";
|
||||||
import { TextField } from "@mui/material";
|
import { TextField } from "@mui/material";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useDataProvider, useNotify, useRecordContext, useTranslate } from "react-admin";
|
import { useDataProvider, useRecordContext, useTranslate } from "react-admin";
|
||||||
import { useFormContext } from "react-hook-form";
|
import { useFormContext } from "react-hook-form";
|
||||||
|
|
||||||
const RateLimitRow = ({
|
const RateLimitRow = ({
|
||||||
@ -10,8 +10,8 @@ const RateLimitRow = ({
|
|||||||
updateRateLimit,
|
updateRateLimit,
|
||||||
}: {
|
}: {
|
||||||
limit: string;
|
limit: string;
|
||||||
value: any;
|
value: object;
|
||||||
updateRateLimit: (limit: string, value: any) => void;
|
updateRateLimit: (limit: string, value: integer | null) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const translate = useTranslate();
|
const translate = useTranslate();
|
||||||
|
|
||||||
@ -53,8 +53,6 @@ const RateLimitRow = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
const UserRateLimits = () => {
|
const UserRateLimits = () => {
|
||||||
const translate = useTranslate();
|
|
||||||
const notify = useNotify();
|
|
||||||
const record = useRecordContext();
|
const record = useRecordContext();
|
||||||
const form = useFormContext();
|
const form = useFormContext();
|
||||||
const dataProvider = useDataProvider();
|
const dataProvider = useDataProvider();
|
||||||
@ -78,7 +76,7 @@ const UserRateLimits = () => {
|
|||||||
fetchRateLimits();
|
fetchRateLimits();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const updateRateLimit = async (limit: string, value: any) => {
|
const updateRateLimit = async (limit: string, value: integer | null) => {
|
||||||
const updatedRateLimits = { ...rateLimits, [limit]: value };
|
const updatedRateLimits = { ...rateLimits, [limit]: value };
|
||||||
setRateLimits(updatedRateLimits);
|
setRateLimits(updatedRateLimits);
|
||||||
form.setValue(`rates.${limit}`, value, { shouldDirty: true });
|
form.setValue(`rates.${limit}`, value, { shouldDirty: true });
|
||||||
|
@ -5,7 +5,7 @@ import { ServerProcessResponse } from "../../synapse/dataProvider";
|
|||||||
import { getTimeSince } from "../../utils/date";
|
import { getTimeSince } from "../../utils/date";
|
||||||
|
|
||||||
const CurrentlyRunningCommand = () => {
|
const CurrentlyRunningCommand = () => {
|
||||||
const [serverProcess, setServerProcess] = useStore<ServerProcessResponse>("serverProcess", {
|
const [serverProcess, _setServerProcess] = useStore<ServerProcessResponse>("serverProcess", {
|
||||||
command: "",
|
command: "",
|
||||||
locked_at: "",
|
locked_at: "",
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import RestoreIcon from "@mui/icons-material/Restore";
|
import RestoreIcon from "@mui/icons-material/Restore";
|
||||||
import ScheduleIcon from "@mui/icons-material/Schedule";
|
import ScheduleIcon from "@mui/icons-material/Schedule";
|
||||||
import { Box, Typography, Link, Divider } from "@mui/material";
|
import { Box, Typography, Link } from "@mui/material";
|
||||||
import { Stack } from "@mui/material";
|
import { Stack } from "@mui/material";
|
||||||
|
|
||||||
import CurrentlyRunningCommand from "./CurrentlyRunningCommand";
|
import CurrentlyRunningCommand from "./CurrentlyRunningCommand";
|
||||||
|
@ -23,6 +23,7 @@ import { ServerCommand, ServerProcessResponse } from "../../synapse/dataProvider
|
|||||||
import { Icons } from "../../utils/icons";
|
import { Icons } from "../../utils/icons";
|
||||||
|
|
||||||
const renderIcon = (icon: string) => {
|
const renderIcon = (icon: string) => {
|
||||||
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
||||||
const IconComponent = Icons[icon] as React.ComponentType<any> | undefined;
|
const IconComponent = Icons[icon] as React.ComponentType<any> | undefined;
|
||||||
return IconComponent ? <IconComponent sx={{ verticalAlign: "middle", mr: 1 }} /> : null;
|
return IconComponent ? <IconComponent sx={{ verticalAlign: "middle", mr: 1 }} /> : null;
|
||||||
};
|
};
|
||||||
@ -80,6 +81,7 @@ const ServerCommandsPanel = () => {
|
|||||||
// Update server process status
|
// Update server process status
|
||||||
await updateServerProcessStatus(serverCommands[command]);
|
await updateServerProcessStatus(serverCommands[command]);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error("Error running command:", error);
|
||||||
setCommandIsRunning(false);
|
setCommandIsRunning(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -33,7 +33,7 @@ const useServerNotifications = () => {
|
|||||||
notifications: [],
|
notifications: [],
|
||||||
success: false,
|
success: false,
|
||||||
});
|
});
|
||||||
const [serverProcess, setServerProcess] = useStore<ServerProcessResponse>("serverProcess", {
|
const [serverProcess, _setServerProcess] = useStore<ServerProcessResponse>("serverProcess", {
|
||||||
command: "",
|
command: "",
|
||||||
locked_at: "",
|
locked_at: "",
|
||||||
});
|
});
|
||||||
|
@ -59,11 +59,11 @@ const useServerStatus = () => {
|
|||||||
host: "",
|
host: "",
|
||||||
results: [],
|
results: [],
|
||||||
});
|
});
|
||||||
const [serverProcess, setServerProcess] = useStore<ServerProcessResponse>("serverProcess", {
|
const [serverProcess, _setServerProcess] = useStore<ServerProcessResponse>("serverProcess", {
|
||||||
command: "",
|
command: "",
|
||||||
locked_at: "",
|
locked_at: "",
|
||||||
});
|
});
|
||||||
const { command, locked_at } = serverProcess;
|
const { command } = serverProcess;
|
||||||
const { etkeccAdmin } = useAppContext();
|
const { etkeccAdmin } = useAppContext();
|
||||||
const dataProvider = useDataProvider();
|
const dataProvider = useDataProvider();
|
||||||
const isOkay = serverStatus.ok;
|
const isOkay = serverStatus.ok;
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
import CheckIcon from "@mui/icons-material/Check";
|
import CheckIcon from "@mui/icons-material/Check";
|
||||||
import CloseIcon from "@mui/icons-material/Close";
|
import CloseIcon from "@mui/icons-material/Close";
|
||||||
import EngineeringIcon from "@mui/icons-material/Engineering";
|
import EngineeringIcon from "@mui/icons-material/Engineering";
|
||||||
import { Alert, Box, Stack, Typography, Paper, Link, Chip, Divider, Tooltip, ChipProps } from "@mui/material";
|
import { Box, Stack, Typography, Paper, Link, Chip, Divider, ChipProps } from "@mui/material";
|
||||||
import { useStore } from "ra-core";
|
import { useStore } from "ra-core";
|
||||||
|
|
||||||
import CurrentlyRunningCommand from "./CurrentlyRunningCommand";
|
import CurrentlyRunningCommand from "./CurrentlyRunningCommand";
|
||||||
import { ServerProcessResponse, ServerStatusComponent, ServerStatusResponse } from "../../synapse/dataProvider";
|
import { ServerProcessResponse, ServerStatusComponent, ServerStatusResponse } from "../../synapse/dataProvider";
|
||||||
import { getTimeSince } from "../../utils/date";
|
|
||||||
|
|
||||||
const StatusChip = ({
|
const StatusChip = ({
|
||||||
isOkay,
|
isOkay,
|
||||||
@ -40,17 +39,17 @@ const ServerComponentText = ({ text }: { text: string }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const ServerStatusPage = () => {
|
const ServerStatusPage = () => {
|
||||||
const [serverStatus, setServerStatus] = useStore<ServerStatusResponse>("serverStatus", {
|
const [serverStatus, _setServerStatus] = useStore<ServerStatusResponse>("serverStatus", {
|
||||||
ok: false,
|
ok: false,
|
||||||
success: false,
|
success: false,
|
||||||
host: "",
|
host: "",
|
||||||
results: [],
|
results: [],
|
||||||
});
|
});
|
||||||
const [serverProcess, setServerProcess] = useStore<ServerProcessResponse>("serverProcess", {
|
const [serverProcess, _setServerProcess] = useStore<ServerProcessResponse>("serverProcess", {
|
||||||
command: "",
|
command: "",
|
||||||
locked_at: "",
|
locked_at: "",
|
||||||
});
|
});
|
||||||
const { command, locked_at } = serverProcess;
|
const { command } = serverProcess;
|
||||||
const successCheck = serverStatus.success;
|
const successCheck = serverStatus.success;
|
||||||
const isOkay = serverStatus.ok;
|
const isOkay = serverStatus.ok;
|
||||||
const host = serverStatus.host;
|
const host = serverStatus.host;
|
||||||
@ -104,7 +103,7 @@ const ServerStatusPage = () => {
|
|||||||
</Typography>
|
</Typography>
|
||||||
|
|
||||||
<Stack spacing={2} direction="row">
|
<Stack spacing={2} direction="row">
|
||||||
{Object.keys(groupedResults).map((category, idx) => (
|
{Object.keys(groupedResults).map((category, _idx) => (
|
||||||
<Box key={`category_${category}`} sx={{ flex: 1 }}>
|
<Box key={`category_${category}`} sx={{ flex: 1 }}>
|
||||||
<Typography variant="h5" mb={1}>
|
<Typography variant="h5" mb={1}>
|
||||||
{category}
|
{category}
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
const transformCommandsToChoices = (commands: Record<string, any>) => {
|
|
||||||
return Object.entries(commands).map(([key, value]) => ({
|
|
||||||
id: key,
|
|
||||||
name: value.name,
|
|
||||||
description: value.description,
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
|
|
||||||
const ScheduledCommandCreate = () => {
|
|
||||||
const commandChoices = transformCommandsToChoices(serverCommands);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<SimpleForm>
|
|
||||||
<SelectInput
|
|
||||||
source="command"
|
|
||||||
choices={commandChoices}
|
|
||||||
optionText={choice => `${choice.name} - ${choice.description}`}
|
|
||||||
/>
|
|
||||||
</SimpleForm>
|
|
||||||
);
|
|
||||||
};
|
|
@ -22,6 +22,7 @@ import { RecurringCommand } from "../../../../../synapse/dataProvider";
|
|||||||
import { useServerCommands } from "../../../hooks/useServerCommands";
|
import { useServerCommands } from "../../../hooks/useServerCommands";
|
||||||
import { useRecurringCommands } from "../../hooks/useRecurringCommands";
|
import { useRecurringCommands } from "../../hooks/useRecurringCommands";
|
||||||
|
|
||||||
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
||||||
const transformCommandsToChoices = (commands: Record<string, any>) => {
|
const transformCommandsToChoices = (commands: Record<string, any>) => {
|
||||||
return Object.entries(commands).map(([key, value]) => ({
|
return Object.entries(commands).map(([key, value]) => ({
|
||||||
id: key,
|
id: key,
|
||||||
@ -111,13 +112,11 @@ const RecurringCommandEdit = () => {
|
|||||||
delete submissionData.args;
|
delete submissionData.args;
|
||||||
}
|
}
|
||||||
|
|
||||||
let result;
|
|
||||||
|
|
||||||
if (isCreating) {
|
if (isCreating) {
|
||||||
result = await dataProvider.createRecurringCommand(etkeccAdmin, submissionData);
|
await dataProvider.createRecurringCommand(etkeccAdmin, submissionData);
|
||||||
notify("recurring_commands.action.create_success", { type: "success" });
|
notify("recurring_commands.action.create_success", { type: "success" });
|
||||||
} else {
|
} else {
|
||||||
result = await dataProvider.updateRecurringCommand(etkeccAdmin, {
|
await dataProvider.updateRecurringCommand(etkeccAdmin, {
|
||||||
...submissionData,
|
...submissionData,
|
||||||
id: id,
|
id: id,
|
||||||
});
|
});
|
||||||
@ -129,6 +128,7 @@ const RecurringCommandEdit = () => {
|
|||||||
|
|
||||||
navigate("/server_actions");
|
navigate("/server_actions");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.error("Error saving recurring command:", error);
|
||||||
notify("recurring_commands.action.update_failure", { type: "error" });
|
notify("recurring_commands.action.update_failure", { type: "error" });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -21,7 +21,7 @@ const ListActions = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const RecurringCommandsList = () => {
|
const RecurringCommandsList = () => {
|
||||||
const { data, isLoading, error } = useRecurringCommands();
|
const { data, isLoading } = useRecurringCommands();
|
||||||
|
|
||||||
const listContext = useList({
|
const listContext = useList({
|
||||||
resource: "recurring",
|
resource: "recurring",
|
||||||
@ -40,6 +40,7 @@ const RecurringCommandsList = () => {
|
|||||||
<Paper>
|
<Paper>
|
||||||
<Datagrid
|
<Datagrid
|
||||||
bulkActionButtons={false}
|
bulkActionButtons={false}
|
||||||
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
||||||
rowClick={(id: Identifier, resource: string, record: any) => {
|
rowClick={(id: Identifier, resource: string, record: any) => {
|
||||||
if (!record) {
|
if (!record) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -11,7 +11,6 @@ import {
|
|||||||
useDataProvider,
|
useDataProvider,
|
||||||
Loading,
|
Loading,
|
||||||
Button,
|
Button,
|
||||||
BooleanInput,
|
|
||||||
SelectInput,
|
SelectInput,
|
||||||
} from "react-admin";
|
} from "react-admin";
|
||||||
import { useWatch } from "react-hook-form";
|
import { useWatch } from "react-hook-form";
|
||||||
@ -23,6 +22,7 @@ import { ScheduledCommand } from "../../../../../synapse/dataProvider";
|
|||||||
import { useServerCommands } from "../../../hooks/useServerCommands";
|
import { useServerCommands } from "../../../hooks/useServerCommands";
|
||||||
import { useScheduledCommands } from "../../hooks/useScheduledCommands";
|
import { useScheduledCommands } from "../../hooks/useScheduledCommands";
|
||||||
|
|
||||||
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
||||||
const transformCommandsToChoices = (commands: Record<string, any>) => {
|
const transformCommandsToChoices = (commands: Record<string, any>) => {
|
||||||
return Object.entries(commands).map(([key, value]) => ({
|
return Object.entries(commands).map(([key, value]) => ({
|
||||||
id: key,
|
id: key,
|
||||||
@ -50,7 +50,7 @@ const ScheduledCommandEdit = () => {
|
|||||||
const isCreating = typeof id === "undefined";
|
const isCreating = typeof id === "undefined";
|
||||||
const [loading, setLoading] = useState(!isCreating);
|
const [loading, setLoading] = useState(!isCreating);
|
||||||
const { data: scheduledCommands, isLoading: isLoadingList } = useScheduledCommands();
|
const { data: scheduledCommands, isLoading: isLoadingList } = useScheduledCommands();
|
||||||
const { serverCommands, isLoading: isLoadingServerCommands } = useServerCommands();
|
const { serverCommands } = useServerCommands();
|
||||||
const pageTitle = isCreating ? "Create Scheduled Command" : "Edit Scheduled Command";
|
const pageTitle = isCreating ? "Create Scheduled Command" : "Edit Scheduled Command";
|
||||||
|
|
||||||
const commandChoices = transformCommandsToChoices(serverCommands);
|
const commandChoices = transformCommandsToChoices(serverCommands);
|
||||||
@ -67,15 +67,12 @@ const ScheduledCommandEdit = () => {
|
|||||||
|
|
||||||
const handleSubmit = async data => {
|
const handleSubmit = async data => {
|
||||||
try {
|
try {
|
||||||
let result;
|
|
||||||
|
|
||||||
data.scheduled_at = new Date(data.scheduled_at).toISOString();
|
data.scheduled_at = new Date(data.scheduled_at).toISOString();
|
||||||
|
|
||||||
if (isCreating) {
|
if (isCreating) {
|
||||||
result = await dataProvider.createScheduledCommand(etkeccAdmin, data);
|
await dataProvider.createScheduledCommand(etkeccAdmin, data);
|
||||||
notify("scheduled_commands.action.create_success", { type: "success" });
|
notify("scheduled_commands.action.create_success", { type: "success" });
|
||||||
} else {
|
} else {
|
||||||
result = await dataProvider.updateScheduledCommand(etkeccAdmin, {
|
await dataProvider.updateScheduledCommand(etkeccAdmin, {
|
||||||
...data,
|
...data,
|
||||||
id: id,
|
id: id,
|
||||||
});
|
});
|
||||||
@ -84,6 +81,7 @@ const ScheduledCommandEdit = () => {
|
|||||||
|
|
||||||
navigate("/server_actions");
|
navigate("/server_actions");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.log("Error saving scheduled command:", error);
|
||||||
notify("scheduled_commands.action.update_failure", { type: "error" });
|
notify("scheduled_commands.action.update_failure", { type: "error" });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -4,8 +4,6 @@ import { useState, useEffect } from "react";
|
|||||||
import {
|
import {
|
||||||
Loading,
|
Loading,
|
||||||
Button,
|
Button,
|
||||||
useDataProvider,
|
|
||||||
useNotify,
|
|
||||||
SimpleShowLayout,
|
SimpleShowLayout,
|
||||||
TextField,
|
TextField,
|
||||||
BooleanField,
|
BooleanField,
|
||||||
@ -15,7 +13,6 @@ import {
|
|||||||
import { useParams, useNavigate } from "react-router-dom";
|
import { useParams, useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
import ScheduledDeleteButton from "./ScheduledDeleteButton";
|
import ScheduledDeleteButton from "./ScheduledDeleteButton";
|
||||||
import { useAppContext } from "../../../../../Context";
|
|
||||||
import { ScheduledCommand } from "../../../../../synapse/dataProvider";
|
import { ScheduledCommand } from "../../../../../synapse/dataProvider";
|
||||||
import { useScheduledCommands } from "../../hooks/useScheduledCommands";
|
import { useScheduledCommands } from "../../hooks/useScheduledCommands";
|
||||||
|
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
import AddIcon from "@mui/icons-material/Add";
|
import AddIcon from "@mui/icons-material/Add";
|
||||||
import { Paper } from "@mui/material";
|
import { Paper } from "@mui/material";
|
||||||
import { Loading, Button, useNotify, useRefresh, useCreatePath, useRecordContext } from "react-admin";
|
import { Loading, Button } from "react-admin";
|
||||||
import { ResourceContextProvider, useList } from "react-admin";
|
import { ResourceContextProvider, useList } from "react-admin";
|
||||||
import { ListContextProvider, TextField } from "react-admin";
|
import { ListContextProvider, TextField } from "react-admin";
|
||||||
import { Datagrid } from "react-admin";
|
import { Datagrid } from "react-admin";
|
||||||
import { BooleanField, DateField, TopToolbar } from "react-admin";
|
import { BooleanField, DateField, TopToolbar } from "react-admin";
|
||||||
import { useDataProvider } from "react-admin";
|
|
||||||
import { Identifier } from "react-admin";
|
import { Identifier } from "react-admin";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
|
|
||||||
import { useAppContext } from "../../../../../Context";
|
|
||||||
import { DATE_FORMAT } from "../../../../../utils/date";
|
import { DATE_FORMAT } from "../../../../../utils/date";
|
||||||
import { useScheduledCommands } from "../../hooks/useScheduledCommands";
|
import { useScheduledCommands } from "../../hooks/useScheduledCommands";
|
||||||
const ListActions = () => {
|
const ListActions = () => {
|
||||||
@ -27,7 +25,7 @@ const ListActions = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const ScheduledCommandsList = () => {
|
const ScheduledCommandsList = () => {
|
||||||
const { data, isLoading, error } = useScheduledCommands();
|
const { data, isLoading } = useScheduledCommands();
|
||||||
|
|
||||||
const listContext = useList({
|
const listContext = useList({
|
||||||
resource: "scheduled",
|
resource: "scheduled",
|
||||||
@ -46,6 +44,7 @@ const ScheduledCommandsList = () => {
|
|||||||
<Paper>
|
<Paper>
|
||||||
<Datagrid
|
<Datagrid
|
||||||
bulkActionButtons={false}
|
bulkActionButtons={false}
|
||||||
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
||||||
rowClick={(id: Identifier, resource: string, record: any) => {
|
rowClick={(id: Identifier, resource: string, record: any) => {
|
||||||
if (!record) {
|
if (!record) {
|
||||||
return "";
|
return "";
|
||||||
|
@ -7,16 +7,7 @@ import DownloadingIcon from "@mui/icons-material/Downloading";
|
|||||||
import FileOpenIcon from "@mui/icons-material/FileOpen";
|
import FileOpenIcon from "@mui/icons-material/FileOpen";
|
||||||
import LockIcon from "@mui/icons-material/Lock";
|
import LockIcon from "@mui/icons-material/Lock";
|
||||||
import LockOpenIcon from "@mui/icons-material/LockOpen";
|
import LockOpenIcon from "@mui/icons-material/LockOpen";
|
||||||
import {
|
import { Box, Dialog, DialogContent, DialogContentText, DialogTitle, Tooltip } from "@mui/material";
|
||||||
Grid2 as Grid,
|
|
||||||
Box,
|
|
||||||
Dialog,
|
|
||||||
DialogContent,
|
|
||||||
DialogContentText,
|
|
||||||
DialogTitle,
|
|
||||||
Tooltip,
|
|
||||||
Link,
|
|
||||||
} from "@mui/material";
|
|
||||||
import { alpha, useTheme } from "@mui/material/styles";
|
import { alpha, useTheme } from "@mui/material/styles";
|
||||||
import { useMutation } from "@tanstack/react-query";
|
import { useMutation } from "@tanstack/react-query";
|
||||||
import { get } from "lodash";
|
import { get } from "lodash";
|
||||||
@ -149,7 +140,6 @@ const PurgeRemoteMediaDialog = ({ open, onClose, onSubmit }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const PurgeRemoteMediaButton = (props: ButtonProps) => {
|
export const PurgeRemoteMediaButton = (props: ButtonProps) => {
|
||||||
const theme = useTheme();
|
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const notify = useNotify();
|
const notify = useNotify();
|
||||||
const dataProvider = useDataProvider<SynapseDataProvider>();
|
const dataProvider = useDataProvider<SynapseDataProvider>();
|
||||||
|
@ -3,7 +3,7 @@ import { CardContent, CardHeader, Container } from "@mui/material";
|
|||||||
import { useTranslate } from "ra-core";
|
import { useTranslate } from "ra-core";
|
||||||
import { ChangeEventHandler } from "react";
|
import { ChangeEventHandler } from "react";
|
||||||
|
|
||||||
import { ParsedStats, Progress } from "./types";
|
import { ImportResult, ParsedStats, Progress } from "./types";
|
||||||
|
|
||||||
const TranslatableOption = ({ value, text }: { value: string; text: string }) => {
|
const TranslatableOption = ({ value, text }: { value: string; text: string }) => {
|
||||||
const translate = useTranslate();
|
const translate = useTranslate();
|
||||||
@ -18,7 +18,7 @@ const ConflictModeCard = ({
|
|||||||
progress,
|
progress,
|
||||||
}: {
|
}: {
|
||||||
stats: ParsedStats | null;
|
stats: ParsedStats | null;
|
||||||
importResults: any;
|
importResults: ImportResult | null;
|
||||||
onConflictModeChanged: ChangeEventHandler<HTMLSelectElement>;
|
onConflictModeChanged: ChangeEventHandler<HTMLSelectElement>;
|
||||||
conflictMode: string;
|
conflictMode: string;
|
||||||
progress: Progress;
|
progress: Progress;
|
||||||
|
@ -5,7 +5,7 @@ import { Checkbox } from "@mui/material";
|
|||||||
import { useTranslate } from "ra-core";
|
import { useTranslate } from "ra-core";
|
||||||
import { ChangeEventHandler } from "react";
|
import { ChangeEventHandler } from "react";
|
||||||
|
|
||||||
import { ParsedStats, Progress } from "./types";
|
import { ImportResult, ParsedStats, Progress } from "./types";
|
||||||
|
|
||||||
const StatsCard = ({
|
const StatsCard = ({
|
||||||
stats,
|
stats,
|
||||||
@ -18,7 +18,7 @@ const StatsCard = ({
|
|||||||
}: {
|
}: {
|
||||||
stats: ParsedStats | null;
|
stats: ParsedStats | null;
|
||||||
progress: Progress;
|
progress: Progress;
|
||||||
importResults: any;
|
importResults: ImportResult | null;
|
||||||
useridMode: string;
|
useridMode: string;
|
||||||
passwordMode: boolean;
|
passwordMode: boolean;
|
||||||
onUseridModeChanged: ChangeEventHandler<HTMLSelectElement>;
|
onUseridModeChanged: ChangeEventHandler<HTMLSelectElement>;
|
||||||
|
@ -2,14 +2,14 @@ import { CardHeader, CardContent, Container, Link, Stack, Typography, Paper } fr
|
|||||||
import { useTranslate } from "ra-core";
|
import { useTranslate } from "ra-core";
|
||||||
import { ChangeEventHandler } from "react";
|
import { ChangeEventHandler } from "react";
|
||||||
|
|
||||||
import { Progress } from "./types";
|
import { ImportResult, Progress } from "./types";
|
||||||
|
|
||||||
const UploadCard = ({
|
const UploadCard = ({
|
||||||
importResults,
|
importResults,
|
||||||
onFileChange,
|
onFileChange,
|
||||||
progress,
|
progress,
|
||||||
}: {
|
}: {
|
||||||
importResults: any;
|
importResults: ImportResult | null;
|
||||||
onFileChange: ChangeEventHandler<HTMLInputElement>;
|
onFileChange: ChangeEventHandler<HTMLInputElement>;
|
||||||
progress: Progress;
|
progress: Progress;
|
||||||
}) => {
|
}) => {
|
||||||
|
@ -273,7 +273,7 @@ const useImportFile = () => {
|
|||||||
let retries = 0;
|
let retries = 0;
|
||||||
const submitRecord = async (recordData: ImportLine) => {
|
const submitRecord = async (recordData: ImportLine) => {
|
||||||
try {
|
try {
|
||||||
const response = await dataProvider.getOne("users", { id: recordData.id });
|
await dataProvider.getOne("users", { id: recordData.id });
|
||||||
|
|
||||||
if (LOGGING) console.log("already existed");
|
if (LOGGING) console.log("already existed");
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { render, screen } from "@testing-library/react";
|
import { act, render, screen } from "@testing-library/react";
|
||||||
import polyglotI18nProvider from "ra-i18n-polyglot";
|
import polyglotI18nProvider from "ra-i18n-polyglot";
|
||||||
import { AdminContext } from "react-admin";
|
import { AdminContext } from "react-admin";
|
||||||
|
|
||||||
@ -7,7 +7,6 @@ import { AppContext } from "../Context";
|
|||||||
import englishMessages from "../i18n/en";
|
import englishMessages from "../i18n/en";
|
||||||
|
|
||||||
const i18nProvider = polyglotI18nProvider(() => englishMessages, "en", [{ locale: "en", name: "English" }]);
|
const i18nProvider = polyglotI18nProvider(() => englishMessages, "en", [{ locale: "en", name: "English" }]);
|
||||||
import { act } from "@testing-library/react";
|
|
||||||
|
|
||||||
describe("LoginForm", () => {
|
describe("LoginForm", () => {
|
||||||
it("renders with no restriction to homeserver", async () => {
|
it("renders with no restriction to homeserver", async () => {
|
||||||
|
@ -161,14 +161,14 @@ const LoginPage = () => {
|
|||||||
try {
|
try {
|
||||||
const serverVersion = await getServerVersion(url);
|
const serverVersion = await getServerVersion(url);
|
||||||
setServerVersion(`${translate("synapseadmin.auth.server_version")} ${serverVersion}`);
|
setServerVersion(`${translate("synapseadmin.auth.server_version")} ${serverVersion}`);
|
||||||
} catch (error) {
|
} catch {
|
||||||
setServerVersion("");
|
setServerVersion("");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const features = await getSupportedFeatures(url);
|
const features = await getSupportedFeatures(url);
|
||||||
setMatrixVersions(`${translate("synapseadmin.auth.supports_specs")} ${features.versions.join(", ")}`);
|
setMatrixVersions(`${translate("synapseadmin.auth.supports_specs")} ${features.versions.join(", ")}`);
|
||||||
} catch (error) {
|
} catch {
|
||||||
setMatrixVersions("");
|
setMatrixVersions("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ const LoginPage = () => {
|
|||||||
const supportSSO = loginFlows.find(f => f.type === "m.login.sso") !== undefined;
|
const supportSSO = loginFlows.find(f => f.type === "m.login.sso") !== undefined;
|
||||||
setSupportPassAuth(supportPass);
|
setSupportPassAuth(supportPass);
|
||||||
setSSOBaseUrl(supportSSO ? url : "");
|
setSSOBaseUrl(supportSSO ? url : "");
|
||||||
} catch (error) {
|
} catch {
|
||||||
setSupportPassAuth(false);
|
setSupportPassAuth(false);
|
||||||
setSSOBaseUrl("");
|
setSSOBaseUrl("");
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,6 @@ const destinationFieldRender = (record: RaRecord) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const DestinationList = (props: ListProps) => {
|
export const DestinationList = (props: ListProps) => {
|
||||||
const record = useRecordContext(props);
|
|
||||||
return (
|
return (
|
||||||
<List
|
<List
|
||||||
{...props}
|
{...props}
|
||||||
|
@ -3,7 +3,6 @@ import {
|
|||||||
BooleanInput,
|
BooleanInput,
|
||||||
Create,
|
Create,
|
||||||
CreateProps,
|
CreateProps,
|
||||||
Datagrid,
|
|
||||||
DatagridConfigurable,
|
DatagridConfigurable,
|
||||||
DateField,
|
DateField,
|
||||||
DateTimeInput,
|
DateTimeInput,
|
||||||
|
@ -2,7 +2,6 @@ import PageviewIcon from "@mui/icons-material/Pageview";
|
|||||||
import ViewListIcon from "@mui/icons-material/ViewList";
|
import ViewListIcon from "@mui/icons-material/ViewList";
|
||||||
import ReportIcon from "@mui/icons-material/Warning";
|
import ReportIcon from "@mui/icons-material/Warning";
|
||||||
import {
|
import {
|
||||||
Datagrid,
|
|
||||||
DatagridConfigurable,
|
DatagridConfigurable,
|
||||||
DateField,
|
DateField,
|
||||||
DeleteButton,
|
DeleteButton,
|
||||||
|
@ -119,14 +119,10 @@ export const MakeAdminBtn = () => {
|
|||||||
|
|
||||||
const { mutate, isPending } = useMutation({
|
const { mutate, isPending } = useMutation({
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
try {
|
|
||||||
const result = await dataProvider.makeRoomAdmin(record.room_id, userIdValue);
|
const result = await dataProvider.makeRoomAdmin(record.room_id, userIdValue);
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
throw new Error(result.error);
|
throw new Error(result.error);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
notify("resources.rooms.action.make_admin.success", { type: "success" });
|
notify("resources.rooms.action.make_admin.success", { type: "success" });
|
||||||
@ -203,7 +199,6 @@ export const MakeAdminBtn = () => {
|
|||||||
|
|
||||||
export const RoomShow = (props: ShowProps) => {
|
export const RoomShow = (props: ShowProps) => {
|
||||||
const translate = useTranslate();
|
const translate = useTranslate();
|
||||||
const record = useRecordContext();
|
|
||||||
return (
|
return (
|
||||||
<Show {...props} actions={<RoomShowActions />} title={<RoomTitle />}>
|
<Show {...props} actions={<RoomShowActions />} title={<RoomTitle />}>
|
||||||
<TabbedShowLayout>
|
<TabbedShowLayout>
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import PermMediaIcon from "@mui/icons-material/PermMedia";
|
import PermMediaIcon from "@mui/icons-material/PermMedia";
|
||||||
import {
|
import {
|
||||||
Datagrid,
|
|
||||||
DatagridConfigurable,
|
DatagridConfigurable,
|
||||||
ExportButton,
|
ExportButton,
|
||||||
List,
|
List,
|
||||||
|
@ -219,13 +219,12 @@ export const UserList = (props: ListProps) => (
|
|||||||
// here only local part of user_id
|
// here only local part of user_id
|
||||||
// maxLength = 255 - "@" - ":" - storage.getItem("home_server").length
|
// maxLength = 255 - "@" - ":" - storage.getItem("home_server").length
|
||||||
// storage.getItem("home_server").length is not valid here
|
// storage.getItem("home_server").length is not valid here
|
||||||
const validateUser = [required(), maxLength(253), regex(/^[a-z0-9._=\-\+/]+$/, "synapseadmin.users.invalid_user_id")];
|
const validateUser = [required(), maxLength(253), regex(/^[a-z0-9._=\-+/]+$/, "synapseadmin.users.invalid_user_id")];
|
||||||
|
|
||||||
const validateAddress = [required(), maxLength(255)];
|
const validateAddress = [required(), maxLength(255)];
|
||||||
|
|
||||||
const UserEditActions = () => {
|
const UserEditActions = () => {
|
||||||
const record = useRecordContext();
|
const record = useRecordContext();
|
||||||
const translate = useTranslate();
|
|
||||||
const ownUserId = localStorage.getItem("user_id");
|
const ownUserId = localStorage.getItem("user_id");
|
||||||
let ownUserIsSelected = false;
|
let ownUserIsSelected = false;
|
||||||
let asManagedUserIsSelected = false;
|
let asManagedUserIsSelected = false;
|
||||||
@ -262,6 +261,7 @@ export const UserCreate = (props: CreateProps) => {
|
|||||||
const [userAvailabilityEl, setUserAvailabilityEl] = useState<React.ReactElement | false>(
|
const [userAvailabilityEl, setUserAvailabilityEl] = useState<React.ReactElement | false>(
|
||||||
<Typography component="span"></Typography>
|
<Typography component="span"></Typography>
|
||||||
);
|
);
|
||||||
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
||||||
const [formData, setFormData] = useState<Record<string, any>>({});
|
const [formData, setFormData] = useState<Record<string, any>>({});
|
||||||
const [create] = useCreate();
|
const [create] = useCreate();
|
||||||
|
|
||||||
@ -284,6 +284,7 @@ export const UserCreate = (props: CreateProps) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
||||||
const postSave = (data: Record<string, any>) => {
|
const postSave = (data: Record<string, any>) => {
|
||||||
setFormData(data);
|
setFormData(data);
|
||||||
if (!userIsAvailable) {
|
if (!userIsAvailable) {
|
||||||
|
@ -17,6 +17,7 @@ import { GetConfig } from "../utils/config";
|
|||||||
import { MatrixError, displayError } from "../utils/error";
|
import { MatrixError, displayError } from "../utils/error";
|
||||||
import { returnMXID } from "../utils/mxid";
|
import { returnMXID } from "../utils/mxid";
|
||||||
|
|
||||||
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
||||||
const CACHED_MANY_REF: Record<string, any> = {};
|
const CACHED_MANY_REF: Record<string, any> = {};
|
||||||
|
|
||||||
// Adds the access token to all requests
|
// Adds the access token to all requests
|
||||||
@ -33,7 +34,7 @@ const jsonClient = async (url: string, options: Options = {}) => {
|
|||||||
try {
|
try {
|
||||||
const response = await fetchUtils.fetchJson(url, options);
|
const response = await fetchUtils.fetchJson(url, options);
|
||||||
return response;
|
return response;
|
||||||
} catch (err: any) {
|
} catch (err) {
|
||||||
const error = err as HttpError;
|
const error = err as HttpError;
|
||||||
const errorStatus = error.status;
|
const errorStatus = error.status;
|
||||||
const errorBody = error.body as MatrixError;
|
const errorBody = error.body as MatrixError;
|
||||||
@ -45,16 +46,11 @@ const jsonClient = async (url: string, options: Options = {}) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
||||||
const filterUndefined = (obj: Record<string, any>) => {
|
const filterUndefined = (obj: Record<string, any>) => {
|
||||||
return Object.fromEntries(Object.entries(obj).filter(([key, value]) => value !== undefined));
|
return Object.fromEntries(Object.entries(obj).filter(([_key, value]) => value !== undefined));
|
||||||
};
|
};
|
||||||
|
|
||||||
interface Action {
|
|
||||||
endpoint: string;
|
|
||||||
method?: string;
|
|
||||||
body?: Record<string, any>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Room {
|
export interface Room {
|
||||||
room_id: string;
|
room_id: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
@ -990,7 +986,7 @@ const baseDataProvider: SynapseDataProvider = {
|
|||||||
},
|
},
|
||||||
setRateLimits: async (id: Identifier, rateLimits: RateLimitsModel) => {
|
setRateLimits: async (id: Identifier, rateLimits: RateLimitsModel) => {
|
||||||
const filtered = Object.entries(rateLimits)
|
const filtered = Object.entries(rateLimits)
|
||||||
.filter(([key, value]) => value !== null && value !== undefined)
|
.filter(([_key, value]) => value !== null && value !== undefined)
|
||||||
.reduce((obj, [key, value]) => {
|
.reduce((obj, [key, value]) => {
|
||||||
obj[key] = value;
|
obj[key] = value;
|
||||||
return obj;
|
return obj;
|
||||||
@ -1023,7 +1019,7 @@ const baseDataProvider: SynapseDataProvider = {
|
|||||||
|
|
||||||
const endpoint_url = `${base_url}/_synapse/admin/v1/rooms/${encodeURIComponent(room_id)}/make_room_admin`;
|
const endpoint_url = `${base_url}/_synapse/admin/v1/rooms/${encodeURIComponent(room_id)}/make_room_admin`;
|
||||||
try {
|
try {
|
||||||
const { json } = await jsonClient(endpoint_url, { method: "POST", body: JSON.stringify({ user_id }) });
|
await jsonClient(endpoint_url, { method: "POST", body: JSON.stringify({ user_id }) });
|
||||||
return { success: true };
|
return { success: true };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof HttpError) {
|
if (error instanceof HttpError) {
|
||||||
@ -1036,7 +1032,7 @@ const baseDataProvider: SynapseDataProvider = {
|
|||||||
const base_url = localStorage.getItem("base_url");
|
const base_url = localStorage.getItem("base_url");
|
||||||
const endpoint_url = `${base_url}/_synapse/admin/v1/suspend/${encodeURIComponent(returnMXID(id))}`;
|
const endpoint_url = `${base_url}/_synapse/admin/v1/suspend/${encodeURIComponent(returnMXID(id))}`;
|
||||||
try {
|
try {
|
||||||
const { json } = await jsonClient(endpoint_url, {
|
await jsonClient(endpoint_url, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
body: JSON.stringify({ suspend: suspendValue }),
|
body: JSON.stringify({ suspend: suspendValue }),
|
||||||
});
|
});
|
||||||
@ -1211,7 +1207,7 @@ const baseDataProvider: SynapseDataProvider = {
|
|||||||
|
|
||||||
return {};
|
return {};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching server commands, error");
|
console.error("Error fetching server commands:", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
@ -1271,7 +1267,7 @@ const baseDataProvider: SynapseDataProvider = {
|
|||||||
|
|
||||||
return [];
|
return [];
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching scheduled commands, error");
|
console.error("Error fetching scheduled commands:", error);
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
},
|
},
|
||||||
@ -1296,7 +1292,7 @@ const baseDataProvider: SynapseDataProvider = {
|
|||||||
|
|
||||||
return [];
|
return [];
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching recurring commands, error");
|
console.error("Error fetching recurring commands:", error);
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
},
|
},
|
||||||
@ -1501,7 +1497,7 @@ const dataProvider = withLifecycleCallbacks(baseDataProvider, [
|
|||||||
}
|
}
|
||||||
return params;
|
return params;
|
||||||
},
|
},
|
||||||
beforeDelete: async (params: DeleteParams<any>, dataProvider: DataProvider) => {
|
beforeDelete: async (params: DeleteParams<any>, _dataProvider: DataProvider) => {
|
||||||
if (params.meta?.deleteMedia) {
|
if (params.meta?.deleteMedia) {
|
||||||
const base_url = localStorage.getItem("base_url");
|
const base_url = localStorage.getItem("base_url");
|
||||||
const endpoint_url = `${base_url}/_synapse/admin/v1/users/${encodeURIComponent(returnMXID(params.id))}/media`;
|
const endpoint_url = `${base_url}/_synapse/admin/v1/users/${encodeURIComponent(returnMXID(params.id))}/media`;
|
||||||
@ -1516,7 +1512,7 @@ const dataProvider = withLifecycleCallbacks(baseDataProvider, [
|
|||||||
|
|
||||||
return params;
|
return params;
|
||||||
},
|
},
|
||||||
beforeDeleteMany: async (params: DeleteManyParams<any>, dataProvider: DataProvider) => {
|
beforeDeleteMany: async (params: DeleteManyParams<any>, _dataProvider: DataProvider) => {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
params.ids.map(async id => {
|
params.ids.map(async id => {
|
||||||
if (params.meta?.deleteMedia) {
|
if (params.meta?.deleteMedia) {
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
import { Identifier, fetchUtils } from "react-admin";
|
import { fetchUtils } from "react-admin";
|
||||||
|
|
||||||
import { isMXID } from "../utils/mxid";
|
|
||||||
|
|
||||||
export const splitMxid = mxid => {
|
export const splitMxid = mxid => {
|
||||||
const re = /^@(?<name>[a-zA-Z0-9._=\-/]+):(?<domain>[a-zA-Z0-9\-.]+\.[a-zA-Z]+)$/;
|
const re = /^@(?<name>[a-zA-Z0-9._=\-/]+):(?<domain>[a-zA-Z0-9\-.]+\.[a-zA-Z]+)$/;
|
||||||
|
@ -69,7 +69,7 @@ export const FetchConfig = async () => {
|
|||||||
// load config from context
|
// load config from context
|
||||||
// we deliberately processing each key separately to avoid overwriting the whole config, losing some keys, and messing
|
// we deliberately processing each key separately to avoid overwriting the whole config, losing some keys, and messing
|
||||||
// with typescript types
|
// with typescript types
|
||||||
export const LoadConfig = (context: any) => {
|
export const LoadConfig = (context: object) => {
|
||||||
if (context?.restrictBaseUrl) {
|
if (context?.restrictBaseUrl) {
|
||||||
config.restrictBaseUrl = context.restrictBaseUrl as string | string[];
|
config.restrictBaseUrl = context.restrictBaseUrl as string | string[];
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,10 @@
|
|||||||
* @returns The decoded string, or the original string if decoding fails.
|
* @returns The decoded string, or the original string if decoding fails.
|
||||||
* @example decodeURIComponent("Hello%20World") // "Hello World"
|
* @example decodeURIComponent("Hello%20World") // "Hello World"
|
||||||
*/
|
*/
|
||||||
const decodeURLComponent = (str: any): any => {
|
const decodeURLComponent = (str: string): string => {
|
||||||
try {
|
try {
|
||||||
return decodeURIComponent(str);
|
return decodeURIComponent(str);
|
||||||
} catch (e) {
|
} catch {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user