From b5988f9a5ff274e97f208c2726abe76c22c858ee Mon Sep 17 00:00:00 2001 From: sct Date: Tue, 15 Dec 2020 03:30:13 +0000 Subject: [PATCH] fix(frontend): add validation for Radarr/Sonarr server name --- src/components/Settings/RadarrModal/index.tsx | 4 ++++ src/components/Settings/SonarrModal/index.tsx | 4 ++++ src/i18n/locale/en.json | 2 ++ 3 files changed, 10 insertions(+) diff --git a/src/components/Settings/RadarrModal/index.tsx b/src/components/Settings/RadarrModal/index.tsx index cce4c37b6..f7d80081f 100644 --- a/src/components/Settings/RadarrModal/index.tsx +++ b/src/components/Settings/RadarrModal/index.tsx @@ -11,6 +11,7 @@ import { defineMessages, useIntl } from 'react-intl'; const messages = defineMessages({ createradarr: 'Create New Radarr Server', editradarr: 'Edit Radarr Server', + validationNameRequired: 'You must provide a server name', validationHostnameRequired: 'You must provide a hostname/IP', validationPortRequired: 'You must provide a port', validationApiKeyRequired: 'You must provide an API key', @@ -74,6 +75,9 @@ const RadarrModal: React.FC = ({ rootFolders: [], }); const RadarrSettingsSchema = Yup.object().shape({ + name: Yup.string().required( + intl.formatMessage(messages.validationNameRequired) + ), hostname: Yup.string().required( intl.formatMessage(messages.validationHostnameRequired) ), diff --git a/src/components/Settings/SonarrModal/index.tsx b/src/components/Settings/SonarrModal/index.tsx index 248006dd6..a98c64ed0 100644 --- a/src/components/Settings/SonarrModal/index.tsx +++ b/src/components/Settings/SonarrModal/index.tsx @@ -11,6 +11,7 @@ import { useIntl, defineMessages } from 'react-intl'; const messages = defineMessages({ createsonarr: 'Create New Sonarr Server', editsonarr: 'Edit Sonarr Server', + validationNameRequired: 'You must provide a server name', validationHostnameRequired: 'You must provide a hostname/IP', validationPortRequired: 'You must provide a port', validationApiKeyRequired: 'You must provide an API key', @@ -73,6 +74,9 @@ const SonarrModal: React.FC = ({ rootFolders: [], }); const SonarrSettingsSchema = Yup.object().shape({ + name: Yup.string().required( + intl.formatMessage(messages.validationNameRequired) + ), hostname: Yup.string().required( intl.formatMessage(messages.validationHostnameRequired) ), diff --git a/src/i18n/locale/en.json b/src/i18n/locale/en.json index b7530f42e..af814e4b8 100644 --- a/src/i18n/locale/en.json +++ b/src/i18n/locale/en.json @@ -135,6 +135,7 @@ "components.Settings.RadarrModal.toastRadarrTestSuccess": "Radarr connection established!", "components.Settings.RadarrModal.validationApiKeyRequired": "You must provide an API key", "components.Settings.RadarrModal.validationHostnameRequired": "You must provide a hostname/IP", + "components.Settings.RadarrModal.validationNameRequired": "You must provide a server name", "components.Settings.RadarrModal.validationPortRequired": "You must provide a port", "components.Settings.RadarrModal.validationProfileRequired": "You must select a profile", "components.Settings.RadarrModal.validationRootFolderRequired": "You must select a root folder", @@ -165,6 +166,7 @@ "components.Settings.SonarrModal.toastRadarrTestSuccess": "Sonarr connection established!", "components.Settings.SonarrModal.validationApiKeyRequired": "You must provide an API key", "components.Settings.SonarrModal.validationHostnameRequired": "You must provide a hostname/IP", + "components.Settings.SonarrModal.validationNameRequired": "You must provide a server name", "components.Settings.SonarrModal.validationPortRequired": "You must provide a port", "components.Settings.SonarrModal.validationProfileRequired": "You must select a profile", "components.Settings.SonarrModal.validationRootFolderRequired": "You must select a root folder",