mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2026-01-03 21:37:42 -05:00
feat(webpush): add warning to web push settings re: HTTPS requirement (#1599)
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { Field, Form, Formik } from 'formik';
|
import { Field, Form, Formik } from 'formik';
|
||||||
import React, { useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { defineMessages, useIntl } from 'react-intl';
|
import { defineMessages, useIntl } from 'react-intl';
|
||||||
import { useToasts } from 'react-toast-notifications';
|
import { useToasts } from 'react-toast-notifications';
|
||||||
import useSWR, { mutate } from 'swr';
|
import useSWR, { mutate } from 'swr';
|
||||||
import globalMessages from '../../../../i18n/globalMessages';
|
import globalMessages from '../../../../i18n/globalMessages';
|
||||||
|
import Alert from '../../../Common/Alert';
|
||||||
import Button from '../../../Common/Button';
|
import Button from '../../../Common/Button';
|
||||||
import LoadingSpinner from '../../../Common/LoadingSpinner';
|
import LoadingSpinner from '../../../Common/LoadingSpinner';
|
||||||
import NotificationTypeSelector from '../../../NotificationTypeSelector';
|
import NotificationTypeSelector from '../../../NotificationTypeSelector';
|
||||||
@@ -16,22 +17,35 @@ const messages = defineMessages({
|
|||||||
toastWebPushTestSending: 'Sending web push test notification…',
|
toastWebPushTestSending: 'Sending web push test notification…',
|
||||||
toastWebPushTestSuccess: 'Web push test notification sent!',
|
toastWebPushTestSuccess: 'Web push test notification sent!',
|
||||||
toastWebPushTestFailed: 'Web push test notification failed to send.',
|
toastWebPushTestFailed: 'Web push test notification failed to send.',
|
||||||
|
httpsRequirement:
|
||||||
|
'In order to receive web push notifications, Overseerr must be served over HTTPS.',
|
||||||
});
|
});
|
||||||
|
|
||||||
const NotificationsWebPush: React.FC = () => {
|
const NotificationsWebPush: React.FC = () => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const { addToast, removeToast } = useToasts();
|
const { addToast, removeToast } = useToasts();
|
||||||
const [isTesting, setIsTesting] = useState(false);
|
const [isTesting, setIsTesting] = useState(false);
|
||||||
|
const [isHttps, setIsHttps] = useState(false);
|
||||||
const { data, error, revalidate } = useSWR(
|
const { data, error, revalidate } = useSWR(
|
||||||
'/api/v1/settings/notifications/webpush'
|
'/api/v1/settings/notifications/webpush'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setIsHttps(window.location.protocol.startsWith('https'));
|
||||||
|
}, []);
|
||||||
|
|
||||||
if (!data && !error) {
|
if (!data && !error) {
|
||||||
return <LoadingSpinner />;
|
return <LoadingSpinner />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
{!isHttps && (
|
||||||
|
<Alert
|
||||||
|
title={intl.formatMessage(messages.httpsRequirement)}
|
||||||
|
type="warning"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<Formik
|
<Formik
|
||||||
initialValues={{
|
initialValues={{
|
||||||
enabled: data.enabled,
|
enabled: data.enabled,
|
||||||
|
|||||||
@@ -37,6 +37,17 @@ const SettingsNotifications: React.FC = ({ children }) => {
|
|||||||
route: '/settings/notifications/email',
|
route: '/settings/notifications/email',
|
||||||
regex: /^\/settings\/notifications\/email/,
|
regex: /^\/settings\/notifications\/email/,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
text: intl.formatMessage(messages.webpush),
|
||||||
|
content: (
|
||||||
|
<span className="flex items-center">
|
||||||
|
<CloudIcon className="h-4 mr-2" />
|
||||||
|
{intl.formatMessage(messages.webpush)}
|
||||||
|
</span>
|
||||||
|
),
|
||||||
|
route: '/settings/notifications/webpush',
|
||||||
|
regex: /^\/settings\/notifications\/webpush/,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
text: 'Discord',
|
text: 'Discord',
|
||||||
content: (
|
content: (
|
||||||
@@ -103,17 +114,6 @@ const SettingsNotifications: React.FC = ({ children }) => {
|
|||||||
route: '/settings/notifications/telegram',
|
route: '/settings/notifications/telegram',
|
||||||
regex: /^\/settings\/notifications\/telegram/,
|
regex: /^\/settings\/notifications\/telegram/,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
text: intl.formatMessage(messages.webpush),
|
|
||||||
content: (
|
|
||||||
<span className="flex items-center">
|
|
||||||
<CloudIcon className="h-4 mr-2" />
|
|
||||||
{intl.formatMessage(messages.webpush)}
|
|
||||||
</span>
|
|
||||||
),
|
|
||||||
route: '/settings/notifications/webpush',
|
|
||||||
regex: /^\/settings\/notifications\/webpush/,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
text: intl.formatMessage(messages.webhook),
|
text: intl.formatMessage(messages.webhook),
|
||||||
content: (
|
content: (
|
||||||
|
|||||||
@@ -290,6 +290,7 @@
|
|||||||
"components.Settings.Notifications.NotificationsSlack.webhookUrl": "Webhook URL",
|
"components.Settings.Notifications.NotificationsSlack.webhookUrl": "Webhook URL",
|
||||||
"components.Settings.Notifications.NotificationsSlack.webhookUrlTip": "Create an <WebhookLink>Incoming Webhook</WebhookLink> integration",
|
"components.Settings.Notifications.NotificationsSlack.webhookUrlTip": "Create an <WebhookLink>Incoming Webhook</WebhookLink> integration",
|
||||||
"components.Settings.Notifications.NotificationsWebPush.agentenabled": "Enable Agent",
|
"components.Settings.Notifications.NotificationsWebPush.agentenabled": "Enable Agent",
|
||||||
|
"components.Settings.Notifications.NotificationsWebPush.httpsRequirement": "In order to receive web push notifications, Overseerr must be served over HTTPS.",
|
||||||
"components.Settings.Notifications.NotificationsWebPush.toastWebPushTestFailed": "Web push test notification failed to send.",
|
"components.Settings.Notifications.NotificationsWebPush.toastWebPushTestFailed": "Web push test notification failed to send.",
|
||||||
"components.Settings.Notifications.NotificationsWebPush.toastWebPushTestSending": "Sending web push test notification…",
|
"components.Settings.Notifications.NotificationsWebPush.toastWebPushTestSending": "Sending web push test notification…",
|
||||||
"components.Settings.Notifications.NotificationsWebPush.toastWebPushTestSuccess": "Web push test notification sent!",
|
"components.Settings.Notifications.NotificationsWebPush.toastWebPushTestSuccess": "Web push test notification sent!",
|
||||||
|
|||||||
Reference in New Issue
Block a user