Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename Server Schedules to Server Actions
  • Loading branch information
beastafk committed Apr 8, 2025
commit 14b59cc9684e8a818d24b08932e6b82a11c16763
14 changes: 7 additions & 7 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Route } from "react-router-dom";
import AdminLayout from "./components/AdminLayout";
import ServerNotificationsPage from "./components/etke.cc/ServerNotificationsPage";
import ServerStatusPage from "./components/etke.cc/ServerStatusPage";
import ServerSchedulesPage from "./components/etke.cc/schedules/components/ServerSchedulesPage";
import ServerActionsPage from "./components/etke.cc/ServerActionsPage";
import RecurringCommandEdit from "./components/etke.cc/schedules/components/recurring/RecurringCommandEdit";
import ScheduledCommandEdit from "./components/etke.cc/schedules/components/scheduled/ScheduledCommandEdit";
import ScheduledCommandShow from "./components/etke.cc/schedules/components/scheduled/ScheduledCommandShow";
Expand Down Expand Up @@ -68,12 +68,12 @@ export const App = () => (
<CustomRoutes>
<Route path="/import_users" element={<UserImport />} />
<Route path="/server_status" element={<ServerStatusPage />} />
<Route path="/server_schedules" element={<ServerSchedulesPage />} />
<Route path="/scheduled_commands/:id/show" element={<ScheduledCommandShow />} />
<Route path="/scheduled_commands/:id" element={<ScheduledCommandEdit />} />
<Route path="/scheduled_commands/create" element={<ScheduledCommandEdit />} />
<Route path="/recurring_commands/:id" element={<RecurringCommandEdit />} />
<Route path="/recurring_commands/create" element={<RecurringCommandEdit />} />
<Route path="/server_actions" element={<ServerActionsPage />} />
<Route path="/server_actions/scheduled/:id/show" element={<ScheduledCommandShow />} />
<Route path="/server_actions/scheduled/:id" element={<ScheduledCommandEdit />} />
<Route path="/server_actions/scheduled/create" element={<ScheduledCommandEdit />} />
<Route path="/server_actions/recurring/:id" element={<RecurringCommandEdit />} />
<Route path="/server_actions/recurring/create" element={<RecurringCommandEdit />} />
<Route path="/server_notifications" element={<ServerNotificationsPage />} />
</CustomRoutes>
<Resource {...users} />
Expand Down
6 changes: 3 additions & 3 deletions src/components/AdminLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ const AdminMenu = props => {
)}
{etkeRoutesEnabled && (
<Menu.Item
key="server_schedules"
to="/server_schedules"
key="server_actions"
to="/server_actions"
leftIcon={<ManageHistoryIcon />}
primaryText="Server Schedules"
primaryText="Server Actions"
/>
)}
<Menu.ResourceItems />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,22 @@
import RestoreIcon from "@mui/icons-material/Restore";
import ScheduleIcon from "@mui/icons-material/Schedule";
import { Box, Typography, Link, Alert, Divider } from "@mui/material";
import { Box, Typography, Link, Divider } from "@mui/material";
import { Stack } from "@mui/material";

