From abdb519e8bd41b9b49f45531f8b383d0ddcfcde2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Padez?= Date: Sun, 30 Aug 2026 23:22:35 +0100 Subject: [PATCH] one Save, in the panel's bar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every section had its own Save buttons — four on About, two on Home, one per record — and on a page long enough to scroll, the button you wanted was the one that had just left the screen. Now there is one, beside Publish, pinned above the scroll. The section announces whether it has unsaved changes, whether it is busy, and how to save; the bar renders that. Neither knows what the other is, which is what keeps DetailPanel a map of keys to components rather than a place that has to know what each section can do. ── What this replaces ── The per-card saves existed because the API treats an absent key as "leave it alone", so a Save carrying everything meant a half-written manifesto shipping with a photograph somebody meant to change. With one Save that is the model rather than an accident: one press writes the page you are looking at. The cost, stated plainly: there is no longer a way to commit one part of a page and leave the rest. Nothing here needed that, and if something ever does it wants its own verb rather than four buttons all called Save. ── Dirty is a comparison, not a flag ── Against what the server last returned, field by field. A flag says "something was typed" and stays true after you undo it by hand; a comparison says "this differs from what is stored", which is the question a Save button is actually answering — and it is what lets the button be dead when there is nothing to do, which is the whole value of having one. The gallery picker on Home is deliberately outside it and still writes on selection: a setPhrase(event.currentTarget.value)} /> - - {saveButton('header', () => - void send('header', { header_url: orNull(headerUrl), header_phrase: orNull(phrase) }), - )} {/* ── ABOUT US ─────────────────────────────────────────────────────────────────────────── */} @@ -162,7 +182,6 @@ export const AboutPanel = () => {

Who you are.

- {saveButton('about', () => void send('about', { about_text: orNull(aboutText) }))} {/* ── PRODUTO: a video beside its text ─────────────────────────────────────────────────── */} @@ -186,9 +205,6 @@ export const AboutPanel = () => { - {saveButton('product', () => - void send('product', { product_video_url: orNull(productVideo), product_text: orNull(productText) }), - )} {/* ── MANIFESTO ────────────────────────────────────────────────────────────────────────── */} @@ -198,7 +214,6 @@ export const AboutPanel = () => {

What you stand for.

- {saveButton('manifesto', () => void send('manifesto', { manifesto_text: orNull(manifesto) }))} {error &&

{error}

} diff --git a/web/sections/HomePanel.tsx b/web/sections/HomePanel.tsx index b37e6a6..7e92474 100644 --- a/web/sections/HomePanel.tsx +++ b/web/sections/HomePanel.tsx @@ -7,6 +7,7 @@ import { readableError } from '../errors'; import { useFlash } from '../useFlash'; import { RichText } from '../RichText'; import { MediaPicker } from '../MediaPicker'; +import { useSaveTarget } from '../SaveTarget'; /** * The Home page: a hero, an intro, and an ordered gallery. @@ -115,11 +116,21 @@ export const HomePanel = () => { either card would have each one saving the other's unsaved edits. Two cards, two independent saves, and a half-finished intro cannot ride along with a hero somebody meant to change. */ - const saveIntro = () => - send('intro', () => clientRef.current.patch<{ data: Home }>('/fofos-admin/home', { intro_text: intro.trim() || null })); + /* + One Save for everything this page holds in a field. + + The gallery choice is NOT part of it: picking a gallery from the list writes immediately, because a +