Simplify disabling image processing for mime-type
This commit is contained in:
@@ -217,7 +217,7 @@
|
|||||||
"call_timeout": "Call timeout",
|
"call_timeout": "Call timeout",
|
||||||
"compression_level": "Compression level",
|
"compression_level": "Compression level",
|
||||||
"connect_timeout": "Connect timeout",
|
"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": {
|
"headers": {
|
||||||
"button": "Headers ({{count}})",
|
"button": "Headers ({{count}})",
|
||||||
"name": "Name",
|
"name": "Name",
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import {
|
|||||||
IMAGE_PROCESSING_COMPRESSION,
|
IMAGE_PROCESSING_COMPRESSION,
|
||||||
IMAGE_PROCESSING_CONNECT_TIMEOUT,
|
IMAGE_PROCESSING_CONNECT_TIMEOUT,
|
||||||
MIME_TYPE_PREFIX,
|
MIME_TYPE_PREFIX,
|
||||||
|
TARGET_DISABLED,
|
||||||
} from '@/features/settings/Settings.constants.ts';
|
} from '@/features/settings/Settings.constants.ts';
|
||||||
import {
|
import {
|
||||||
SettingsDownloadConversion,
|
SettingsDownloadConversion,
|
||||||
@@ -92,7 +93,13 @@ export const containsInvalidConversion = (conversions: TSettingsDownloadConversi
|
|||||||
);
|
);
|
||||||
|
|
||||||
export const getTargetMode = (target: string): ImageProcessingTargetMode => {
|
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;
|
return ImageProcessingTargetMode.URL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +122,7 @@ export const addStableIdToConversions = (
|
|||||||
// eslint-disable-next-line no-plusplus
|
// eslint-disable-next-line no-plusplus
|
||||||
id: (conversion as TSettingsDownloadConversion).id ?? COUNTER++,
|
id: (conversion as TSettingsDownloadConversion).id ?? COUNTER++,
|
||||||
...conversion,
|
...conversion,
|
||||||
mode: getTargetMode(conversion.target),
|
mode: getTargetMode(normalizeMimeType(conversion.target)),
|
||||||
headers: conversion.headers ? addStableIdToHeaders(conversion.headers) : null,
|
headers: conversion.headers ? addStableIdToHeaders(conversion.headers) : null,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -283,6 +283,9 @@ const IMAGE_PROCESSING_TARGET_MODES = Object.values(ImageProcessingTargetMode);
|
|||||||
const IMAGE_PROCESSING_TARGET_MODES_TO_TRANSLATION_KEY: {
|
const IMAGE_PROCESSING_TARGET_MODES_TO_TRANSLATION_KEY: {
|
||||||
[flavor in ImageProcessingTargetMode]: SelectSettingValueDisplayInfo;
|
[flavor in ImageProcessingTargetMode]: SelectSettingValueDisplayInfo;
|
||||||
} = {
|
} = {
|
||||||
|
[ImageProcessingTargetMode.DISABLED]: {
|
||||||
|
text: 'global.label.disabled',
|
||||||
|
},
|
||||||
[ImageProcessingTargetMode.IMAGE]: {
|
[ImageProcessingTargetMode.IMAGE]: {
|
||||||
text: 'download.settings.conversion.target_modes.image.title',
|
text: 'download.settings.conversion.target_modes.image.title',
|
||||||
description: 'download.settings.conversion.target_modes.image.description',
|
description: 'download.settings.conversion.target_modes.image.description',
|
||||||
@@ -298,6 +301,7 @@ export const IMAGE_PROCESSING_TARGET_MODES_SELECT_VALUES: SelectSettingValue<Ima
|
|||||||
export const IMAGE_PROCESSING_INPUT_WIDTH = 250;
|
export const IMAGE_PROCESSING_INPUT_WIDTH = 250;
|
||||||
export const DEFAULT_MIME_TYPE = 'default';
|
export const DEFAULT_MIME_TYPE = 'default';
|
||||||
export const MIME_TYPE_PREFIX = 'image/';
|
export const MIME_TYPE_PREFIX = 'image/';
|
||||||
|
export const TARGET_DISABLED = 'none';
|
||||||
|
|
||||||
export const IMAGE_PROCESSING_TYPE_TO_TRANSLATION: Record<ImageProcessingType, TranslationKey> = {
|
export const IMAGE_PROCESSING_TYPE_TO_TRANSLATION: Record<ImageProcessingType, TranslationKey> = {
|
||||||
[ImageProcessingType.DOWNLOAD]: 'download.settings.conversion.title',
|
[ImageProcessingType.DOWNLOAD]: 'download.settings.conversion.title',
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ export type GlobalUpdateSkipEntriesSettings = Pick<
|
|||||||
export type LibrarySettingsType = Pick<ServerSettings, 'updateMangas'>;
|
export type LibrarySettingsType = Pick<ServerSettings, 'updateMangas'>;
|
||||||
|
|
||||||
export enum ImageProcessingTargetMode {
|
export enum ImageProcessingTargetMode {
|
||||||
|
DISABLED = 'disabled',
|
||||||
IMAGE = 'image',
|
IMAGE = 'image',
|
||||||
URL = 'url',
|
URL = 'url',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import {
|
|||||||
IMAGE_PROCESSING_CONNECT_TIMEOUT,
|
IMAGE_PROCESSING_CONNECT_TIMEOUT,
|
||||||
IMAGE_PROCESSING_INPUT_WIDTH,
|
IMAGE_PROCESSING_INPUT_WIDTH,
|
||||||
IMAGE_PROCESSING_TARGET_MODES_SELECT_VALUES,
|
IMAGE_PROCESSING_TARGET_MODES_SELECT_VALUES,
|
||||||
|
TARGET_DISABLED,
|
||||||
} from '@/features/settings/Settings.constants.ts';
|
} from '@/features/settings/Settings.constants.ts';
|
||||||
import { Select } from '@/base/components/inputs/Select.tsx';
|
import { Select } from '@/base/components/inputs/Select.tsx';
|
||||||
import { TypographyMaxLines } from '@/base/components/texts/TypographyMaxLines.tsx';
|
import { TypographyMaxLines } from '@/base/components/texts/TypographyMaxLines.tsx';
|
||||||
@@ -58,6 +59,7 @@ export const Processing = ({
|
|||||||
|
|
||||||
const [areHeadersCollapsed, setAreHeadersCollapsed] = useState(true);
|
const [areHeadersCollapsed, setAreHeadersCollapsed] = useState(true);
|
||||||
|
|
||||||
|
const isDisabledMode = mode === ImageProcessingTargetMode.DISABLED;
|
||||||
const isImageMode = mode === ImageProcessingTargetMode.IMAGE;
|
const isImageMode = mode === ImageProcessingTargetMode.IMAGE;
|
||||||
|
|
||||||
const isCallTimeoutValid = isValidCallTimeoutSetting(callTimeout);
|
const isCallTimeoutValid = isValidCallTimeoutSetting(callTimeout);
|
||||||
@@ -124,6 +126,8 @@ export const Processing = ({
|
|||||||
onChange({
|
onChange({
|
||||||
...conversion,
|
...conversion,
|
||||||
mode: e.target.value,
|
mode: e.target.value,
|
||||||
|
target:
|
||||||
|
e.target.value === ImageProcessingTargetMode.DISABLED ? TARGET_DISABLED : '',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
@@ -134,6 +138,7 @@ export const Processing = ({
|
|||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
|
{!isDisabledMode && (
|
||||||
<MimeTypeTextField
|
<MimeTypeTextField
|
||||||
mode={mode}
|
mode={mode}
|
||||||
shouldAutoFocus={false}
|
shouldAutoFocus={false}
|
||||||
@@ -148,7 +153,14 @@ export const Processing = ({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
{isImageMode ? (
|
)}
|
||||||
|
{(() => {
|
||||||
|
if (isDisabledMode) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isImageMode) {
|
||||||
|
return (
|
||||||
<TextField
|
<TextField
|
||||||
sx={{ width: IMAGE_PROCESSING_INPUT_WIDTH }}
|
sx={{ width: IMAGE_PROCESSING_INPUT_WIDTH }}
|
||||||
label={t('download.settings.conversion.compression_level')}
|
label={t('download.settings.conversion.compression_level')}
|
||||||
@@ -168,7 +180,10 @@ export const Processing = ({
|
|||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
) : (
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
<>
|
<>
|
||||||
<TextField
|
<TextField
|
||||||
sx={{ width: IMAGE_PROCESSING_INPUT_WIDTH }}
|
sx={{ width: IMAGE_PROCESSING_INPUT_WIDTH }}
|
||||||
@@ -232,7 +247,8 @@ export const Processing = ({
|
|||||||
})}
|
})}
|
||||||
</Button>
|
</Button>
|
||||||
</>
|
</>
|
||||||
)}
|
);
|
||||||
|
})()}
|
||||||
</Stack>
|
</Stack>
|
||||||
<CustomTooltip disabled={isDisabled} title={t('chapter.action.download.delete.label.action')}>
|
<CustomTooltip disabled={isDisabled} title={t('chapter.action.download.delete.label.action')}>
|
||||||
<IconButton
|
<IconButton
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import Button from '@mui/material/Button';
|
|||||||
import {
|
import {
|
||||||
IMAGE_PROCESSING_TYPE_TO_SETTING,
|
IMAGE_PROCESSING_TYPE_TO_SETTING,
|
||||||
IMAGE_PROCESSING_TYPE_TO_TRANSLATION,
|
IMAGE_PROCESSING_TYPE_TO_TRANSLATION,
|
||||||
|
TARGET_DISABLED,
|
||||||
} from '@/features/settings/Settings.constants.ts';
|
} from '@/features/settings/Settings.constants.ts';
|
||||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||||
import { ImageProcessingType, ServerSettings } from '@/features/settings/Settings.types.ts';
|
import { ImageProcessingType, ServerSettings } from '@/features/settings/Settings.types.ts';
|
||||||
@@ -92,7 +93,7 @@ export const ImageProcessingSetting = ({ type }: { type: ImageProcessingType })
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack sx={{ p: 2, gap: 3 }}>
|
<Stack sx={{ p: 2, gap: 3 }}>
|
||||||
<Typography>{t('download.settings.conversion.description', { value: 'none' })}</Typography>
|
<Typography>{t('download.settings.conversion.description', { value: TARGET_DISABLED })}</Typography>
|
||||||
<Stack sx={{ flexDirection: 'column', gap: 5 }}>
|
<Stack sx={{ flexDirection: 'column', gap: 5 }}>
|
||||||
{tmpConversions.map((conversion, index) => {
|
{tmpConversions.map((conversion, index) => {
|
||||||
const { mimeType } = conversion;
|
const { mimeType } = conversion;
|
||||||
|
|||||||
Reference in New Issue
Block a user