import RecurringCommandsList from "./recurring/RecurringCommandsList";
import ScheduledCommandsList from "./scheduled/ScheduledCommandsList";
import CurrentlyRunningCommand from "../../CurrentlyRunningCommand";
import ServerCommandsPanel from "../../ServerCommandsPanel";
const ServerSchedulesPage = () => {
import RecurringCommandsList from "./schedules/components/recurring/RecurringCommandsList";
import ScheduledCommandsList from "./schedules/components/scheduled/ScheduledCommandsList";
import CurrentlyRunningCommand from "./CurrentlyRunningCommand";
import ServerCommandsPanel from "./ServerCommandsPanel";
const ServerActionsPage = () => {
return (
<Stack spacing={3} mt={3}>
<Stack spacing={1} direction="column">
<Stack spacing={2} direction="column">
<CurrentlyRunningCommand />
<ServerCommandsPanel />
</Stack>

<Divider sx={{ my: 4, borderWidth: 1 }} />

<Stack spacing={1} direction="column">
<Box sx={{ display: "flex", alignItems: "center", gap: 1 }}>
<Typography variant="h4">Server Schedules</Typography>
</Box>
<Typography variant="body1">
Here you can{" "}
<Link target="_blank" href="https://etke.cc/help/extras/scheduler/#schedule">
schedule
</Link>{" "}
commands to run them either once at a certain time or on{" "}
<Link target="_blank" href="https://etke.cc/help/extras/scheduler/#recurring">
a recurring basis
</Link>
.
</Typography>
</Stack>

<Box sx={{ mt: 2 }}>
<Typography variant="h5">
<ScheduleIcon sx={{ verticalAlign: "middle", mr: 1 }} /> Scheduled commands
Expand Down Expand Up @@ -69,4 +52,4 @@ const ServerSchedulesPage = () => {
);
};

export default ServerSchedulesPage;
export default ServerActionsPage;
13 changes: 9 additions & 4 deletions src/components/etke.cc/ServerCommandsPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PlayArrow, CheckCircle, HelpCenter } from "@mui/icons-material";
import { PlayArrow, CheckCircle, HelpCenter, Construction } from "@mui/icons-material";
import {
Table,
TableBody,
Expand Down Expand Up @@ -128,13 +128,16 @@ const ServerCommandsPanel = () => {

return (
<>
<Typography variant="h4">Server Commands</Typography>
<Typography variant="h5"><Construction sx={{ verticalAlign: "middle", mr: 1 }} /> Server Commands</Typography>
<TableContainer component={Paper}>
<Table sx={{ minWidth: 450 }} size="small" aria-label="simple table">
<TableHead>
<TableRow>
<TableCell>
Command
</TableCell>
<TableCell>
Help
<Link href="https://etke.cc/help/extras/scheduler/#commands" target="_blank">
<Button size="small" startIcon={<HelpCenter />} title="Help" />
</Link>
Expand All @@ -145,15 +148,17 @@ const ServerCommandsPanel = () => {
</TableHead>
<TableBody>
{Object.entries(serverCommands).map(([command, { icon, args, description, additionalArgs }]) => (
<TableRow key={command} sx={{ "&:last-child td, &:last-child th": { border: 0 } }}>
<TableRow key={command}>
<TableCell scope="row">
<Box>
{renderIcon(icon)}
{command}
</Box>
</TableCell>
<TableCell>
<Link href={"https://etke.cc/help/extras/scheduler/#" + command} target="_blank">
<Button size="small" startIcon={<HelpCenter />} title={command + " help"} />
</Link>
</Box>
</TableCell>
<TableCell>{description}</TableCell>
<TableCell>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const RecurringCommandEdit = () => {
// Invalidate scheduled commands queries
queryClient.invalidateQueries({ queryKey: ["scheduledCommands"] });

navigate("/server_schedules");
navigate("/server_actions");
} catch (error) {
notify("recurring_commands.action.update_failure", { type: "error" });
}
Expand All @@ -139,7 +139,7 @@ const RecurringCommandEdit = () => {

return (
<Box sx={{ mt: 2 }}>
<Button label="Back" onClick={() => navigate("/server_schedules")} startIcon={<ArrowBackIcon />} sx={{ mb: 2 }} />
<Button label="Back" onClick={() => navigate("/server_actions")} startIcon={<ArrowBackIcon />} sx={{ mb: 2 }} />

<Card>
<CardHeader title={pageTitle} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Paper } from "@mui/material";
import { Loading, Button } from "react-admin";
import { DateField } from "react-admin";
import { Datagrid } from "react-admin";
import { ListContextProvider, TextField, TopToolbar } from "react-admin";
import { ListContextProvider, TextField, TopToolbar, Identifier } from "react-admin";
import { ResourceContextProvider, useList } from "react-admin";
import { useNavigate } from "react-router-dom";

Expand All @@ -15,7 +15,7 @@ const ListActions = () => {

return (
<TopToolbar>
<Button label="Create" onClick={() => navigate("/recurring_commands/create")} startIcon={<AddIcon />} />
<Button label="Create" onClick={() => navigate("/server_actions/recurring/create")} startIcon={<AddIcon />} />
</TopToolbar>
);
};
Expand All @@ -24,7 +24,7 @@ const RecurringCommandsList = () => {
const { data, isLoading, error } = useRecurringCommands();

const listContext = useList({
resource: "recurring_commands",
resource: "recurring",
sort: { field: "scheduled_at", order: "DESC" },
perPage: 50,
data: data || [],
Expand All @@ -34,11 +34,17 @@ const RecurringCommandsList = () => {
if (isLoading) return <Loading />;

return (
<ResourceContextProvider value="recurring_commands">
<ResourceContextProvider value="recurring">
<ListContextProvider value={listContext}>
<ListActions />
<Paper>
<Datagrid bulkActionButtons={false} rowClick="edit">
<Datagrid bulkActionButtons={false} rowClick={(id: Identifier, resource: string, record: any) => {
if (!record) {
return "";
}

return `/server_actions/${resource}/${id}`;
}}>
<TextField source="command" />
<TextField source="args" label="Arguments" />
<TextField source="time" label="Time (UTC)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const RecurringDeleteButton = () => {
try {
await dataProvider.deleteRecurringCommand(etkeccAdmin, record.id);
notify("recurring_commands.action.delete_success", { type: "success" });
navigate("/server_schedules");
navigate("/server_actions");
} catch (error) {
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
notify(`Error: ${errorMessage}`, { type: "error" });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const ScheduledCommandEdit = () => {
notify("scheduled_commands.action.update_success", { type: "success" });
}

navigate("/server_schedules");
navigate("/server_actions");
} catch (error) {
notify("scheduled_commands.action.update_failure", { type: "error" });
}
Expand All @@ -94,7 +94,7 @@ const ScheduledCommandEdit = () => {

return (
<Box sx={{ mt: 2 }}>
<Button label="Back" onClick={() => navigate("/server_schedules")} startIcon={<ArrowBackIcon />} sx={{ mb: 2 }} />
<Button label="Back" onClick={() => navigate("/server_actions")} startIcon={<ArrowBackIcon />} sx={{ mb: 2 }} />

<Card>
<CardHeader title={pageTitle} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ import { useScheduledCommands } from "../../hooks/useScheduledCommands";
const ScheduledCommandShow = () => {
const { id } = useParams();
const navigate = useNavigate();
const notify = useNotify();
const dataProvider = useDataProvider();
const { etkeccAdmin } = useAppContext();
const [command, setCommand] = useState<ScheduledCommand | null>(null);
const [loading, setLoading] = useState(true);
const { data: scheduledCommands, isLoading: isLoadingList } = useScheduledCommands();
Expand All @@ -44,15 +41,12 @@ const ScheduledCommandShow = () => {
}

if (!command) {
// notify("Command not found", { type: "error" });
// navigate("/server_schedules");
return null;
}
console.log(command);

return (
<Box sx={{ mt: 2 }}>
<Button label="Back" onClick={() => navigate("/server_schedules")} startIcon={<ArrowBackIcon />} sx={{ mb: 2 }} />
<Button label="Back" onClick={() => navigate("/server_actions")} startIcon={<ArrowBackIcon />} sx={{ mb: 2 }} />

<RecordContextProvider value={command}>
<Card>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const ListActions = () => {
const navigate = useNavigate();

const handleCreate = () => {
navigate("/scheduled_commands/create");
navigate("/server_actions/scheduled/create");
};

return (
Expand All @@ -30,7 +30,7 @@ const ScheduledCommandsList = () => {
const { data, isLoading, error } = useScheduledCommands();

const listContext = useList({
resource: "scheduled_commands",
resource: "scheduled",
sort: { field: "scheduled_at", order: "DESC" },
perPage: 50,
data: data || [],
Expand All @@ -40,7 +40,7 @@ const ScheduledCommandsList = () => {
if (isLoading) return <Loading />;

return (
<ResourceContextProvider value="scheduled_commands">
<ResourceContextProvider value="scheduled">
<ListContextProvider value={listContext}>
<ListActions />
<Paper>
Expand All @@ -52,10 +52,10 @@ const ScheduledCommandsList = () => {
}

if (record.is_recurring) {
return `/${resource}/${id}/show`;
return `/server_actions/${resource}/${id}/show`;
}

return `/${resource}/${id}`;
return `/server_actions/${resource}/${id}`;
}}
>
<TextField source="command" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const ScheduledDeleteButton = () => {
try {
await dataProvider.deleteScheduledCommand(etkeccAdmin, record.id);
notify("scheduled_commands.action.delete_success", { type: "success" });
navigate("/server_schedules");
navigate("/server_actions");
} catch (error) {
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
notify(`Error: ${errorMessage}`, { type: "error" });
Expand Down