From 07f0b88e30ceac7b64c8f39136a560e64d29998a Mon Sep 17 00:00:00 2001 From: Christian Byrne Date: Mon, 19 May 2025 20:18:19 -0700 Subject: [PATCH] Require description field to be non-empty when reporting issue from the UI (#3939) Co-authored-by: github-actions --- .../dialog/content/error/ReportIssuePanel.vue | 8 ++++++-- src/locales/en/main.json | 4 +++- src/locales/es/main.json | 2 ++ src/locales/fr/main.json | 2 ++ src/locales/ja/main.json | 2 ++ src/locales/ko/main.json | 2 ++ src/locales/ru/main.json | 2 ++ src/locales/zh/main.json | 2 ++ src/schemas/issueReportSchema.ts | 14 ++++++++++++-- 9 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/components/dialog/content/error/ReportIssuePanel.vue b/src/components/dialog/content/error/ReportIssuePanel.vue index 79bc5aa53..b6fc5748a 100644 --- a/src/components/dialog/content/error/ReportIssuePanel.vue +++ b/src/components/dialog/content/error/ReportIssuePanel.vue @@ -124,12 +124,16 @@ :aria-label="$t('issueReport.provideAdditionalDetails')" /> - {{ t('issueReport.validation.maxLength') }} + {{ + $field.value + ? t('issueReport.validation.maxLength') + : t('issueReport.validation.descriptionRequired') + }} diff --git a/src/locales/en/main.json b/src/locales/en/main.json index a72be931b..dd071b34f 100644 --- a/src/locales/en/main.json +++ b/src/locales/en/main.json @@ -203,7 +203,9 @@ "validation": { "maxLength": "Message too long", "invalidEmail": "Please enter a valid email address", - "selectIssueType": "Please select an issue type" + "selectIssueType": "Please select an issue type", + "descriptionRequired": "Description is required", + "helpTypeRequired": "Help type is required" } }, "color": { diff --git a/src/locales/es/main.json b/src/locales/es/main.json index 622f95f61..63a532ed7 100644 --- a/src/locales/es/main.json +++ b/src/locales/es/main.json @@ -498,6 +498,8 @@ "submitErrorReport": "Enviar Reporte de Error (Opcional)", "systemStats": "Estadísticas del Sistema", "validation": { + "descriptionRequired": "Se requiere una descripción", + "helpTypeRequired": "Se requiere el tipo de ayuda", "invalidEmail": "Por favor ingresa una dirección de correo electrónico válida", "maxLength": "Mensaje demasiado largo", "selectIssueType": "Por favor, seleccione un tipo de problema" diff --git a/src/locales/fr/main.json b/src/locales/fr/main.json index 783a53a47..63a93bd9a 100644 --- a/src/locales/fr/main.json +++ b/src/locales/fr/main.json @@ -498,6 +498,8 @@ "submitErrorReport": "Soumettre un rapport d'erreur (Facultatif)", "systemStats": "Statistiques du système", "validation": { + "descriptionRequired": "La description est requise", + "helpTypeRequired": "Le type d'aide est requis", "invalidEmail": "Veuillez entrer une adresse e-mail valide", "maxLength": "Message trop long", "selectIssueType": "Veuillez sélectionner un type de problème" diff --git a/src/locales/ja/main.json b/src/locales/ja/main.json index de5f8cb3e..f34b5744a 100644 --- a/src/locales/ja/main.json +++ b/src/locales/ja/main.json @@ -498,6 +498,8 @@ "submitErrorReport": "エラーレポートを提出する(オプション)", "systemStats": "システム統計", "validation": { + "descriptionRequired": "説明は必須です", + "helpTypeRequired": "ヘルプの種類は必須です", "invalidEmail": "有効なメールアドレスを入力してください", "maxLength": "メッセージが長すぎます", "selectIssueType": "問題の種類を選択してください" diff --git a/src/locales/ko/main.json b/src/locales/ko/main.json index d6a173629..bcf6003dc 100644 --- a/src/locales/ko/main.json +++ b/src/locales/ko/main.json @@ -498,6 +498,8 @@ "submitErrorReport": "오류 보고서 제출 (선택 사항)", "systemStats": "시스템 통계", "validation": { + "descriptionRequired": "설명은 필수입니다", + "helpTypeRequired": "도움 유형은 필수입니다", "invalidEmail": "유효한 이메일 주소를 입력해 주세요", "maxLength": "메시지가 너무 깁니다", "selectIssueType": "문제 유형을 선택해 주세요" diff --git a/src/locales/ru/main.json b/src/locales/ru/main.json index d8e8f8e2a..e788576ee 100644 --- a/src/locales/ru/main.json +++ b/src/locales/ru/main.json @@ -498,6 +498,8 @@ "submitErrorReport": "Отправить отчёт об ошибке (необязательно)", "systemStats": "Статистика системы", "validation": { + "descriptionRequired": "Описание обязательно", + "helpTypeRequired": "Тип помощи обязателен", "invalidEmail": "Пожалуйста, введите действительный адрес электронной почты", "maxLength": "Сообщение слишком длинное", "selectIssueType": "Пожалуйста, выберите тип проблемы" diff --git a/src/locales/zh/main.json b/src/locales/zh/main.json index 86b896eb6..f26c4b2ad 100644 --- a/src/locales/zh/main.json +++ b/src/locales/zh/main.json @@ -498,6 +498,8 @@ "submitErrorReport": "提交错误报告(可选)", "systemStats": "系统状态", "validation": { + "descriptionRequired": "描述为必填项", + "helpTypeRequired": "帮助类型为必选项", "invalidEmail": "请输入有效的电子邮件地址", "maxLength": "消息过长", "selectIssueType": "请选择一个问题类型" diff --git a/src/schemas/issueReportSchema.ts b/src/schemas/issueReportSchema.ts index fb580779d..d85f75cc5 100644 --- a/src/schemas/issueReportSchema.ts +++ b/src/schemas/issueReportSchema.ts @@ -1,10 +1,16 @@ import { z } from 'zod' +import { t } from '@/i18n' + const checkboxField = z.boolean().optional() export const issueReportSchema = z .object({ contactInfo: z.string().email().max(320).optional().or(z.literal('')), - details: z.string().max(5_000).optional(), + details: z + .string() + .min(1, { message: t('validation.descriptionRequired') }) + .max(5_000, { message: t('validation.maxLength', { length: 5_000 }) }) + .optional(), helpType: z.string().optional() }) .catchall(checkboxField) @@ -12,7 +18,11 @@ export const issueReportSchema = z path: ['details', 'helpType'] }) .refine((data) => data.helpType !== undefined && data.helpType !== '', { - message: 'Help type is required', + message: t('issueReport.validation.helpTypeRequired'), path: ['helpType'] }) + .refine((data) => data.details !== undefined && data.details !== '', { + message: t('issueReport.validation.descriptionRequired'), + path: ['details'] + }) export type IssueReportFormData = z.infer