fix(webui): save settings when editing completes (NAN-323) (#6384)
* fix(webui): save settings when editing completes (NAN-323) * fix(webui): close settings completion and verification gaps * refactor(webui): simplify settings edit ownership
This commit is contained in:
1 parent
26e1f41a00
commit
c6babb20e8
34 files changed
+1363
-388
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { useRef, type ReactNode } from "react";
|
||||
import { Check, ChevronDown, Clipboard, Loader2 } from "lucide-react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
@@ -38,14 +38,12 @@ export interface ChannelSetupSurfaceViewProps {
|
||||
connectFlow?: ReactNode;
|
||||
onAdvancedOpenChange: (open: boolean) => void;
|
||||
onChangeField: (key: string, value: string) => void;
|
||||
onFieldBlur: (key: string) => void;
|
||||
onToggleSecret: (key: string) => void;
|
||||
onClearSecret: (key: string, clear: boolean) => void;
|
||||
onApplyPreset: (preset: ChannelProviderPreset) => void;
|
||||
onSubmit: () => void;
|
||||
onCheckConnection: () => void;
|
||||
onToggleEnabled: (enabled: boolean) => void;
|
||||
onSaveConnectionSettings: () => void;
|
||||
onCopyCommand: () => void;
|
||||
onNotice: (notice: string | null) => void;
|
||||
}
|
||||
@@ -55,14 +53,17 @@ export function ChannelSetupSurfaceView({
|
||||
configuredFields, fieldValues, visibleSecrets, clearedSecrets, fieldErrors, actionPending,
|
||||
enabled, autoSaving, autoSaveState, advancedOpen, advancedPanelId, validation, validating,
|
||||
notice, connectFlow, onAdvancedOpenChange,
|
||||
onChangeField: setFieldValue, onFieldBlur: saveSecretOnBlur, onToggleSecret: toggleSecret,
|
||||
onChangeField: setFieldValue, onToggleSecret: toggleSecret,
|
||||
onClearSecret: setSecretCleared, onApplyPreset: applyPreset, onSubmit: saveCredentialSettings,
|
||||
onCheckConnection: checkCurrentSettings, onToggleEnabled: toggleEnabled,
|
||||
onSaveConnectionSettings: saveConnectionSettings, onCopyCommand: copyCommand, onNotice: setNotice,
|
||||
onCopyCommand: copyCommand, onNotice: setNotice,
|
||||
}: ChannelSetupSurfaceViewProps) {
|
||||
const { t } = useTranslation();
|
||||
const tx = (key: string, fallback: string) => t(key, { defaultValue: fallback });
|
||||
const mode = setup.mode ?? "credentials";
|
||||
// Keep feedback's footprint so blur-save updates cannot move the close target mid-click.
|
||||
const lastNotice = useRef(notice);
|
||||
if (notice) lastNotice.current = notice;
|
||||
const hasAdvanced = advancedFields.length > 0 || savedSecretFields.length > 0 || availablePresets.length > 0;
|
||||
const advancedFormProps = {
|
||||
fields: advancedFields,
|
||||
@@ -70,7 +71,6 @@ export function ChannelSetupSurfaceView({
|
||||
configuredFields,
|
||||
visibleSecrets,
|
||||
onChange: setFieldValue,
|
||||
onFieldBlur: saveSecretOnBlur,
|
||||
onToggleSecret: toggleSecret,
|
||||
errors: fieldErrors,
|
||||
clearedSecrets,
|
||||
@@ -217,7 +217,6 @@ export function ChannelSetupSurfaceView({
|
||||
configuredFields={configuredFields}
|
||||
visibleSecrets={visibleSecrets}
|
||||
onChange={setFieldValue}
|
||||
onFieldBlur={saveSecretOnBlur}
|
||||
onToggleSecret={toggleSecret}
|
||||
errors={fieldErrors}
|
||||
clearedSecrets={clearedSecrets}
|
||||
@@ -255,7 +254,7 @@ export function ChannelSetupSurfaceView({
|
||||
))}
|
||||
</div>
|
||||
{advancedFields.length ? (
|
||||
<div onBlur={() => void saveConnectionSettings()}>
|
||||
<div>
|
||||
{mode === "connect" ? (
|
||||
<ChannelFieldGroups {...advancedFormProps} requirements={[]} sectionLabels={setup.sectionLabels} />
|
||||
) : (
|
||||
@@ -282,10 +281,10 @@ export function ChannelSetupSurfaceView({
|
||||
aria-live="polite"
|
||||
className={cn(
|
||||
"rounded-control bg-muted/55 px-3 py-2.5 text-[12px] leading-5 text-muted-foreground",
|
||||
!notice && "sr-only",
|
||||
!notice && (lastNotice.current ? "invisible" : "sr-only"),
|
||||
)}
|
||||
>
|
||||
{notice ?? ""}
|
||||
{notice ?? lastNotice.current ?? ""}
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user