|
|
@@ -3,6 +3,8 @@ import { useCallback, useEffect, useState } from 'react';
|
|
|
import { useTranslation } from 'next-i18next';
|
|
|
import { useForm } from 'react-hook-form';
|
|
|
|
|
|
+import { toastError, toastSuccess } from '~/client/util/toastr';
|
|
|
+
|
|
|
import {
|
|
|
type ContentDispositionSettings as ContentDispositionSettingsType,
|
|
|
useContentDisposition,
|
|
|
@@ -92,7 +94,10 @@ const ContentDispositionSettings: React.FC = () => {
|
|
|
const attachmentMimeTypes = watch('attachmentMimeTypes');
|
|
|
|
|
|
const handleSetMimeType = useCallback(
|
|
|
- (disposition: 'inline' | 'attachment') => {
|
|
|
+ (disposition: 'inline' | 'attachment', event: React.MouseEvent) => {
|
|
|
+ event.preventDefault();
|
|
|
+ event.stopPropagation();
|
|
|
+
|
|
|
const mimeType = normalizeMimeType(currentInput);
|
|
|
if (!mimeType) return;
|
|
|
|
|
|
@@ -136,9 +141,18 @@ const ContentDispositionSettings: React.FC = () => {
|
|
|
try {
|
|
|
setError(null);
|
|
|
await updateSettings(data);
|
|
|
+
|
|
|
+ toastSuccess(
|
|
|
+ t('toaster.update_successed', {
|
|
|
+ target: t('markdown_settings.content-disposition_header'),
|
|
|
+ ns: 'commons',
|
|
|
+ }),
|
|
|
+ );
|
|
|
+
|
|
|
reset(data);
|
|
|
} catch (err) {
|
|
|
setError((err as Error).message);
|
|
|
+ toastError(err);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -168,7 +182,7 @@ const ContentDispositionSettings: React.FC = () => {
|
|
|
<button
|
|
|
className="btn btn-primary px-3 flex-shrink-0 rounded-3 fw-bold"
|
|
|
type="button"
|
|
|
- onClick={() => handleSetMimeType('inline')}
|
|
|
+ onClick={(e) => handleSetMimeType('inline', e)}
|
|
|
disabled={!currentInput.trim() || isUpdating}
|
|
|
>
|
|
|
{t(
|
|
|
@@ -178,7 +192,7 @@ const ContentDispositionSettings: React.FC = () => {
|
|
|
<button
|
|
|
className="btn btn-primary text-white px-3 flex-shrink-0 rounded-3 fw-bold"
|
|
|
type="button"
|
|
|
- onClick={() => handleSetMimeType('attachment')}
|
|
|
+ onClick={(e) => handleSetMimeType('attachment', e)}
|
|
|
disabled={!currentInput.trim() || isUpdating}
|
|
|
>
|
|
|
{t(
|