web: every Copy button works over plain http; saved keys and passwords can be removed (#8508, #8511)
copyText (family idea "copyText"): - web/src/lib/utils/clipboard.ts tries the Clipboard API first. - Where the API is missing (plain http on a home network) or refuses, it copies through the copy command on a hidden textarea instead. - If that fails too, it selects the shown value. - All six Copy buttons go through it: an invite token, the needs-a-file list, diagnostics, connection details, a playlist link, and report details. Before, five of them only showed an error over http. SecretField (family idea "SecretField"): - One component for a write-only credential: a password box for a new value, which the card's own Save sends, and a Remove button while one is saved. - Used for the provider API keys, the SMTP password, the backup secret key and the AcoustID key. Only AcoustID had Remove before. - The server gains clear_password (SMTP) and clear_secret_key (backup). An empty value still keeps the stored one. Provider keys already clear when sent empty. - Remove sends the saved settings back with only the credential cleared, so unsaved edits elsewhere on the card stay unsaved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import type { Snippet } from 'svelte';
|
||||
import SettingsGroup from '#lib/components/settings/SettingsGroup.svelte';
|
||||
import SettingRow from '#lib/components/settings/SettingRow.svelte';
|
||||
import SecretField from '#lib/components/settings/SecretField.svelte';
|
||||
import { errMessage } from '#lib/api/errors.js';
|
||||
import { pushToast } from '#lib/stores/toast.svelte.js';
|
||||
|
||||
@@ -98,6 +99,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
// An empty key removes the saved one on the server.
|
||||
async function onRemoveKey(p: P) {
|
||||
try {
|
||||
await save(p.id, { api_key: '' });
|
||||
// A test result for the old key no longer says anything.
|
||||
delete results[p.id];
|
||||
} catch (e) {
|
||||
pushToast(`Couldn't remove the key for ${p.display_name}: ${errMessage(e)}`, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function onTest(p: P) {
|
||||
testing[p.id] = true;
|
||||
try {
|
||||
@@ -135,12 +147,14 @@
|
||||
{#if l}
|
||||
<div class="flex flex-wrap items-center gap-2 px-4 pb-3">
|
||||
{#if p.requires_api_key}
|
||||
<input
|
||||
type="password"
|
||||
aria-label="{p.display_name} API key"
|
||||
placeholder={p.api_key_set ? 'Key saved · leave empty to keep it' : keyPlaceholder}
|
||||
<SecretField
|
||||
label="{p.display_name} API key"
|
||||
has={p.api_key_set}
|
||||
placeholder={p.api_key_set ? undefined : keyPlaceholder}
|
||||
bind:value={l.apiKey}
|
||||
class="w-64 max-w-full rounded-md border border-border bg-background px-3 py-1.5 text-sm"
|
||||
remove={() => onRemoveKey(p)}
|
||||
disabled={saving[p.id]}
|
||||
class="w-64"
|
||||
/>
|
||||
{/if}
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user