fix(frontend): clarify that radarr/sonnarr servers must be tested before profiles/folders appear

Also blocks "Add Server" or "Save" button until all required fields are entered

fixes #326 and #328
pull/376/head
sct 4 years ago
parent 0d088e085e
commit fc12ab84d9

@ -42,6 +42,10 @@ const messages = defineMessages({
selectQualityProfile: 'Select a Quality Profile', selectQualityProfile: 'Select a Quality Profile',
selectRootFolder: 'Select a Root Folder', selectRootFolder: 'Select a Root Folder',
selectMinimumAvailability: 'Select minimum availability', selectMinimumAvailability: 'Select minimum availability',
loadingprofiles: 'Loading quality profiles…',
testFirstQualityProfiles: 'Test your connection to load quality profiles',
loadingrootfolders: 'Loading root folders…',
testFirstRootFolders: 'Test your connection to load root folders',
}); });
interface TestResponse { interface TestResponse {
@ -86,7 +90,9 @@ const RadarrModal: React.FC<RadarrModalProps> = ({
intl.formatMessage(messages.validationPortRequired) intl.formatMessage(messages.validationPortRequired)
), ),
apiKey: Yup.string().required(intl.formatMessage(messages.apiKey)), apiKey: Yup.string().required(intl.formatMessage(messages.apiKey)),
rootFolder: Yup.string().required(intl.formatMessage(messages.rootfolder)), rootFolder: Yup.string().required(
intl.formatMessage(messages.validationRootFolderRequired)
),
activeProfileId: Yup.string().required( activeProfileId: Yup.string().required(
intl.formatMessage(messages.validationProfileRequired) intl.formatMessage(messages.validationProfileRequired)
), ),
@ -179,7 +185,7 @@ const RadarrModal: React.FC<RadarrModalProps> = ({
baseUrl: radarr?.baseUrl, baseUrl: radarr?.baseUrl,
activeProfileId: radarr?.activeProfileId, activeProfileId: radarr?.activeProfileId,
rootFolder: radarr?.activeDirectory, rootFolder: radarr?.activeDirectory,
minimumAvailability: radarr?.minimumAvailability, minimumAvailability: radarr?.minimumAvailability ?? 'released',
isDefault: radarr?.isDefault ?? false, isDefault: radarr?.isDefault ?? false,
is4k: radarr?.is4k ?? false, is4k: radarr?.is4k ?? false,
}} }}
@ -226,6 +232,7 @@ const RadarrModal: React.FC<RadarrModalProps> = ({
handleSubmit, handleSubmit,
setFieldValue, setFieldValue,
isSubmitting, isSubmitting,
isValid,
}) => { }) => {
return ( return (
<Modal <Modal
@ -258,7 +265,7 @@ const RadarrModal: React.FC<RadarrModalProps> = ({
secondaryDisabled={ secondaryDisabled={
!values.apiKey || !values.hostname || !values.port || isTesting !values.apiKey || !values.hostname || !values.port || isTesting
} }
okDisabled={!isValidated || isSubmitting || isTesting} okDisabled={!isValidated || isSubmitting || isTesting || !isValid}
onOk={() => handleSubmit()} onOk={() => handleSubmit()}
title={ title={
!radarr !radarr
@ -453,10 +460,17 @@ const RadarrModal: React.FC<RadarrModalProps> = ({
as="select" as="select"
id="activeProfileId" id="activeProfileId"
name="activeProfileId" name="activeProfileId"
className="mt-1 form-select rounded-md block w-full pl-3 pr-10 py-2 text-base leading-6 bg-gray-700 border-gray-500 focus:outline-none focus:ring-blue focus:border-gray-500 sm:text-sm sm:leading-5" disabled={!isValidated || isTesting}
className="mt-1 form-select rounded-md block w-full pl-3 pr-10 py-2 text-base leading-6 bg-gray-700 border-gray-500 focus:outline-none focus:ring-blue focus:border-gray-500 sm:text-sm sm:leading-5 disabled:opacity-50"
> >
<option value=""> <option value="">
{intl.formatMessage(messages.selectQualityProfile)} {isTesting
? intl.formatMessage(messages.loadingprofiles)
: !isValidated
? intl.formatMessage(
messages.testFirstQualityProfiles
)
: intl.formatMessage(messages.selectQualityProfile)}
</option> </option>
{testResponse.profiles.length > 0 && {testResponse.profiles.length > 0 &&
testResponse.profiles.map((profile) => ( testResponse.profiles.map((profile) => (
@ -489,10 +503,15 @@ const RadarrModal: React.FC<RadarrModalProps> = ({
as="select" as="select"
id="rootFolder" id="rootFolder"
name="rootFolder" name="rootFolder"
className="mt-1 form-select rounded-md block w-full pl-3 pr-10 py-2 text-base leading-6 bg-gray-700 border-gray-500 focus:outline-none focus:ring-blue focus:border-gray-500 sm:text-sm sm:leading-5" disabled={!isValidated || isTesting}
className="mt-1 form-select rounded-md block w-full pl-3 pr-10 py-2 text-base leading-6 bg-gray-700 border-gray-500 focus:outline-none focus:ring-blue focus:border-gray-500 sm:text-sm sm:leading-5 disabled:opacity-50"
> >
<option value=""> <option value="">
{intl.formatMessage(messages.selectRootFolder)} {isTesting
? intl.formatMessage(messages.loadingrootfolders)
: !isValidated
? intl.formatMessage(messages.testFirstRootFolders)
: intl.formatMessage(messages.selectRootFolder)}
</option> </option>
{testResponse.rootFolders.length > 0 && {testResponse.rootFolders.length > 0 &&
testResponse.rootFolders.map((folder) => ( testResponse.rootFolders.map((folder) => (
@ -527,11 +546,6 @@ const RadarrModal: React.FC<RadarrModalProps> = ({
name="minimumAvailability" name="minimumAvailability"
className="mt-1 form-select rounded-md block w-full pl-3 pr-10 py-2 text-base leading-6 bg-gray-700 border-gray-500 focus:outline-none focus:ring-blue focus:border-gray-500 sm:text-sm sm:leading-5" className="mt-1 form-select rounded-md block w-full pl-3 pr-10 py-2 text-base leading-6 bg-gray-700 border-gray-500 focus:outline-none focus:ring-blue focus:border-gray-500 sm:text-sm sm:leading-5"
> >
<option value="">
{intl.formatMessage(
messages.selectMinimumAvailability
)}
</option>
<option value="announced">Announced</option> <option value="announced">Announced</option>
<option value="inCinemas">In Cinemas</option> <option value="inCinemas">In Cinemas</option>
<option value="released">Released</option> <option value="released">Released</option>

@ -40,6 +40,10 @@ const messages = defineMessages({
server4k: '4K Server', server4k: '4K Server',
selectQualityProfile: 'Select a Quality Profile', selectQualityProfile: 'Select a Quality Profile',
selectRootFolder: 'Select a Root Folder', selectRootFolder: 'Select a Root Folder',
loadingprofiles: 'Loading quality profiles…',
testFirstQualityProfiles: 'Test your connection to load quality profiles',
loadingrootfolders: 'Loading root folders…',
testFirstRootFolders: 'Test your connection to load root folders',
}); });
interface TestResponse { interface TestResponse {
@ -225,6 +229,7 @@ const SonarrModal: React.FC<SonarrModalProps> = ({
handleSubmit, handleSubmit,
setFieldValue, setFieldValue,
isSubmitting, isSubmitting,
isValid,
}) => { }) => {
return ( return (
<Modal <Modal
@ -257,7 +262,7 @@ const SonarrModal: React.FC<SonarrModalProps> = ({
secondaryDisabled={ secondaryDisabled={
!values.apiKey || !values.hostname || !values.port || isTesting !values.apiKey || !values.hostname || !values.port || isTesting
} }
okDisabled={!isValidated || isSubmitting || isTesting} okDisabled={!isValidated || isSubmitting || isTesting || !isValid}
onOk={() => handleSubmit()} onOk={() => handleSubmit()}
title={ title={
!sonarr !sonarr
@ -452,10 +457,17 @@ const SonarrModal: React.FC<SonarrModalProps> = ({
as="select" as="select"
id="activeProfileId" id="activeProfileId"
name="activeProfileId" name="activeProfileId"
className="mt-1 form-select rounded-md block w-full pl-3 pr-10 py-2 text-base leading-6 bg-gray-700 border-gray-500 focus:outline-none focus:ring-blue focus:border-gray-500 sm:text-sm sm:leading-5" disabled={!isValidated || isTesting}
className="mt-1 form-select rounded-md block w-full pl-3 pr-10 py-2 text-base leading-6 bg-gray-700 border-gray-500 focus:outline-none focus:ring-blue focus:border-gray-500 sm:text-sm sm:leading-5 disabled:opacity-50"
> >
<option value=""> <option value="">
{intl.formatMessage(messages.selectQualityProfile)} {isTesting
? intl.formatMessage(messages.loadingprofiles)
: !isValidated
? intl.formatMessage(
messages.testFirstQualityProfiles
)
: intl.formatMessage(messages.selectQualityProfile)}
</option> </option>
{testResponse.profiles.length > 0 && {testResponse.profiles.length > 0 &&
testResponse.profiles.map((profile) => ( testResponse.profiles.map((profile) => (
@ -488,10 +500,15 @@ const SonarrModal: React.FC<SonarrModalProps> = ({
as="select" as="select"
id="rootFolder" id="rootFolder"
name="rootFolder" name="rootFolder"
className="mt-1 form-select block rounded-md w-full pl-3 pr-10 py-2 text-base leading-6 bg-gray-700 border-gray-500 focus:outline-none focus:ring-blue focus:border-gray-500 sm:text-sm sm:leading-5" disabled={!isValidated || isTesting}
className="mt-1 form-select block rounded-md w-full pl-3 pr-10 py-2 text-base leading-6 bg-gray-700 border-gray-500 focus:outline-none focus:ring-blue focus:border-gray-500 sm:text-sm sm:leading-5 disabled:opacity-50"
> >
<option value=""> <option value="">
{intl.formatMessage(messages.selectRootFolder)} {isTesting
? intl.formatMessage(messages.loadingrootfolders)
: !isValidated
? intl.formatMessage(messages.testFirstRootFolders)
: intl.formatMessage(messages.selectRootFolder)}
</option> </option>
{testResponse.rootFolders.length > 0 && {testResponse.rootFolders.length > 0 &&
testResponse.rootFolders.map((folder) => ( testResponse.rootFolders.map((folder) => (

@ -116,6 +116,8 @@
"components.Settings.RadarrModal.defaultserver": "Default Server", "components.Settings.RadarrModal.defaultserver": "Default Server",
"components.Settings.RadarrModal.editradarr": "Edit Radarr Server", "components.Settings.RadarrModal.editradarr": "Edit Radarr Server",
"components.Settings.RadarrModal.hostname": "Hostname", "components.Settings.RadarrModal.hostname": "Hostname",
"components.Settings.RadarrModal.loadingprofiles": "Loading quality profiles…",
"components.Settings.RadarrModal.loadingrootfolders": "Loading root folders…",
"components.Settings.RadarrModal.minimumAvailability": "Minimum Availability", "components.Settings.RadarrModal.minimumAvailability": "Minimum Availability",
"components.Settings.RadarrModal.port": "Port", "components.Settings.RadarrModal.port": "Port",
"components.Settings.RadarrModal.qualityprofile": "Quality Profile", "components.Settings.RadarrModal.qualityprofile": "Quality Profile",
@ -130,6 +132,8 @@
"components.Settings.RadarrModal.servernamePlaceholder": "A Radarr Server", "components.Settings.RadarrModal.servernamePlaceholder": "A Radarr Server",
"components.Settings.RadarrModal.ssl": "SSL", "components.Settings.RadarrModal.ssl": "SSL",
"components.Settings.RadarrModal.test": "Test", "components.Settings.RadarrModal.test": "Test",
"components.Settings.RadarrModal.testFirstQualityProfiles": "Test your connection to load quality profiles",
"components.Settings.RadarrModal.testFirstRootFolders": "Test your connection to load root folders",
"components.Settings.RadarrModal.testing": "Testing...", "components.Settings.RadarrModal.testing": "Testing...",
"components.Settings.RadarrModal.toastRadarrTestFailure": "Failed to connect to Radarr Server", "components.Settings.RadarrModal.toastRadarrTestFailure": "Failed to connect to Radarr Server",
"components.Settings.RadarrModal.toastRadarrTestSuccess": "Radarr connection established!", "components.Settings.RadarrModal.toastRadarrTestSuccess": "Radarr connection established!",
@ -156,6 +160,8 @@
"components.Settings.SonarrModal.defaultserver": "Default Server", "components.Settings.SonarrModal.defaultserver": "Default Server",
"components.Settings.SonarrModal.editsonarr": "Edit Sonarr Server", "components.Settings.SonarrModal.editsonarr": "Edit Sonarr Server",
"components.Settings.SonarrModal.hostname": "Hostname", "components.Settings.SonarrModal.hostname": "Hostname",
"components.Settings.SonarrModal.loadingprofiles": "Loading quality profiles…",
"components.Settings.SonarrModal.loadingrootfolders": "Loading root folders…",
"components.Settings.SonarrModal.port": "Port", "components.Settings.SonarrModal.port": "Port",
"components.Settings.SonarrModal.qualityprofile": "Quality Profile", "components.Settings.SonarrModal.qualityprofile": "Quality Profile",
"components.Settings.SonarrModal.rootfolder": "Root Folder", "components.Settings.SonarrModal.rootfolder": "Root Folder",
@ -169,6 +175,8 @@
"components.Settings.SonarrModal.servernamePlaceholder": "A Sonarr Server", "components.Settings.SonarrModal.servernamePlaceholder": "A Sonarr Server",
"components.Settings.SonarrModal.ssl": "SSL", "components.Settings.SonarrModal.ssl": "SSL",
"components.Settings.SonarrModal.test": "Test", "components.Settings.SonarrModal.test": "Test",
"components.Settings.SonarrModal.testFirstQualityProfiles": "Test your connection to load quality profiles",
"components.Settings.SonarrModal.testFirstRootFolders": "Test your connection to load root folders",
"components.Settings.SonarrModal.testing": "Testing...", "components.Settings.SonarrModal.testing": "Testing...",
"components.Settings.SonarrModal.toastRadarrTestFailure": "Could not connect to Sonarr Server", "components.Settings.SonarrModal.toastRadarrTestFailure": "Could not connect to Sonarr Server",
"components.Settings.SonarrModal.toastRadarrTestSuccess": "Sonarr connection established!", "components.Settings.SonarrModal.toastRadarrTestSuccess": "Sonarr connection established!",

Loading…
Cancel
Save