From bca45d5a80570dfaa8c43b6b4b28831fa13e1fed Mon Sep 17 00:00:00 2001 From: Frank Stellmacher <171614930+Psychotoxical@users.noreply.github.com> Date: Mon, 18 May 2026 16:32:40 +0200 Subject: [PATCH] feat(servers): scan actions + edit existing server profiles (#780) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(server-scan): plumbing for triggering library scans Adds `startScan` / `getScanStatus` against the Subsonic API (`fullScan=true` is Navidrome's extension), a small per-server scan store, and a global polling hook (2 s cadence) that emits a toast when each scan finishes. Scans can run on any configured server, including inactive ones, by reusing `apiForServer`. UI surfaces follow in the next commit. * feat(server-scan): expose Quick / Full Scan in switcher + settings cards Adds a `ServerScanActions` component with two variants (compact for the server-switcher dropdown, card for the Settings server cards) backed by the scan store from the previous commit. Full Scan requires a second click within 3 s to confirm, matching the playlist-delete pattern. Status slot shows a spinner with running track count while scanning, a green check when finished, and a red icon on error. The switcher row is converted from a single button to a flex container so per-server scan controls don't hijack the server-switch click. i18n added across all 9 locales. * fix(server-scan): reorder switcher row to check / name / scan actions Moves the check / spinner slot from the right edge to the left so the spinner pop-in on server switch doesn't sit next to the scan icons. Removes the layout shift that briefly hovered the Quick scan button when the row re-rendered. * feat(servers): edit existing server profiles in Settings → Servers * Pencil-button on each server card opens an inline edit form that replaces the card (prefilled name / URL / username / password). * `AddServerForm` reused with an `editingServer` prop — title flips to "Edit Server", submit label to "Save", magic-string field hidden (the edit scope is manual fields; magic-string remains an add-time invite shortcut). * Edit saves unconditionally — ping runs post-save as a status indicator (analog to the existing Test button) instead of gating the save. Lets users update a profile when the server is currently unreachable. * Translations across all 9 locales (`editServer`, `editServerTitle`). * fix(servers): submit Add/Edit Server form on Enter Wrapped the form body in a real
); } diff --git a/src/components/settings/ServerScanActions.tsx b/src/components/settings/ServerScanActions.tsx new file mode 100644 index 00000000..115b127d --- /dev/null +++ b/src/components/settings/ServerScanActions.tsx @@ -0,0 +1,164 @@ +import React, { useEffect, useRef } from 'react'; +import { useTranslation } from 'react-i18next'; +import { Check, DatabaseZap, Loader2, RefreshCw, WifiOff } from 'lucide-react'; +import { startScan } from '../../api/subsonicScan'; +import { useScanStore } from '../../store/scanStore'; +import { showToast } from '../../utils/ui/toast'; + +const CONFIRM_TIMEOUT_MS = 3000; + +interface Props { + serverId: string; + /** `compact` for the server switcher dropdown (icon-only), `card` for the settings cards. */ + variant: 'compact' | 'card'; +} + +export default function ServerScanActions({ serverId, variant }: Props) { + const { t } = useTranslation(); + const entry = useScanStore(s => s.byServer[serverId]); + const setEntry = useScanStore(s => s.set); + const confirmTimerRef = useRef