corpushub-design-system 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,7 +8,7 @@ export default function ServerErrorReport({ errorContext, corpus, onClose, onSen
|
|
|
8
8
|
const { t } = useTranslation('common');
|
|
9
9
|
const formRef = useRef(null);
|
|
10
10
|
const [sending, setSending] = useState(false);
|
|
11
|
-
const [canSend, setCanSend] = useState(
|
|
11
|
+
const [canSend, setCanSend] = useState(false);
|
|
12
12
|
return (_jsx(AppModal, { title: t('server.error.report.modal.title'), subtitle: t('server.error.report.modal.subtitle'), close: onClose, confirm: () => {
|
|
13
13
|
void formRef.current?.send();
|
|
14
14
|
}, disableConfirm: sending || !canSend, confirmLabel: t('server.error.report.modal.send'), className: "server-error-report-modal", children: _jsx(ServerErrorReportForm, { ref: formRef, errorContext: errorContext, corpus: corpus, intent: "error", onSent: onSent, onSendingChange: setSending, onCanSendChange: setCanSend }) }));
|
|
@@ -8,27 +8,33 @@ import { Button } from '../../primitives';
|
|
|
8
8
|
import { captureTabScreenshot } from './captureTabScreenshot';
|
|
9
9
|
import { getConsoleLogs } from './consoleCapture';
|
|
10
10
|
import './styles.scss';
|
|
11
|
-
const DEFAULT_USER_MESSAGE = 'No extra information given by the user';
|
|
12
11
|
const ServerErrorReportForm = forwardRef(function ServerErrorReportForm({ errorContext, corpus, intent = 'error', showSendButton = false, onSent, onSendingChange, onCanSendChange, className, }, ref) {
|
|
13
12
|
const { t, i18n } = useTranslation('common');
|
|
14
13
|
const [userMessage, setUserMessage] = useState('');
|
|
15
14
|
const [sending, setSending] = useState(false);
|
|
16
15
|
const [sendError, setSendError] = useState(null);
|
|
17
|
-
const canSend = !sending;
|
|
16
|
+
const canSend = !!userMessage.trim() && !sending;
|
|
18
17
|
const placeholderKey = intent === 'feedback'
|
|
19
18
|
? 'server.error.report.feedback.placeholder'
|
|
20
19
|
: 'server.error.report.modal.placeholder';
|
|
21
20
|
const sendLabelKey = intent === 'feedback'
|
|
22
21
|
? 'server.error.report.feedback.send'
|
|
23
22
|
: 'server.error.report.modal.send';
|
|
23
|
+
const validationKey = intent === 'feedback'
|
|
24
|
+
? 'server.error.report.feedback.validation'
|
|
25
|
+
: 'server.error.report.validation';
|
|
24
26
|
const handleSend = async () => {
|
|
27
|
+
if (!userMessage.trim()) {
|
|
28
|
+
setSendError(t(validationKey));
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
25
31
|
setSending(true);
|
|
26
32
|
onSendingChange?.(true);
|
|
27
33
|
setSendError(null);
|
|
28
34
|
try {
|
|
29
35
|
const screenshot = await captureTabScreenshot();
|
|
30
36
|
await ErrorReportService.send({
|
|
31
|
-
userMessage
|
|
37
|
+
userMessage,
|
|
32
38
|
errorContext,
|
|
33
39
|
sendContext: {
|
|
34
40
|
locale: i18n.resolvedLanguage || i18n.language,
|