matrix in one config

This commit is contained in:
Alex Holliday committed 2026-01-29 20:26:28 +00:00
1 parent a25ff03b71
commit 796960aeb2
3 files changed
+65 -45

No files matched your search

+49 -36
View File
@@ -1,7 +1,9 @@
import { BasePage, ConfigBox } from "@/Components/v2/design-elements"; import { BasePage, ConfigBox } from "@/Components/v2/design-elements";
import { TextField, Select } from "@/Components/v2/inputs"; import { TextField, Select, Button } from "@/Components/v2/inputs";
import MenuItem from "@mui/material/MenuItem"; import MenuItem from "@mui/material/MenuItem";
import Typography from "@mui/material/Typography"; import Typography from "@mui/material/Typography";
import Stack from "@mui/material/Stack";
import { useTheme } from "@mui/material/styles";
import { useEffect, useMemo } from "react"; import { useEffect, useMemo } from "react";
import { useParams } from "react-router-dom"; import { useParams } from "react-router-dom";
@@ -16,6 +18,7 @@ import { NotificationChannels } from "@/Types/Notification";
const NotificationsCreatePage = () => { const NotificationsCreatePage = () => {
const { t } = useTranslation(); const { t } = useTranslation();
const theme = useTheme();
const { notificationId } = useParams<{ notificationId: string }>(); const { notificationId } = useParams<{ notificationId: string }>();
const isEditMode = Boolean(notificationId); const isEditMode = Boolean(notificationId);
@@ -31,14 +34,12 @@ const NotificationsCreatePage = () => {
}); });
const { const {
register,
control, control,
watch, watch,
reset, reset,
formState: {}, handleSubmit,
} = form; } = form;
// Reset form when defaults change (i.e., when data is fetched)
useEffect(() => { useEffect(() => {
reset(defaults); reset(defaults);
}, [defaults, reset]); }, [defaults, reset]);
@@ -70,13 +71,19 @@ const NotificationsCreatePage = () => {
}; };
}, [watchedType, t]); }, [watchedType, t]);
const onSubmit = (data: NotificationFormData) => {
console.log(data);
};
// Suppress unused variable warnings - these will be used when UI is built const handleTest = () => {
void register; console.log("Test notification");
void control; };
return ( return (
<BasePage> <BasePage
component="form"
onSubmit={handleSubmit(onSubmit)}
>
<ConfigBox <ConfigBox
title={t("pages.notifications.form.notificationName.title")} title={t("pages.notifications.form.notificationName.title")}
subtitle={t("pages.notifications.form.notificationName.description")} subtitle={t("pages.notifications.form.notificationName.description")}
@@ -107,27 +114,23 @@ const NotificationsCreatePage = () => {
name="type" name="type"
control={control} control={control}
defaultValue={defaults.type} defaultValue={defaults.type}
render={({ field, fieldState }) => { render={({ field, fieldState }) => (
return (
<Select <Select
value={field.value} value={field.value}
fieldLabel={t("pages.notifications.form.type.optionType")} fieldLabel={t("pages.notifications.form.type.optionType")}
error={!!fieldState.error} error={!!fieldState.error}
onChange={field.onChange} onChange={field.onChange}
> >
{NotificationChannels.map((type: string) => { {NotificationChannels.map((type: string) => (
return (
<MenuItem <MenuItem
key={type} key={type}
value={type} value={type}
> >
<Typography textTransform={"capitalize"}>{type}</Typography> <Typography textTransform="capitalize">{type}</Typography>
</MenuItem> </MenuItem>
); ))}
})}
</Select> </Select>
); )}
}}
/> />
} }
/> />
@@ -157,9 +160,10 @@ const NotificationsCreatePage = () => {
)} )}
{watchedType === "matrix" && ( {watchedType === "matrix" && (
<ConfigBox <ConfigBox
title={t("pages.notifications.form.homeServer.title")} title={t("pages.notifications.form.matrix.title")}
subtitle={t("pages.notifications.form.homeServer.description")} subtitle={t("pages.notifications.form.matrix.description")}
rightContent={ rightContent={
<Stack spacing={theme.spacing(8)}>
<Controller <Controller
name="homeserverUrl" name="homeserverUrl"
control={control} control={control}
@@ -176,14 +180,6 @@ const NotificationsCreatePage = () => {
/> />
)} )}
/> />
}
/>
)}
{watchedType === "matrix" && (
<ConfigBox
title={t("pages.notifications.form.roomId.title")}
subtitle={t("pages.notifications.form.roomId.description")}
rightContent={
<Controller <Controller
name="roomId" name="roomId"
control={control} control={control}
@@ -200,14 +196,6 @@ const NotificationsCreatePage = () => {
/> />
)} )}
/> />
}
/>
)}
{watchedType === "matrix" && (
<ConfigBox
title={t("pages.notifications.form.accessToken.title")}
subtitle={t("pages.notifications.form.accessToken.description")}
rightContent={
<Controller <Controller
name="accessToken" name="accessToken"
control={control} control={control}
@@ -216,7 +204,9 @@ const NotificationsCreatePage = () => {
<TextField <TextField
{...field} {...field}
type="text" type="text"
fieldLabel={t("pages.notifications.form.accessToken.optionAccessToken")} fieldLabel={t(
"pages.notifications.form.accessToken.optionAccessToken"
)}
placeholder={t("pages.notifications.form.accessToken.placeholder")} placeholder={t("pages.notifications.form.accessToken.placeholder")}
fullWidth fullWidth
error={!!fieldState.error} error={!!fieldState.error}
@@ -224,9 +214,32 @@ const NotificationsCreatePage = () => {
/> />
)} )}
/> />
</Stack>
} }
/> />
)} )}
<Stack
direction="row"
justifyContent="flex-end"
spacing={theme.spacing(2)}
>
<Button
variant="contained"
color="primary"
onClick={handleTest}
loading={false}
>
{t("common.buttons.test")}
</Button>
<Button
loading={false}
type="submit"
variant="contained"
color="primary"
>
{t("common.buttons.save")}
</Button>
</Stack>
</BasePage> </BasePage>
); );
}; };
+7 -1
View File
@@ -231,7 +231,13 @@ const Routes = () => {
<Route <Route
path="notifications/:notificationId" path="notifications/:notificationId"
element={<CreateNotifications />} element={
<>
<ThemeProvider theme={v2theme}>
<CreateNotifications />
</ThemeProvider>
</>
}
/> />
<Route <Route
+9 -8
View File
@@ -269,10 +269,11 @@
"si": "Speed Index (SI)", "si": "Speed Index (SI)",
"tbt": "Total Blocking Time (TBT)" "tbt": "Total Blocking Time (TBT)"
}, },
"pie": { "title": "Performance report" }, "pie": {
"title": "Performance report"
},
"legend": { "legend": {
"title": "PageSpeed report", "title": "PageSpeed report",
"weight": "Weight" "weight": "Weight"
} }
} }
@@ -362,16 +363,12 @@
"title": "Home server" "title": "Home server"
}, },
"roomId": { "roomId": {
"description": "The ID of the room where notifications will be sent.",
"optionRoomId": "Room ID", "optionRoomId": "Room ID",
"placeholder": "!abcdefg:matrix.org", "placeholder": "!abcdefg:matrix.org"
"title": "Room ID"
}, },
"accessToken": { "accessToken": {
"description": "The access token used to authenticate with the Matrix server.",
"optionAccessToken": "Access token", "optionAccessToken": "Access token",
"placeholder": "syt_YWxleF9ob2xsaWRheQ_VmtScmV0U2VjcmV0S2V5_abc123", "placeholder": "syt_YWxleF9ob2xsaWRheQ_VmtScmV0U2VjcmV0S2V5_abc123"
"title": "Access token"
}, },
"address": { "address": {
"description": "The address where notifications will be sent.", "description": "The address where notifications will be sent.",
@@ -385,6 +382,10 @@
"optionIntegrationKey": "Integration key", "optionIntegrationKey": "Integration key",
"placeholder": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6", "placeholder": "a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6",
"title": "Integration key" "title": "Integration key"
},
"matrix": {
"description": "Configure your Matrix homeserver connection for notifications.",
"title": "Matrix configuration"
} }
} }
} }