Merges Renovate's kit 3 (PR #149) and adapter-static 4 (PR #148) bumps, plus the migration they need. The mechanical part is `sv migrate sveltekit-3`, run one task at a time and reviewed: - svelte.config.js is gone. Its options move into sveltekit() in vite.config.ts, exported as kitOptions so vitest.config.ts runs the same kit setup, including the $test-utils alias the tests import. - $lib becomes #lib through package.json "imports". There is no src/lib/index, so only the "#lib/*" entry is kept. - tsconfig extends $app/tsconfig. - Peer floors raised to kit 3's requirements: svelte ^5.57.1, vite ^8.0.12, svelte-check ^4.7.5. By hand, from the codemod's list of non-automated tasks: - goto's replaceState option is now replace; keepFocus becomes reset: false. For the search typeahead, reset: false also stops the scroll-to-top, which is wanted while typing. - The test setup mocks drop pushState/replaceState and $app/paths base/assets, which kit 3 removed, and mock refreshAll in place of invalidateAll. - The other flagged files only read page.url or goto internal routes, so they needed no change. TypeScript goes to ^6, not the ^7 Renovate offers: kit 3 declares typescript ^6 as a peer and svelte-check 4.7 accepts ^5 || ^6. Move to 7 once both accept it. With Tailwind 4 and kit 3 in, `npm audit` on the whole tree reports 0, so the web lane now audits every dependency rather than only what ships to browsers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
127 lines
4.1 KiB
Svelte
127 lines
4.1 KiB
Svelte
<script lang="ts">
|
|
import { onMount } from 'svelte';
|
|
import {
|
|
getNotificationEmailSettings,
|
|
updateNotificationEmailSettings,
|
|
type NotificationEmailSettings
|
|
} from '#lib/api/admin.js';
|
|
import { errMessage } from '#lib/api/errors.js';
|
|
import { pushToast } from '#lib/stores/toast.svelte.js';
|
|
|
|
// When notification emails go out (M489 #5346). Nothing is emailed per
|
|
// event: new music is a daily summary, everything else a batch.
|
|
|
|
let saved = $state<NotificationEmailSettings | null>(null);
|
|
let form = $state<NotificationEmailSettings | null>(null);
|
|
let saving = $state(false);
|
|
let loadError = $state(false);
|
|
|
|
const dirty = $derived(
|
|
!!saved &&
|
|
!!form &&
|
|
(saved.summary_hour !== form.summary_hour ||
|
|
saved.batch_window_minutes !== form.batch_window_minutes)
|
|
);
|
|
|
|
const hours = Array.from({ length: 24 }, (_, h) => h);
|
|
|
|
function hourLabel(h: number): string {
|
|
return `${String(h).padStart(2, '0')}:00`;
|
|
}
|
|
|
|
async function load() {
|
|
try {
|
|
saved = await getNotificationEmailSettings();
|
|
form = { ...saved };
|
|
loadError = false;
|
|
} catch {
|
|
loadError = true;
|
|
}
|
|
}
|
|
|
|
onMount(load);
|
|
|
|
async function save() {
|
|
if (!form) return;
|
|
saving = true;
|
|
try {
|
|
saved = await updateNotificationEmailSettings(form);
|
|
form = { ...saved };
|
|
pushToast('Notification email schedule saved.');
|
|
} catch (e) {
|
|
// The server names the field it refused (#3937: errMessage, not
|
|
// e.message, because the client throws a plain object).
|
|
pushToast(errMessage(e), 'error');
|
|
} finally {
|
|
saving = false;
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<section class="space-y-4 rounded-xl border border-border bg-surface p-5">
|
|
<div>
|
|
<h3 class="font-display text-lg font-medium text-text-primary">Notification emails</h3>
|
|
<p class="mt-1 text-sm text-text-secondary">
|
|
Nothing is emailed per event. Each person chooses which notifications reach their email in
|
|
their own settings.
|
|
</p>
|
|
</div>
|
|
|
|
{#if loadError}
|
|
<p class="text-sm text-action-destructive">
|
|
Couldn't load the email schedule.
|
|
<button type="button" class="underline hover:no-underline" onclick={load}>Try again</button>
|
|
</p>
|
|
{:else if form === null}
|
|
<p class="text-sm text-text-secondary">Loading the email schedule…</p>
|
|
{:else}
|
|
<div class="grid gap-4 sm:grid-cols-2">
|
|
<label class="block">
|
|
<span class="text-sm text-text-primary">New music summary</span>
|
|
<span class="block text-xs text-text-secondary">
|
|
Once a day at this hour, in each person's own timezone.
|
|
</span>
|
|
<select
|
|
bind:value={form.summary_hour}
|
|
class="mt-1 w-28 rounded border border-border bg-background px-2 py-1 text-sm
|
|
text-text-primary focus-visible:outline-solid focus-visible:outline-2
|
|
focus-visible:outline-accent"
|
|
>
|
|
{#each hours as h (h)}
|
|
<option value={h}>{hourLabel(h)}</option>
|
|
{/each}
|
|
</select>
|
|
</label>
|
|
|
|
<label class="block">
|
|
<span class="text-sm text-text-primary">Batch everything else (minutes)</span>
|
|
<span class="block text-xs text-text-secondary">
|
|
One email this long after the first item, holding all that came in.
|
|
</span>
|
|
<input
|
|
type="number"
|
|
min="15"
|
|
max="1440"
|
|
bind:value={form.batch_window_minutes}
|
|
class="mt-1 w-28 rounded border border-border bg-background px-2 py-1 text-sm
|
|
text-text-primary focus-visible:outline-solid focus-visible:outline-2
|
|
focus-visible:outline-accent"
|
|
/>
|
|
</label>
|
|
</div>
|
|
|
|
<div class="flex justify-end">
|
|
<button
|
|
type="button"
|
|
class="rounded-md bg-action-secondary px-4 py-2 text-sm text-action-fg hover:opacity-90
|
|
focus-visible:outline-solid focus-visible:outline-2 focus-visible:outline-accent
|
|
disabled:cursor-not-allowed disabled:opacity-50"
|
|
disabled={!dirty || saving}
|
|
onclick={save}
|
|
>
|
|
{saving ? 'Saving…' : 'Save'}
|
|
</button>
|
|
</div>
|
|
{/if}
|
|
</section>
|