mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-16 11:23:10 +02:00
Revert "Revert "Sync provider settings with settings.yml in config UI"" (#5273)
Reverts Stirling-Tools/Stirling-PDF#5271
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { Paper, Group, Text, Button, Collapse, Stack, TextInput, Textarea, Switch, PasswordInput } from '@mantine/core';
|
import { Paper, Group, Text, Button, Collapse, Stack, TextInput, Textarea, Switch, PasswordInput } from '@mantine/core';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import LocalIcon from '@app/components/shared/LocalIcon';
|
import LocalIcon from '@app/components/shared/LocalIcon';
|
||||||
@@ -25,14 +25,22 @@ export default function ProviderCard({
|
|||||||
const [expanded, setExpanded] = useState(false);
|
const [expanded, setExpanded] = useState(false);
|
||||||
const [localSettings, setLocalSettings] = useState<Record<string, any>>(settings);
|
const [localSettings, setLocalSettings] = useState<Record<string, any>>(settings);
|
||||||
|
|
||||||
|
// Keep local settings in sync with incoming settings (values loaded from settings.yml)
|
||||||
|
useEffect(() => {
|
||||||
|
if (!expanded) {
|
||||||
|
setLocalSettings(settings);
|
||||||
|
}
|
||||||
|
}, [settings, expanded]);
|
||||||
|
|
||||||
// Initialize local settings with defaults when opening an unconfigured provider
|
// Initialize local settings with defaults when opening an unconfigured provider
|
||||||
const handleConnectToggle = () => {
|
const handleConnectToggle = () => {
|
||||||
if (!isConfigured && !expanded) {
|
if (!isConfigured && !expanded) {
|
||||||
// First time opening an unconfigured provider - initialize with defaults
|
// First time opening an unconfigured provider - initialize with defaults
|
||||||
const defaultSettings: Record<string, any> = {};
|
// while preserving any values already present (from settings.yml)
|
||||||
|
const defaultSettings: Record<string, any> = { ...settings };
|
||||||
provider.fields.forEach((field) => {
|
provider.fields.forEach((field) => {
|
||||||
if (field.defaultValue !== undefined) {
|
if (field.defaultValue !== undefined) {
|
||||||
defaultSettings[field.key] = field.defaultValue;
|
defaultSettings[field.key] = defaultSettings[field.key] ?? field.defaultValue;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setLocalSettings(defaultSettings);
|
setLocalSettings(defaultSettings);
|
||||||
|
|||||||
+1
@@ -422,6 +422,7 @@ export default function AdminConnectionsSection() {
|
|||||||
key={provider.id}
|
key={provider.id}
|
||||||
provider={provider}
|
provider={provider}
|
||||||
isConfigured={false}
|
isConfigured={false}
|
||||||
|
settings={getProviderSettings(provider)}
|
||||||
onSave={(providerSettings) => handleProviderSave(provider, providerSettings)}
|
onSave={(providerSettings) => handleProviderSave(provider, providerSettings)}
|
||||||
disabled={!loginEnabled}
|
disabled={!loginEnabled}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user