diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 2e70c021..c4c80e92 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -59,7 +59,7 @@ "eslint-plugin-no-unsanitized": "^4.1.5", "eslint-plugin-promise": "^7.2.1", "eslint-plugin-react-compiler": "^19.1.0-rc.2", - "eslint-plugin-react-hooks": "^7.0.1", + "eslint-plugin-react-hooks": "^6.1.1", "eslint-plugin-react-refresh": "^0.5.2", "eslint-plugin-security": "^4.0.0", "eslint-plugin-sonarjs": "^4.0.1", @@ -6043,17 +6043,16 @@ } }, "node_modules/eslint-plugin-react-hooks": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-7.0.1.tgz", - "integrity": "sha512-O0d0m04evaNzEPoSW+59Mezf8Qt0InfgGIBJnpC0h3NH/WjUAR7BIKUfysC6todmtiZ/A0oUVS8Gce0WhBrHsA==", + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-6.1.1.tgz", + "integrity": "sha512-St9EKZzOAQF704nt2oJvAKZHjhrpg25ClQoaAlHmPZuajFldVLqRDW4VBNAS01NzeiQF0m0qhG1ZA807K6aVaQ==", "dev": true, "license": "MIT", "dependencies": { "@babel/core": "^7.24.4", "@babel/parser": "^7.24.4", - "hermes-parser": "^0.25.1", - "zod": "^3.25.0 || ^4.0.0", - "zod-validation-error": "^3.5.0 || ^4.0.0" + "zod": "^3.22.4 || ^4.0.0", + "zod-validation-error": "^3.0.3 || ^4.0.0" }, "engines": { "node": ">=18" diff --git a/frontend/package.json b/frontend/package.json index 75e29034..3c75e43e 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -78,7 +78,7 @@ "eslint-plugin-no-unsanitized": "^4.1.5", "eslint-plugin-promise": "^7.2.1", "eslint-plugin-react-compiler": "^19.1.0-rc.2", - "eslint-plugin-react-hooks": "^7.0.1", + "eslint-plugin-react-hooks": "^6.1.1", "eslint-plugin-react-refresh": "^0.5.2", "eslint-plugin-security": "^4.0.0", "eslint-plugin-sonarjs": "^4.0.1", diff --git a/frontend/src/locales/en/translation.json b/frontend/src/locales/en/translation.json index d0f465c2..83fc647b 100644 --- a/frontend/src/locales/en/translation.json +++ b/frontend/src/locales/en/translation.json @@ -566,6 +566,7 @@ "sendTest": "Send Test Notification", "testSent": "Test notification sent!", "testFailed": "Failed to send test", + "saveBeforeTesting": "Save the provider first before testing", "deleteConfirm": "Are you sure?", "noProviders": "No notification providers configured.", "deprecatedReadOnly": "Deprecated (Read-only)", diff --git a/frontend/src/pages/Notifications.tsx b/frontend/src/pages/Notifications.tsx index 1ab50472..7f623144 100644 --- a/frontend/src/pages/Notifications.tsx +++ b/frontend/src/pages/Notifications.tsx @@ -115,7 +115,12 @@ const ProviderForm: FC<{ const handleTest = () => { const formData = watch(); - testMutation.mutate({ ...formData, type: normalizeProviderType(formData.type) } as Partial); + const currentType = normalizeProviderType(formData.type); + if (!formData.id && currentType !== 'email') { + toast.error(t('notificationProviders.saveBeforeTesting')); + return; + } + testMutation.mutate({ ...formData, type: currentType } as Partial); }; const handlePreview = async () => { @@ -141,6 +146,7 @@ const ProviderForm: FC<{ const isGotify = type === 'gotify'; const isTelegram = type === 'telegram'; const isEmail = type === 'email'; + const isNew = !watch('id'); useEffect(() => { if (type !== 'gotify' && type !== 'telegram') { setValue('gotify_token', '', { shouldDirty: false, shouldTouch: false }); @@ -372,7 +378,7 @@ const ProviderForm: FC<{ type="button" variant="secondary" onClick={handleTest} - disabled={testMutation.isPending} + disabled={testMutation.isPending || (isNew && !isEmail)} data-testid="provider-test-btn" className="min-w-20" >