From cbedb8e1cac465edcfed913f7ca06f92bc0ff37c Mon Sep 17 00:00:00 2001 From: James Date: Tue, 12 Aug 2025 14:30:46 +0100 Subject: [PATCH] Simplify settings definition --- .../tools/sanitize/SanitizeSettings.tsx | 46 +++---------------- 1 file changed, 7 insertions(+), 39 deletions(-) diff --git a/frontend/src/components/tools/sanitize/SanitizeSettings.tsx b/frontend/src/components/tools/sanitize/SanitizeSettings.tsx index f849d14f0..ac61d1f13 100644 --- a/frontend/src/components/tools/sanitize/SanitizeSettings.tsx +++ b/frontend/src/components/tools/sanitize/SanitizeSettings.tsx @@ -1,6 +1,6 @@ import { Stack, Text, Checkbox } from "@mantine/core"; import { useTranslation } from "react-i18next"; -import { SanitizeParameters } from "../../../hooks/tools/sanitize/useSanitizeParameters"; +import { SanitizeParameters, defaultParameters } from "../../../hooks/tools/sanitize/useSanitizeParameters"; interface SanitizeSettingsProps { parameters: SanitizeParameters; @@ -11,44 +11,12 @@ interface SanitizeSettingsProps { const SanitizeSettings = ({ parameters, onParameterChange, disabled = false }: SanitizeSettingsProps) => { const { t } = useTranslation(); - const options = [ - { - key: 'removeJavaScript' as const, - label: t('sanitize.options.removeJavaScript', 'Remove JavaScript'), - description: t('sanitize.options.removeJavaScript.desc', 'Remove JavaScript actions and scripts from the PDF'), - default: true, - }, - { - key: 'removeEmbeddedFiles' as const, - label: t('sanitize.options.removeEmbeddedFiles', 'Remove Embedded Files'), - description: t('sanitize.options.removeEmbeddedFiles.desc', 'Remove any files embedded within the PDF'), - default: true, - }, - { - key: 'removeXMPMetadata' as const, - label: t('sanitize.options.removeXMPMetadata', 'Remove XMP Metadata'), - description: t('sanitize.options.removeXMPMetadata.desc', 'Remove XMP metadata from the PDF'), - default: false, - }, - { - key: 'removeMetadata' as const, - label: t('sanitize.options.removeMetadata', 'Remove Document Metadata'), - description: t('sanitize.options.removeMetadata.desc', 'Remove document information metadata (title, author, etc.)'), - default: false, - }, - { - key: 'removeLinks' as const, - label: t('sanitize.options.removeLinks', 'Remove Links'), - description: t('sanitize.options.removeLinks.desc', 'Remove external links and launch actions from the PDF'), - default: false, - }, - { - key: 'removeFonts' as const, - label: t('sanitize.options.removeFonts', 'Remove Fonts'), - description: t('sanitize.options.removeFonts.desc', 'Remove embedded fonts from the PDF'), - default: false, - }, - ]; + const options = Object.entries(defaultParameters).map(([key, value]) => ({ + key: key as keyof SanitizeParameters, + label: t(`sanitize.options.${key}`, key), + description: t(`sanitize.options.${key}.desc`, `${key} from the PDF`), + default: value, + })); return (