feat: add validation to prevent testing new notification providers without saving

This commit is contained in:
GitHub Actions
2026-03-10 13:23:13 +00:00
parent 95c3adfa61
commit f3d69b0116
4 changed files with 16 additions and 10 deletions
+6 -7
View File
@@ -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"
+1 -1
View File
@@ -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",
+1
View File
@@ -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)",
+8 -2
View File
@@ -115,7 +115,12 @@ const ProviderForm: FC<{
const handleTest = () => {
const formData = watch();
testMutation.mutate({ ...formData, type: normalizeProviderType(formData.type) } as Partial<NotificationProvider>);
const currentType = normalizeProviderType(formData.type);
if (!formData.id && currentType !== 'email') {
toast.error(t('notificationProviders.saveBeforeTesting'));
return;
}
testMutation.mutate({ ...formData, type: currentType } as Partial<NotificationProvider>);
};
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"
>