diff --git a/public/locales/en.json b/public/locales/en.json index 30f4f1da..b30d80e0 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -217,7 +217,7 @@ "call_timeout": "Call timeout", "compression_level": "Compression level", "connect_timeout": "Connect timeout", - "description": "In case no MIME-Type is defined, the \"default\" one will be used for the processing.\nSet \"{{value}}\" as the target type to disable processing for a MIME-Type", + "description": "In case no MIME-Type is defined, the \"default\" one will be used for the processing.\nSet the target mode to disabled to prevent processing for a MIME-Type", "headers": { "button": "Headers ({{count}})", "name": "Name", diff --git a/src/features/settings/ImageProcessing.utils.ts b/src/features/settings/ImageProcessing.utils.ts index 99b0bb1d..d2833e31 100644 --- a/src/features/settings/ImageProcessing.utils.ts +++ b/src/features/settings/ImageProcessing.utils.ts @@ -18,6 +18,7 @@ import { IMAGE_PROCESSING_COMPRESSION, IMAGE_PROCESSING_CONNECT_TIMEOUT, MIME_TYPE_PREFIX, + TARGET_DISABLED, } from '@/features/settings/Settings.constants.ts'; import { SettingsDownloadConversion, @@ -92,7 +93,13 @@ export const containsInvalidConversion = (conversions: TSettingsDownloadConversi ); export const getTargetMode = (target: string): ImageProcessingTargetMode => { - if (isUrlTargetMode(target)) { + const normalizedTargetMode = normalizeMimeType(target); + + if (normalizedTargetMode === TARGET_DISABLED) { + return ImageProcessingTargetMode.DISABLED; + } + + if (isUrlTargetMode(normalizedTargetMode)) { return ImageProcessingTargetMode.URL; } @@ -115,7 +122,7 @@ export const addStableIdToConversions = ( // eslint-disable-next-line no-plusplus id: (conversion as TSettingsDownloadConversion).id ?? COUNTER++, ...conversion, - mode: getTargetMode(conversion.target), + mode: getTargetMode(normalizeMimeType(conversion.target)), headers: conversion.headers ? addStableIdToHeaders(conversion.headers) : null, })); diff --git a/src/features/settings/Settings.constants.ts b/src/features/settings/Settings.constants.ts index 284f2dd8..b3654ec7 100644 --- a/src/features/settings/Settings.constants.ts +++ b/src/features/settings/Settings.constants.ts @@ -283,6 +283,9 @@ const IMAGE_PROCESSING_TARGET_MODES = Object.values(ImageProcessingTargetMode); const IMAGE_PROCESSING_TARGET_MODES_TO_TRANSLATION_KEY: { [flavor in ImageProcessingTargetMode]: SelectSettingValueDisplayInfo; } = { + [ImageProcessingTargetMode.DISABLED]: { + text: 'global.label.disabled', + }, [ImageProcessingTargetMode.IMAGE]: { text: 'download.settings.conversion.target_modes.image.title', description: 'download.settings.conversion.target_modes.image.description', @@ -298,6 +301,7 @@ export const IMAGE_PROCESSING_TARGET_MODES_SELECT_VALUES: SelectSettingValue = { [ImageProcessingType.DOWNLOAD]: 'download.settings.conversion.title', diff --git a/src/features/settings/Settings.types.ts b/src/features/settings/Settings.types.ts index 25990099..07a7239b 100644 --- a/src/features/settings/Settings.types.ts +++ b/src/features/settings/Settings.types.ts @@ -60,6 +60,7 @@ export type GlobalUpdateSkipEntriesSettings = Pick< export type LibrarySettingsType = Pick; export enum ImageProcessingTargetMode { + DISABLED = 'disabled', IMAGE = 'image', URL = 'url', } diff --git a/src/features/settings/components/images/Processing.tsx b/src/features/settings/components/images/Processing.tsx index d1810161..45692dfd 100644 --- a/src/features/settings/components/images/Processing.tsx +++ b/src/features/settings/components/images/Processing.tsx @@ -29,6 +29,7 @@ import { IMAGE_PROCESSING_CONNECT_TIMEOUT, IMAGE_PROCESSING_INPUT_WIDTH, IMAGE_PROCESSING_TARGET_MODES_SELECT_VALUES, + TARGET_DISABLED, } from '@/features/settings/Settings.constants.ts'; import { Select } from '@/base/components/inputs/Select.tsx'; import { TypographyMaxLines } from '@/base/components/texts/TypographyMaxLines.tsx'; @@ -58,6 +59,7 @@ export const Processing = ({ const [areHeadersCollapsed, setAreHeadersCollapsed] = useState(true); + const isDisabledMode = mode === ImageProcessingTargetMode.DISABLED; const isImageMode = mode === ImageProcessingTargetMode.IMAGE; const isCallTimeoutValid = isValidCallTimeoutSetting(callTimeout); @@ -124,6 +126,8 @@ export const Processing = ({ onChange({ ...conversion, mode: e.target.value, + target: + e.target.value === ImageProcessingTargetMode.DISABLED ? TARGET_DISABLED : '', }) } > @@ -134,105 +138,117 @@ export const Processing = ({ ))} - - onChange({ - ...conversion, - target: value, - }) - } - /> - {isImageMode ? ( - { + {!isDisabledMode && ( + onChange({ ...conversion, - compressionLevel: e.target.value ? Number(e.target.value) : null, - }); - }} + target: value, + }) + } /> - ) : ( - <> - - {t('global.date.label.second_other')} - - ), - }, - }} - onChange={(e) => { - onChange({ - ...conversion, - callTimeout: e.target.value - ? d(Number(e.target.value)).seconds.toISOString() - : null, - }); - }} - /> - - {t('global.date.label.second_other')} - - ), - }, - }} - onChange={(e) => { - onChange({ - ...conversion, - connectTimeout: e.target.value - ? d(Number(e.target.value)).seconds.toISOString() - : null, - }); - }} - /> - - )} + {(() => { + if (isDisabledMode) { + return null; + } + + if (isImageMode) { + return ( + { + onChange({ + ...conversion, + compressionLevel: e.target.value ? Number(e.target.value) : null, + }); + }} + /> + ); + } + + return ( + <> + + {t('global.date.label.second_other')} + + ), + }, + }} + onChange={(e) => { + onChange({ + ...conversion, + callTimeout: e.target.value + ? d(Number(e.target.value)).seconds.toISOString() + : null, + }); + }} + /> + + {t('global.date.label.second_other')} + + ), + }, + }} + onChange={(e) => { + onChange({ + ...conversion, + connectTimeout: e.target.value + ? d(Number(e.target.value)).seconds.toISOString() + : null, + }); + }} + /> + + + ); + })()} - {t('download.settings.conversion.description', { value: 'none' })} + {t('download.settings.conversion.description', { value: TARGET_DISABLED })} {tmpConversions.map((conversion, index) => { const { mimeType } = conversion;