diff --git a/apps/studio/src/apps/FilesApp.tsx b/apps/studio/src/apps/FilesApp.tsx index 1cedae5..51156ab 100644 --- a/apps/studio/src/apps/FilesApp.tsx +++ b/apps/studio/src/apps/FilesApp.tsx @@ -41,6 +41,8 @@ type MediaNav = "all" | "collections" | "loose" | `coll:${string}`; interface Launch { entry?: Entry; folder?: string | null; home?: boolean; bin?: boolean; collection?: string; filter?: string } /** Files a person does not browse among the others: they live in a Settings folder and open in Settings. */ const SETTINGS_TYPES = ["property", "naming", "settings", "preferences"]; +/** Records that are reached through their settings page, never listed (#426: one file per settings tab). */ +const HIDDEN_TYPES = ["property", "naming", "preferences"]; const remembered = (key: string, fallback: T): T => { try { const v = localStorage.getItem(key); return v ? (JSON.parse(v) as T) : fallback; } catch { return fallback; } }; const remember = (key: string, v: unknown) => { try { localStorage.setItem(key, JSON.stringify(v)); } catch { /* private mode */ } }; @@ -173,7 +175,7 @@ function Browser({ win, projectId, setTitle, setRoute, entry, start, onEntry }: : mnav === "loose" ? loose : spread || q ? photos : [...all.filter((f) => f.type === "collection" && !f.internal_of), ...loose]; } else if (shotsOnly) out = all.filter((f) => f.type === only && !f.internal_of); - else out = all.filter((f) => !f.internal_of && f.type !== "preferences" && (flat ? !f.fixed && !SETTINGS_TYPES.includes(f.type) : f.container === here)); + else out = all.filter((f) => !f.internal_of && !HIDDEN_TYPES.includes(f.type) && (flat ? !f.fixed && !SETTINGS_TYPES.includes(f.type) : f.container === here)); if (types.length) out = out.filter((f) => types.includes(f.type)); if (q) out = out.filter((f) => matchesSearch(q, texts(f))); if (filtering) out = out.filter(matches); diff --git a/apps/studio/src/apps/ProjectApp.tsx b/apps/studio/src/apps/ProjectApp.tsx index cb1ce98..d06dd49 100644 --- a/apps/studio/src/apps/ProjectApp.tsx +++ b/apps/studio/src/apps/ProjectApp.tsx @@ -12,7 +12,7 @@ import { ExtensionsPage } from "./project/Extensions"; import "../catalogue.css"; /** The project's pages in Settings (#426: the Project app folded into Settings). */ -export const PROJECT_TABS = ["general", "properties", "naming", "extensions", "projects"] as const; +export const PROJECT_TABS = ["general", "properties", "naming", "extensions", "customizations", "projects"] as const; export type ProjectTab = (typeof PROJECT_TABS)[number]; const day = (iso: string) => new Date(iso).toLocaleDateString(undefined, { year: "numeric", month: "short", day: "numeric" }); /** A name the server refused because it is taken reads better than "409". */ @@ -73,6 +73,18 @@ export function ProjectPage({ tab, winId, projectId }: { tab: ProjectTab; winId: {tab === "properties" && } {tab === "naming" && } {tab === "extensions" && current && } + {/* Customizations (#426): how this project behaves for everyone in it; user policies join here later. */} + {tab === "customizations" && current && ( + <> + + void setCanvasLive(current, v as "realtime" | "gradual").catch(toastError)} + options={[{ value: "realtime", label: "Realtime" }, { value: "gradual", label: "Every 5 seconds" }]} /> +

{(current.canvas_live ?? "realtime") === "realtime" + ? "Everyone watching a canvas sees each change and each stroke as it is drawn, and sees at once when the person editing lets it go. It runs on a Durable Object per open canvas, which counts against the Cloudflare plan." + : "Everyone watching a canvas sees each save as soon as it is made, and at once when it is free to edit; the changes and strokes in between are not streamed. Who edits is always live."}

+
+ + )} {tab === "general" && current && ( <> @@ -83,13 +95,6 @@ export function ProjectPage({ tab, winId, projectId }: { tab: ProjectTab; winId: - - void setCanvasLive(current, v as "realtime" | "gradual").catch(toastError)} - options={[{ value: "realtime", label: "Realtime" }, { value: "gradual", label: "Every 5 seconds" }]} /> -

{(current.canvas_live ?? "realtime") === "realtime" - ? "Everyone watching a canvas sees each change and each stroke as it is drawn, and sees at once when the person editing lets it go. It runs on a Durable Object per open canvas, which counts against the Cloudflare plan." - : "Everyone watching a canvas sees it as it was saved, read again every 5 seconds, and sees within 5 seconds when it is free to edit. It only reads the database."}

-
@@ -99,7 +104,7 @@ export function ProjectPage({ tab, winId, projectId }: { tab: ProjectTab; winId: - + diff --git a/apps/studio/src/apps/SettingsApp.tsx b/apps/studio/src/apps/SettingsApp.tsx index e3232f5..790e3aa 100644 --- a/apps/studio/src/apps/SettingsApp.tsx +++ b/apps/studio/src/apps/SettingsApp.tsx @@ -13,9 +13,9 @@ import type { ResourceRef } from "../wm/wm"; const TABS = ["appearance", "account", "shortcuts", "about", ...PROJECT_TABS] as const; type Tab = (typeof TABS)[number]; -const TITLE: Record = { appearance: "Appearance", account: "Account", shortcuts: "Keyboard shortcuts", about: "About", general: "Project", properties: "Properties", naming: "Naming patterns", extensions: "Extensions", projects: "All projects" }; +const TITLE: Record = { appearance: "Appearance", account: "Account", shortcuts: "Keyboard shortcuts", about: "About", general: "General", customizations: "Customizations", properties: "Properties", naming: "Naming patterns", extensions: "Extensions", projects: "All projects" }; /** A settings page file's page, as a tab (#426: one file per page; "project" is the General page). */ -const PAGE_TAB: Record = { project: "general", extensions: "extensions", appearance: "appearance", account: "account", shortcuts: "shortcuts" }; +const PAGE_TAB: Record = { general: "general", properties: "properties", naming: "naming", customizations: "customizations", extensions: "extensions", appearance: "appearance", account: "account", shortcuts: "shortcuts" }; /** Every shortcut of the registry, scope by scope: the same list as the `?` sheet and docs/shortcuts.md. */ export function ShortcutList() { @@ -64,7 +64,7 @@ export function SettingsApp({ win, projectId, setTitle, setRoute }: AppProps) { setTab(id as Tab)} title={tab === "general" ? project?.name ?? "Project" : TITLE[tab]} wide={tab === "properties" || tab === "naming"} sections={[ { label: "You", items: [{ id: "appearance", label: "Appearance", icon: "palette" }, { id: "account", label: "Account", icon: "user" }, { id: "shortcuts", label: "Shortcuts", icon: "keyboard" }, { id: "about", label: "About", icon: "info" }] }, - { label: "This project", items: [{ id: "general", label: "Project", icon: "slate" }, { id: "properties", label: "Properties", icon: "tag" }, { id: "naming", label: "Naming patterns", icon: "edit" }, { id: "extensions", label: "Extensions", icon: "extension" }] }, + { label: "This project", items: [{ id: "general", label: "General", icon: "slate" }, { id: "properties", label: "Properties", icon: "tag" }, { id: "naming", label: "Naming patterns", icon: "edit" }, { id: "extensions", label: "Extensions", icon: "extension" }, { id: "customizations", label: "Customizations", icon: "sliders" }] }, { label: "All projects", items: [{ id: "projects", label: "Projects", icon: "files" }] }, ]}> {(PROJECT_TABS as readonly string[]).includes(tab) && } diff --git a/apps/studio/src/fileKinds.ts b/apps/studio/src/fileKinds.ts index c9b196d..14e7482 100644 --- a/apps/studio/src/fileKinds.ts +++ b/apps/studio/src/fileKinds.ts @@ -51,7 +51,7 @@ export function targetOf(f: FileRec, files: ReadonlyMap): Targe } /** How a file shows as an icon or a row: a shortcut takes the look of what it opens. */ -const PAGE_GLYPH: Record = { project: "slate", extensions: "extension", appearance: "palette", account: "user", shortcuts: "keyboard" }; +const PAGE_GLYPH: Record = { general: "slate", properties: "tag", naming: "edit", customizations: "sliders", extensions: "extension", appearance: "palette", account: "user", shortcuts: "keyboard" }; /** The fixed folders' own glyphs: a first-class folder like an OS's Desktop, not a padlock. */ const FIXED_GLYPH: Record = { desktop: "desktop", settings: "settings" }; export const fixedGlyph = (fixed: string): IconName => FIXED_GLYPH[fixed] ?? "folder"; diff --git a/apps/studio/src/wm/Search.tsx b/apps/studio/src/wm/Search.tsx index 7967400..eb96f7b 100644 --- a/apps/studio/src/wm/Search.tsx +++ b/apps/studio/src/wm/Search.tsx @@ -35,7 +35,7 @@ export function Search({ projectId, onClose }: { projectId: string; onClose: () return { id: `file-${f.id}`, group: "Files", label: f.name, meta: where(f, inHome), keywords: values, art: thumb ? : }; }; const items: PaletteItem[] = useMemo(() => { - const listed = (list: FileRec[]) => list.filter((f) => !f.internal_of && !f.fixed && f.type !== "preferences").sort((a, b) => (b.updated_at ?? b.created_at).localeCompare(a.updated_at ?? a.created_at)); + const listed = (list: FileRec[]) => list.filter((f) => !f.internal_of && !f.fixed && !["preferences", "property", "naming"].includes(f.type)).sort((a, b) => (b.updated_at ?? b.created_at).localeCompare(a.updated_at ?? a.created_at)); return [ ...windows.map((w): PaletteItem => { const d = appDef(w.app); return { id: `win-${w.id}`, group: "Open windows", label: w.title, meta: d?.name, art: }; }), ...apps().map((a): PaletteItem => ({ id: `app-${a.id}`, group: "Apps", label: a.name, meta: a.about, art: })), diff --git a/apps/worker/migrations/0011_settings_tabs.sql b/apps/worker/migrations/0011_settings_tabs.sql new file mode 100644 index 0000000..ba59477 --- /dev/null +++ b/apps/worker/migrations/0011_settings_tabs.sql @@ -0,0 +1,15 @@ +-- One settings file per tab (#426, second round): the page "project" is called General now, and every project's +-- Settings folder gets the pages Properties, Naming patterns and Customizations next to General and Extensions. +UPDATE files SET name = 'General', body = json_set(body, '$.page', 'general') +WHERE type = 'settings' AND json_extract(body, '$.page') = 'project'; + +INSERT INTO files (id, project_id, type, name, container, created_by, created_at, body, body_version) +SELECT + lower(hex(randomblob(4))) || '-' || lower(hex(randomblob(2))) || '-4' || substr(lower(hex(randomblob(2))), 2) || '-' + || substr('89ab', 1 + abs(random()) % 4, 1) || substr(lower(hex(randomblob(2))), 2) || '-' || lower(hex(randomblob(6))), + s.project_id, 'settings', p.name, s.id, s.created_by, strftime('%Y-%m-%dT%H:%M:%fZ', 'now'), json_object('page', p.page), 1 +FROM files s +JOIN (SELECT 'general' AS page, 'General' AS name UNION ALL SELECT 'properties', 'Properties' UNION ALL SELECT 'naming', 'Naming patterns' + UNION ALL SELECT 'extensions', 'Extensions' UNION ALL SELECT 'customizations', 'Customizations') p +WHERE s.fixed = 'settings' AND s.project_id IS NOT NULL + AND NOT EXISTS (SELECT 1 FROM files x WHERE x.container = s.id AND x.type = 'settings' AND json_extract(x.body, '$.page') = p.page); diff --git a/apps/worker/test/routes/files.test.ts b/apps/worker/test/routes/files.test.ts index ac2c844..05f36fc 100644 --- a/apps/worker/test/routes/files.test.ts +++ b/apps/worker/test/routes/files.test.ts @@ -66,7 +66,7 @@ describe("settings pages (#426)", () => { const all = (await ok<{ files: (FileOut & { body: { page: string } })[] }>(api(u.token, "GET", `/api/files?project_id=${project}&body=1`))).files; const settings = all.find((f) => f.fixed === "settings")!.id; const pages = all.filter((f) => f.type === "settings"); - expect(pages.map((f) => [f.name, f.body.page, f.container]).sort()).toEqual([["Extensions", "extensions", settings], ["Project", "project", settings]]); + expect(pages.map((f) => [f.name, f.body.page, f.container]).sort()).toEqual([["Customizations", "customizations", settings], ["Extensions", "extensions", settings], ["General", "general", settings], ["Naming patterns", "naming", settings], ["Properties", "properties", settings]]); const page = pages[0].id; expect((await put(page, { name: "Mine" }, 400)).error).toMatch(/kept by the server/); expect((await put(uuid(), { type: "settings", project_id: project, container: settings, body: { page: "project" } }, 400)).error).toMatch(/kept by the server/); diff --git a/docs/api.md b/docs/api.md index 4b6db2f..ea79d25 100644 --- a/docs/api.md +++ b/docs/api.md @@ -43,7 +43,7 @@ A file as the API gives it: | --- | --- | | `id` | UUID, chosen by the client | | `project_id`, `home` | Its root: a project, or (`project_id: null`, `home: true`) the caller's account home | -| `type` | A registered file type. So far `folder`, `shortcut`, `preferences` (a person's preferences, in their account home), `settings` (a settings page, body `{ page }`: `project`, `extensions` in a project's Settings folder, `appearance`, `account`, `shortcuts` in the home's; made and kept by the server, a PUT is refused), `photo`, `collection`, `device` (a phone or tablet, in its owner's account home), `property` and `naming` (a property definition and a naming pattern, only in the project's Settings folder), `filter` (a saved query), `shot` (properties only until step B6), `canvas` and `preset` (an optics preset; [canvas](features/canvas.md)); each build step adds the types it builds | +| `type` | A registered file type. So far `folder`, `shortcut`, `preferences` (a person's preferences, in their account home), `settings` (a settings page, body `{ page }`: `general`, `properties`, `naming`, `extensions`, `customizations` in a project's Settings folder (migration 0011), `appearance`, `account`, `shortcuts` in the home's; made and kept by the server, a PUT is refused), `photo`, `collection`, `device` (a phone or tablet, in its owner's account home), `property` and `naming` (a property definition and a naming pattern, only in the project's Settings folder), `filter` (a saved query), `shot` (properties only until step B6), `canvas` and `preset` (an optics preset; [canvas](features/canvas.md)); each build step adds the types it builds | | `name` | Free text, up to 120 characters, not unique | | `container` | The folder or collection it sits in; `null` at the top level | | `internal_of` | The file it was made inside ([internal files](rewrite/i1-interjection.md)); such a file sits in no container and is left out of lists unless asked for (`internal=1`, `internal_of`) | diff --git a/docs/data-model.md b/docs/data-model.md index e0bf597..2a04507 100644 --- a/docs/data-model.md +++ b/docs/data-model.md @@ -35,7 +35,7 @@ A new numbered file for every change; an applied one is never edited. | `name` | Free text, not unique | | `container` | The folder or collection it sits in; null at the top level. Cleared when the container is purged, so a file binned on its own inside it restores to the top level | | `internal_of` | The file it was made inside; never together with `container`. Purged with its parent | -| `fixed` | `desktop` or `settings`: a project's fixed folders, made with the project, one of each; a home's `settings` folder, made when the home is first listed (`ensureHome`, migration 0010 adds the project pages) | +| `fixed` | `desktop` or `settings`: a project's fixed folders, made with the project, one of each; a home's `settings` folder, made when the home is first listed (`ensureHome`; migrations 0010 and 0011 add the project pages, one per settings tab) | | `deleted_at`, `deleted_with` | The recycle bin. `deleted_with` names the file whose binning took this one along (a folder's contents, a file's internal files); null for the file the user binned | | `lock_by`, `lock_holder`, `lock_until` | One editor at a time: the user, the editing window's own token, and until when. Written from step B5 | | `body`, `body_version` | The type's own document, saved whole and checked by `packages/model` on every save, and the version of its shape. A change of shape raises the version and upgrades stored bodies when they are read; it needs no migration | diff --git a/docs/features/desktop.md b/docs/features/desktop.md index f9fcfb4..565775b 100644 --- a/docs/features/desktop.md +++ b/docs/features/desktop.md @@ -52,7 +52,7 @@ An app declares its name, glyph and colour, tier, whether it is one window in al | Shot, Set, Location, Canvas, Timeline | `apps/ShotApp.tsx`, `CanvasApp.tsx`, `TimelineApp.tsx` | One file per window; Timeline also shows the project's master timeline ([timeline](timeline.md)) | | Recycle bin | `apps/BinApp.tsx` | What was deleted: restore, delete permanently, empty | -| Settings | `apps/SettingsApp.tsx`, `apps/AccountPage.tsx`, `apps/ProjectApp.tsx` (the project's pages) | You (Appearance, Account, Shortcuts, About), this project (Project: name, facts, delete; Properties; Naming patterns; Extensions) and all projects (open, new, rename, delete). Opens the settings page files, property definitions and naming patterns at their page (#426: the Project app folded in) | +| Settings | `apps/SettingsApp.tsx`, `apps/AccountPage.tsx`, `apps/ProjectApp.tsx` (the project's pages) | You (Appearance, Account, Shortcuts, About), this project (General: name, facts, delete; Properties; Naming patterns; Extensions; Customizations: the project's behaviour, so far how canvases update while edited) and all projects (open, new, rename, delete). Opens the settings page files, property definitions and naming patterns at their page (#426: the Project app folded in) | ## Preferences (`prefs.ts`, `theme.ts`) diff --git a/docs/features/files.md b/docs/features/files.md index 4ac9a8f..72263d0 100644 --- a/docs/features/files.md +++ b/docs/features/files.md @@ -8,7 +8,7 @@ Everything a user makes is a file ([07 ยท organisation](../rewrite/07-organisati - **Two roots:** a project, and the signed-in person's **account home** (files that follow them into every project). Nothing moves between the two, or between projects. - **Containers:** a folder holds any files and nests up to 8 deep; a collection holds only photos and does not nest ([media](media.md)). A file sits in one container or at the top level. Names are free text and need not be unique. -- **Fixed folders** of a project, made with it: **Desktop** (what is in it shows as icons on the desktop) and **Settings** (its settings pages Project and Extensions, its properties and naming patterns). A person's home has a **Settings** folder too (Appearance, Account, Shortcuts), made when the home is first listed. They cannot be renamed, moved, copied or deleted, and show as first-class folders with their own glyphs (desktop, settings). +- **Fixed folders** of a project, made with it: **Desktop** (what is in it shows as icons on the desktop) and **Settings** (one settings page per tab: General, Properties, Naming patterns, Extensions, Customizations; the property definitions and naming patterns are kept there too but not listed, their pages show them). A person's home has a **Settings** folder too (Appearance, Account, Shortcuts), made when the home is first listed. They cannot be renamed, moved, copied or deleted, and show as first-class folders with their own glyphs (desktop, settings). - **Shortcuts** are files of their own: one opens an app, or points at a file elsewhere. A shortcut whose target is in the bin or gone is not shown on the desktop and says so in Files; it works again once the target is restored. - **Settings pages are files** (#426): one file of the type `settings` per page (its body names the page), in its root's Settings folder. Opening one opens Settings at that page; so do a property definition and a naming pattern. They are made and kept by the server: never renamed, moved, copied or deleted. What a page sets lives where it always did (the project, the account, the preferences). The personal pages are drawn in one colour, the project's in another, each with its page's glyph. - **Preferences** are a data file of the type `preferences` in the account home ([desktop](desktop.md#preferences-prefsts-themets)); Files and the search do not list it (the Appearance page is how it is reached). diff --git a/packages/model/src/types.ts b/packages/model/src/types.ts index e168bf3..a5651fc 100644 --- a/packages/model/src/types.ts +++ b/packages/model/src/types.ts @@ -100,20 +100,21 @@ export function knownPreferences(body: Record): Record = { project: "Project", extensions: "Extensions", appearance: "Appearance", account: "Account", shortcuts: "Shortcuts" }; +export const SETTINGS_PAGE_NAMES: Record = { general: "General", properties: "Properties", naming: "Naming patterns", extensions: "Extensions", customizations: "Customizations", appearance: "Appearance", account: "Account", shortcuts: "Shortcuts" }; /** - * A settings page as a file (#426): the project's (Project, Extensions) in its Settings folder, a - * person's (Appearance, Account, Shortcuts) in their home's. It names its page; what the page sets + * A settings page as a file (#426): one per tab, the project's (General, Properties, Naming patterns, Extensions, + * Customizations) in its Settings folder, a person's (Appearance, Account, Shortcuts) in their home's. The property + * definitions and naming patterns stay files of their own in the Settings folder; the browser lists the pages only. It names its page; what the page sets * lives where it always did (the project, the preferences file, the account), so the file is how a * page is found, opened and pinned. Made by the server with the folder; never renamed or deleted. */ export const SETTINGS: FileType = { type: "settings", label: "Settings page", plural: "Settings pages", roots: ["project", "home"], onlyIn: "settings", made: "system", version: 1, - empty: () => ({ page: "project" }), + empty: () => ({ page: "general" }), check(body) { for (const k of Object.keys(body)) if (k !== "page") return `a settings page has no "${k}"`; return typeof body.page === "string" && body.page in SETTINGS_PAGES ? null : "page is not a settings page";