Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion apps/studio/src/apps/FilesApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <T,>(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 */ } };
Expand Down Expand Up @@ -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);
Expand Down
23 changes: 14 additions & 9 deletions apps/studio/src/apps/ProjectApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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". */
Expand Down Expand Up @@ -73,6 +73,18 @@ export function ProjectPage({ tab, winId, projectId }: { tab: ProjectTab; winId:
{tab === "properties" && <PropertiesPage projectId={projectId} files={catalogue.files} defs={catalogue.defs} />}
{tab === "naming" && <NamingPage projectId={projectId} files={catalogue.files} patterns={catalogue.patterns} />}
{tab === "extensions" && current && <ExtensionsPage project={current} />}
{/* Customizations (#426): how this project behaves for everyone in it; user policies join here later. */}
{tab === "customizations" && current && (
<>
<SettingsGroup title="Canvases while someone edits them">
<Segmented label="Live updates" value={current.canvas_live ?? "realtime"} onChange={(v) => void setCanvasLive(current, v as "realtime" | "gradual").catch(toastError)}
options={[{ value: "realtime", label: "Realtime" }, { value: "gradual", label: "Every 5 seconds" }]} />
<p className="st-note">{(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."}</p>
</SettingsGroup>
</>
)}
{tab === "general" && current && (
<>
<SettingsGroup title="Name">
Expand All @@ -83,13 +95,6 @@ export function ProjectPage({ tab, winId, projectId }: { tab: ProjectTab; winId:
</span>
</FormField>
</SettingsGroup>
<SettingsGroup title="Canvases while someone edits them">
<Segmented label="Live updates" value={current.canvas_live ?? "realtime"} onChange={(v) => void setCanvasLive(current, v as "realtime" | "gradual").catch(toastError)}
options={[{ value: "realtime", label: "Realtime" }, { value: "gradual", label: "Every 5 seconds" }]} />
<p className="st-note">{(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."}</p>
</SettingsGroup>
<SettingsGroup title="About this project">
<PropertyList>
<PropertySection title="Facts" icon="info">
Expand All @@ -99,7 +104,7 @@ export function ProjectPage({ tab, winId, projectId }: { tab: ProjectTab; winId:
</PropertySection>
<PropertySection title="Fixed folders" icon="lock">
<PropertyRow label="Desktop" value="What is in it shows as icons on the desktop" />
<PropertyRow label="Settings" value="Holds the project's properties and naming patterns" />
<PropertyRow label="Settings" value="One file per settings tab: General, Properties, Naming patterns, Extensions, Customizations" />
</PropertySection>
</PropertyList>
</SettingsGroup>
Expand Down
6 changes: 3 additions & 3 deletions apps/studio/src/apps/SettingsApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<Tab, string> = { appearance: "Appearance", account: "Account", shortcuts: "Keyboard shortcuts", about: "About", general: "Project", properties: "Properties", naming: "Naming patterns", extensions: "Extensions", projects: "All projects" };
const TITLE: Record<Tab, string> = { 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<string, Tab> = { project: "general", extensions: "extensions", appearance: "appearance", account: "account", shortcuts: "shortcuts" };
const PAGE_TAB: Record<string, Tab> = { 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() {
Expand Down Expand Up @@ -64,7 +64,7 @@ export function SettingsApp({ win, projectId, setTitle, setRoute }: AppProps) {
<SettingsLayout value={tab} onChange={(id) => 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) && <ProjectPage tab={tab as ProjectTab} winId={win.id} projectId={projectId} />}
Expand Down
2 changes: 1 addition & 1 deletion apps/studio/src/fileKinds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function targetOf(f: FileRec, files: ReadonlyMap<string, FileRec>): Targe
}

/** How a file shows as an icon or a row: a shortcut takes the look of what it opens. */
const PAGE_GLYPH: Record<string, IconName> = { project: "slate", extensions: "extension", appearance: "palette", account: "user", shortcuts: "keyboard" };
const PAGE_GLYPH: Record<string, IconName> = { 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<string, IconName> = { desktop: "desktop", settings: "settings" };
export const fixedGlyph = (fixed: string): IconName => FIXED_GLYPH[fixed] ?? "folder";
Expand Down
2 changes: 1 addition & 1 deletion apps/studio/src/wm/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? <img src={thumb} alt="" loading="lazy" /> : <AppIcon glyph={l.glyph} color={l.color} size={24} /> };
};
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: <AppIcon glyph={d?.glyph} color={d?.color} size={24} /> }; }),
...apps().map((a): PaletteItem => ({ id: `app-${a.id}`, group: "Apps", label: a.name, meta: a.about, art: <AppIcon glyph={a.glyph} color={a.color} size={24} /> })),
Expand Down
15 changes: 15 additions & 0 deletions apps/worker/migrations/0011_settings_tabs.sql
Original file line number Diff line number Diff line change
@@ -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);
2 changes: 1 addition & 1 deletion apps/worker/test/routes/files.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/);
Expand Down
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`) |
Expand Down
2 changes: 1 addition & 1 deletion docs/data-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
2 changes: 1 addition & 1 deletion docs/features/desktop.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)

Expand Down
2 changes: 1 addition & 1 deletion docs/features/files.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
Loading
Loading