mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-11-16 01:21:16 +01:00
## default
<img width="1012" height="627"
alt="{BF57458D-50A6-4057-94F1-D6AB4628EFD8}"
src="https://github.com/user-attachments/assets/85e550ab-0aed-4341-be95-d5d3bc7146db"
/>
## disabled
<img width="1141" height="620"
alt="{140DB87B-05CF-4E0E-A14A-ED15075BD2EE}"
src="https://github.com/user-attachments/assets/e0f56e84-fb9d-4787-b5cb-ba7c5a54b1e1"
/>
## unzip options
<img width="530" height="255"
alt="{482CE185-73D5-4D90-91BB-B9305C711391}"
src="https://github.com/user-attachments/assets/609b18ee-4eae-4cee-afc1-5db01f9d1088"
/>
<img width="579" height="473"
alt="{4DFCA96D-792D-4370-8C62-4BA42C9F1A5F}"
src="https://github.com/user-attachments/assets/c67fa4af-04ef-41df-9420-65ce4247e25b"
/>
## pop up and maintains version metadata
<img width="1071" height="1220"
alt="{7F2A785C-5717-4A79-9D45-74BDA46DF273}"
src="https://github.com/user-attachments/assets/9374cd2a-b7e5-46c4-a722-e141ab42f0de"
/>
---------
Co-authored-by: Connor Yoh <connor@stirlingpdf.com>
90 lines
3.5 KiB
TypeScript
90 lines
3.5 KiB
TypeScript
import React, { useState, useEffect } from 'react';
|
|
import { Paper, Stack, Switch, Text, Tooltip, NumberInput } from '@mantine/core';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { usePreferences } from '../../../../contexts/PreferencesContext';
|
|
|
|
const DEFAULT_AUTO_UNZIP_FILE_LIMIT = 4;
|
|
|
|
const GeneralSection: React.FC = () => {
|
|
const { t } = useTranslation();
|
|
const { preferences, updatePreference } = usePreferences();
|
|
const [fileLimitInput, setFileLimitInput] = useState<number | string>(preferences.autoUnzipFileLimit);
|
|
|
|
// Sync local state with preference changes
|
|
useEffect(() => {
|
|
setFileLimitInput(preferences.autoUnzipFileLimit);
|
|
}, [preferences.autoUnzipFileLimit]);
|
|
|
|
return (
|
|
<Stack gap="lg">
|
|
<div>
|
|
<Text fw={600} size="lg">{t('settings.general.title', 'General')}</Text>
|
|
<Text size="sm" c="dimmed">
|
|
{t('settings.general.description', 'Configure general application preferences.')}
|
|
</Text>
|
|
</div>
|
|
|
|
<Paper withBorder p="md" radius="md">
|
|
<Stack gap="md">
|
|
<Tooltip
|
|
label={t('settings.general.autoUnzipTooltip', 'Automatically extract ZIP files returned from API operations. Disable to keep ZIP files intact. This does not affect automation workflows.')}
|
|
multiline
|
|
w={300}
|
|
withArrow
|
|
>
|
|
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', cursor: 'help' }}>
|
|
<div>
|
|
<Text fw={500} size="sm">
|
|
{t('settings.general.autoUnzip', 'Auto-unzip API responses')}
|
|
</Text>
|
|
<Text size="xs" c="dimmed" mt={4}>
|
|
{t('settings.general.autoUnzipDescription', 'Automatically extract files from ZIP responses')}
|
|
</Text>
|
|
</div>
|
|
<Switch
|
|
checked={preferences.autoUnzip}
|
|
onChange={(event) => updatePreference('autoUnzip', event.currentTarget.checked)}
|
|
/>
|
|
</div>
|
|
</Tooltip>
|
|
|
|
<Tooltip
|
|
label={t('settings.general.autoUnzipFileLimitTooltip', 'Only unzip if the ZIP contains this many files or fewer. Set higher to extract larger ZIPs.')}
|
|
multiline
|
|
w={300}
|
|
withArrow
|
|
>
|
|
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', cursor: 'help' }}>
|
|
<div>
|
|
<Text fw={500} size="sm">
|
|
{t('settings.general.autoUnzipFileLimit', 'Auto-unzip file limit')}
|
|
</Text>
|
|
<Text size="xs" c="dimmed" mt={4}>
|
|
{t('settings.general.autoUnzipFileLimitDescription', 'Maximum number of files to extract from ZIP')}
|
|
</Text>
|
|
</div>
|
|
<NumberInput
|
|
value={fileLimitInput}
|
|
onChange={setFileLimitInput}
|
|
onBlur={() => {
|
|
const numValue = Number(fileLimitInput);
|
|
const finalValue = (!fileLimitInput || isNaN(numValue) || numValue < 1 || numValue > 100) ? DEFAULT_AUTO_UNZIP_FILE_LIMIT : numValue;
|
|
setFileLimitInput(finalValue);
|
|
updatePreference('autoUnzipFileLimit', finalValue);
|
|
}}
|
|
min={1}
|
|
max={100}
|
|
step={1}
|
|
disabled={!preferences.autoUnzip}
|
|
style={{ width: 90 }}
|
|
/>
|
|
</div>
|
|
</Tooltip>
|
|
</Stack>
|
|
</Paper>
|
|
</Stack>
|
|
);
|
|
};
|
|
|
|
export default GeneralSection;
|