feat(notify): add mattermost
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { forwardRef, useImperativeHandle, useMemo } from "react";
|
||||
import { Form, type FormInstance } from "antd";
|
||||
import {forwardRef, useImperativeHandle, useMemo} from "react";
|
||||
import {Form, type FormInstance} from "antd";
|
||||
|
||||
import { NOTIFY_CHANNELS, type NotifyChannelsSettingsContent } from "@/domain/settings";
|
||||
import { useAntdForm } from "@/hooks";
|
||||
import {NOTIFY_CHANNELS, type NotifyChannelsSettingsContent} from "@/domain/settings";
|
||||
import {useAntdForm} from "@/hooks";
|
||||
|
||||
import NotifyChannelEditFormBarkFields from "./NotifyChannelEditFormBarkFields";
|
||||
import NotifyChannelEditFormDingTalkFields from "./NotifyChannelEditFormDingTalkFields";
|
||||
@@ -14,6 +14,7 @@ import NotifyChannelEditFormServerChanFields from "./NotifyChannelEditFormServer
|
||||
import NotifyChannelEditFormTelegramFields from "./NotifyChannelEditFormTelegramFields";
|
||||
import NotifyChannelEditFormWebhookFields from "./NotifyChannelEditFormWebhookFields";
|
||||
import NotifyChannelEditFormWeComFields from "./NotifyChannelEditFormWeComFields";
|
||||
import NotifyChannelEditFormMattermostFields from "@/components/notification/NotifyChannelEditFormMattermostFields.tsx";
|
||||
|
||||
type NotifyChannelEditFormFieldValues = NotifyChannelsSettingsContent[keyof NotifyChannelsSettingsContent];
|
||||
|
||||
@@ -54,6 +55,8 @@ const NotifyChannelEditForm = forwardRef<NotifyChannelEditFormInstance, NotifyCh
|
||||
return <NotifyChannelEditFormGotifyFields />;
|
||||
case NOTIFY_CHANNELS.LARK:
|
||||
return <NotifyChannelEditFormLarkFields />;
|
||||
case NOTIFY_CHANNELS.MATTERMOST:
|
||||
return <NotifyChannelEditFormMattermostFields />;
|
||||
case NOTIFY_CHANNELS.PUSHPLUS:
|
||||
return <NotifyChannelEditFormPushPlusFields />;
|
||||
case NOTIFY_CHANNELS.SERVERCHAN:
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
import {useTranslation} from "react-i18next";
|
||||
import {Form, Input} from "antd";
|
||||
import {createSchemaFieldRule} from "antd-zod";
|
||||
import {z} from "zod";
|
||||
|
||||
const NotifyChannelEditFormMattermostFields = () => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSchema = z.object({
|
||||
serverUrl: z
|
||||
.string({ message: t("settings.notification.channel.form.mattermost_server_url.placeholder") })
|
||||
.url(t("common.errmsg.url_invalid")),
|
||||
channelId: z
|
||||
.string({ message: t("settings.notification.channel.form.mattermost_channel_id.placeholder") })
|
||||
.nonempty(t("settings.notification.channel.form.mattermost_channel_id.placeholder")),
|
||||
username: z
|
||||
.string({ message: t("settings.notification.channel.form.mattermost_username.placeholder") })
|
||||
.nonempty(t("settings.notification.channel.form.mattermost_username.placeholder")),
|
||||
password: z
|
||||
.string({ message: t("settings.notification.channel.form.mattermost_password.placeholder") })
|
||||
.nonempty(t("settings.notification.channel.form.mattermost_password.placeholder")),
|
||||
});
|
||||
const formRule = createSchemaFieldRule(formSchema);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item
|
||||
name="serverUrl"
|
||||
label={t("settings.notification.channel.form.mattermost_server_url.label")}
|
||||
rules={[formRule]}
|
||||
tooltip={<span dangerouslySetInnerHTML={{ __html: t("settings.notification.channel.form.mattermost_server_url.tooltip") }}></span>}
|
||||
>
|
||||
<Input placeholder={t("settings.notification.channel.form.mattermost_server_url.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="channelId"
|
||||
label={t("settings.notification.channel.form.mattermost_channel_id.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Input placeholder={t("settings.notification.channel.form.mattermost_channel_id.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="username"
|
||||
label={t("settings.notification.channel.form.mattermost_username.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Input placeholder={t("settings.notification.channel.form.mattermost_username.placeholder")} />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
name="password"
|
||||
label={t("settings.notification.channel.form.mattermost_password.label")}
|
||||
rules={[formRule]}
|
||||
>
|
||||
<Input.Password placeholder={t("settings.notification.channel.form.mattermost_password.placeholder")} />
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default NotifyChannelEditFormMattermostFields;
|
||||
Reference in New Issue
Block a user