|
|
|
@ -13,6 +13,8 @@ const messages = defineMessages({
|
|
|
|
|
save: 'Save Changes',
|
|
|
|
|
saving: 'Saving…',
|
|
|
|
|
agentenabled: 'Enable Agent',
|
|
|
|
|
botUsername: 'Bot Username',
|
|
|
|
|
botAvatarUrl: 'Bot Avatar URL',
|
|
|
|
|
webhookUrl: 'Webhook URL',
|
|
|
|
|
webhookUrlPlaceholder: 'Server Settings → Integrations → Webhooks',
|
|
|
|
|
discordsettingssaved: 'Discord notification settings saved successfully!',
|
|
|
|
@ -20,7 +22,7 @@ const messages = defineMessages({
|
|
|
|
|
testsent: 'Test notification sent!',
|
|
|
|
|
test: 'Test',
|
|
|
|
|
notificationtypes: 'Notification Types',
|
|
|
|
|
validationWebhookUrl: 'You must provide a valid URL',
|
|
|
|
|
validationUrl: 'You must provide a valid URL',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const NotificationsDiscord: React.FC = () => {
|
|
|
|
@ -31,9 +33,12 @@ const NotificationsDiscord: React.FC = () => {
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const NotificationsDiscordSchema = Yup.object().shape({
|
|
|
|
|
botAvatarUrl: Yup.string()
|
|
|
|
|
.nullable()
|
|
|
|
|
.url(intl.formatMessage(messages.validationUrl)),
|
|
|
|
|
webhookUrl: Yup.string()
|
|
|
|
|
.required(intl.formatMessage(messages.validationWebhookUrl))
|
|
|
|
|
.url(intl.formatMessage(messages.validationWebhookUrl)),
|
|
|
|
|
.required(intl.formatMessage(messages.validationUrl))
|
|
|
|
|
.url(intl.formatMessage(messages.validationUrl)),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!data && !error) {
|
|
|
|
@ -45,6 +50,8 @@ const NotificationsDiscord: React.FC = () => {
|
|
|
|
|
initialValues={{
|
|
|
|
|
enabled: data.enabled,
|
|
|
|
|
types: data.types,
|
|
|
|
|
botUsername: data?.options.botUsername,
|
|
|
|
|
botAvatarUrl: data?.options.botAvatarUrl,
|
|
|
|
|
webhookUrl: data.options.webhookUrl,
|
|
|
|
|
}}
|
|
|
|
|
validationSchema={NotificationsDiscordSchema}
|
|
|
|
@ -54,6 +61,8 @@ const NotificationsDiscord: React.FC = () => {
|
|
|
|
|
enabled: values.enabled,
|
|
|
|
|
types: values.types,
|
|
|
|
|
options: {
|
|
|
|
|
botUsername: values.botUsername,
|
|
|
|
|
botAvatarUrl: values.botAvatarUrl,
|
|
|
|
|
webhookUrl: values.webhookUrl,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
@ -77,6 +86,8 @@ const NotificationsDiscord: React.FC = () => {
|
|
|
|
|
enabled: true,
|
|
|
|
|
types: values.types,
|
|
|
|
|
options: {
|
|
|
|
|
botUsername: values.botUsername,
|
|
|
|
|
botAvatarUrl: values.botAvatarUrl,
|
|
|
|
|
webhookUrl: values.webhookUrl,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
@ -97,6 +108,42 @@ const NotificationsDiscord: React.FC = () => {
|
|
|
|
|
<Field type="checkbox" id="enabled" name="enabled" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="form-row">
|
|
|
|
|
<label htmlFor="botUsername" className="text-label">
|
|
|
|
|
{intl.formatMessage(messages.botUsername)}
|
|
|
|
|
</label>
|
|
|
|
|
<div className="form-input">
|
|
|
|
|
<div className="flex max-w-lg rounded-md shadow-sm">
|
|
|
|
|
<Field
|
|
|
|
|
id="botUsername"
|
|
|
|
|
name="botUsername"
|
|
|
|
|
type="text"
|
|
|
|
|
placeholder={intl.formatMessage(messages.botUsername)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
{errors.botUsername && touched.botUsername && (
|
|
|
|
|
<div className="error">{errors.botUsername}</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="form-row">
|
|
|
|
|
<label htmlFor="botAvatarUrl" className="text-label">
|
|
|
|
|
{intl.formatMessage(messages.botAvatarUrl)}
|
|
|
|
|
</label>
|
|
|
|
|
<div className="form-input">
|
|
|
|
|
<div className="flex max-w-lg rounded-md shadow-sm">
|
|
|
|
|
<Field
|
|
|
|
|
id="botAvatarUrl"
|
|
|
|
|
name="botAvatarUrl"
|
|
|
|
|
type="text"
|
|
|
|
|
placeholder={intl.formatMessage(messages.botAvatarUrl)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
{errors.botAvatarUrl && touched.botAvatarUrl && (
|
|
|
|
|
<div className="error">{errors.botAvatarUrl}</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="form-row">
|
|
|
|
|
<label htmlFor="name" className="text-label">
|
|
|
|
|
{intl.formatMessage(messages.webhookUrl)}
|
|
|
|
|