diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fab0761..b5e4d023 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,15 @@ exact tag (`ghcr.io/calnode/calnode:0.1.0`) if you need stability between upgrad ## [Unreleased] ### Added +- **Unlisted event types.** Create and edit forms now offer Public, Unlisted and Private + visibility, shown in the admin list and read-only details. Active Unlisted event types + accept normal bookings through their existing URLs without appearing in person or team + directories; anyone with the link can book without signing in. Active remains independent, + and existing Public/Private behavior is preserved. Migration 00072 adds a default-off + `is_unlisted` flag while retaining the `is_public` booking gate. Create/PATCH accepts + `visibility`; legacy `is_public` PATCH requests still select Public/Private. New event + types default to Public; duplicates retain visibility and start inactive. Migration rollback + makes Unlisted types Private so an older binary cannot unexpectedly list them. - **French localization of the admin UI.** The SvelteKit admin (`frontend/`) now has a lightweight i18n layer (`frontend/src/lib/i18n/`) with English as the source of truth and a complete French catalog written by a native speaker. The language is chosen in diff --git a/README.md b/README.md index 4ce56269..6291089e 100644 --- a/README.md +++ b/README.md @@ -183,6 +183,7 @@ domains, Resend email, Google & Microsoft OAuth, Litestream backups, troubleshoo **Shipped** - Event types with per-type duration, location, custom questions, custom email copy +- Public, **Unlisted** (direct link only), or Private event-type visibility - DST-correct availability (working hours, day-of-week rules, date overrides) - Team routing: **fixed · round-robin · collective · priority** - **Google Calendar & Microsoft 365 / Outlook** — native free/busy conflict checks @@ -218,6 +219,20 @@ domains, Resend email, Google & Microsoft OAuth, Litestream backups, troubleshoo **On the roadmap** - OpenAPI spec · `/metrics` · multi-domain (one instance, many hostnames) +### Event-type visibility + +Choose **Visibility** when creating an event type, or open an existing event type's +**General** tab, choose a visibility and save: + +- **Public** (the default): listed in person/team directories and bookable through its URL. +- **Unlisted**: hidden from those directories, but bookable through the same `/book/{slug}` URL. +- **Private**: hidden from directories and inaccessible through the public booking URL. + +Keep **Active** enabled to accept bookings. Inactive types are unbookable and absent from +directories in every visibility state. Unlisted is discoverability, not access control: +anyone with the link can book without signing in. For API compatibility and migration +details, see [the visibility model](docs/ARCHITECTURE.md#14-visibility-model). + --- ## Stack diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 0856972d..c641f80a 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -69,8 +69,9 @@ app you must `pnpm build` in `frontend/` **and** rebuild/restart the Go binary ## 4. Persistence (SQLite) — and the single-connection rule -Public person (`/u/{handle}`) and team (`/team/{slug}`) directories list public, -active event types by `display_order` ascending, then name and unique slug for +Public person (`/u/{handle}`) and team (`/team/{slug}`) directories list active event +types with **Public** visibility (excluding Unlisted and Private; see §14), by +`display_order` ascending, then name and unique slug for deterministic ties. The integer defaults to 0, preserving alphabetical order for existing types. Owners can set it through event-type create/PATCH or the event editor's Directory order field; negative values put an event ahead of the default @@ -79,7 +80,7 @@ It does not affect the admin event-type list or team member roster ordering. - `internal/db`: opens SQLite with **`SetMaxOpenConns(1)`** + `SetMaxIdleConns(1)`, **WAL** journal mode, `busy_timeout=5000`. One writer connection by design. -- Migrations: **goose** SQL files in `internal/db/migrations/` (00001→00029). Run +- Migrations: numbered **goose** SQL files embedded from `internal/db/migrations/`. Run automatically on startup. `ALTER TABLE ADD COLUMN` is reversible-by-convention only (SQLite can't easily drop columns). @@ -106,7 +107,9 @@ partial unique index covers) — no TOCTOU between concurrent bookings. `invite_tokens` (hashed, single-use). **There is no `auth_providers` table** — OAuth identity is columns on `users` (migration 00012). - **Teams:** `teams`, `team_members` (with `routing_priority`). -- **Event types:** `event_types` (+ `routing_mode` — CHECK has **four** values: +- **Event types:** `event_types` (+ `is_active`, independent of visibility; + `is_public` gates direct booking and `is_unlisted` suppresses directory listing — §14; + `routing_mode` — CHECK has **four** values: fixed | round_robin | collective | priority; `rr_strategy`; `max_active_bookings` (per-invitee cap, enforced); `seat_limit` (group/class — column exists but is **not enforced**); `team_id` — vestigial for routing), `event_type_hosts` @@ -818,6 +821,26 @@ as the desired state: ## 14. Visibility model +Event types have three visibility choices, independent of **Active**: + +- **Public** (the default): direct booking is accessible and the event type is listed + in the existing person/team directories. +- **Unlisted**: direct booking works normally, but directories omit the event type. + Anyone with the URL can book without signing in; this is discoverability, not access control. +- **Private**: direct booking is inaccessible and directories omit the event type. + +Inactive event types remain unbookable and absent from directories in every visibility +state. Administration lists and manages all three states under the existing ownership rules. +Create/PATCH accepts `visibility` (`public`, `unlisted`, `private`); admin responses include it. +Migration 00072 adds `is_unlisted` (default 0), retaining `is_public` as the direct-booking +gate so all existing Public/Private values and booking checks stay unchanged. Direct booking, +slots, questions, embeds and the assistant use that gate; only the directory queries check +`is_unlisted`. The authenticated MCP booking catalog retains its existing bookability filter. +Legacy PATCH clients can still use `is_public` to choose Public/Private (clearing Unlisted). +If both fields are sent they must agree on direct accessibility; `visibility` sets the state. +Duplication keeps visibility and still starts inactive. Rolling migration 00072 back makes +Unlisted types Private, avoiding unexpected directory publication by an older binary. + - Members see **only bookings they host** — `ListByHost` matches `bookings.host_id` **OR** any `booking_hosts` seat, so Group/fixed non-primary attendees see meetings they're on (not just the ones they lead). diff --git a/docs/i18n-glossary.md b/docs/i18n-glossary.md index 2ee884b5..e5898151 100644 --- a/docs/i18n-glossary.md +++ b/docs/i18n-glossary.md @@ -35,6 +35,10 @@ not have to invent terminology that is already decided. | round robin | round robin | - | tourniquet | French admin uses "tourniquet"; do not calque "tourner entre eux". | | reminder | reminder | rappel | rappel | | | directory | directory | - | annuaire | Only the person and team pages. | +| event-type visibility | Visibility | - | Visibilité | Admin key: `eventTypes.visibility.label`. Independent of Active. | +| public event type | Public | - | Public | Admin key: `eventTypes.visibility.public`. Listed and bookable when active. | +| unlisted event type | Unlisted | - | Non répertorié | Admin key: `eventTypes.visibility.unlisted`. Hidden from directories; anyone with the link can book when active. | +| private event type | Private | - | Privé | Admin key: `eventTypes.visibility.private`. No public booking access or directory listing. | ## Register diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index cd6c8723..98f17211 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -34,7 +34,9 @@ export type EventType = { // duration on create; editable so a 45-minute meeting can still be offered on the hour. slot_interval_minutes: number; is_active: boolean; + /** Direct-booking gate, true for both Public and Unlisted. */ is_public: boolean; + visibility: 'public' | 'unlisted' | 'private'; /** Show already-booked times struck through on the booking page instead of hiding * them. Off by default: the slots endpoint is public, so this makes the host's * booked hours visible to anyone with the link. */ diff --git a/frontend/src/lib/components/event-types/VisibilitySelect.svelte b/frontend/src/lib/components/event-types/VisibilitySelect.svelte new file mode 100644 index 00000000..0b957231 --- /dev/null +++ b/frontend/src/lib/components/event-types/VisibilitySelect.svelte @@ -0,0 +1,23 @@ + + +
+ + + + {$t(`eventTypes.visibility.${value}`)} + + + {$t('eventTypes.visibility.public')} + {$t('eventTypes.visibility.unlisted')} + {$t('eventTypes.visibility.private')} + + +

{$t(`eventTypes.visibility.hint.${value}`)}

+
diff --git a/frontend/src/lib/components/event-types/VisibilitySelect.test.ts b/frontend/src/lib/components/event-types/VisibilitySelect.test.ts new file mode 100644 index 00000000..43b8c3d6 --- /dev/null +++ b/frontend/src/lib/components/event-types/VisibilitySelect.test.ts @@ -0,0 +1,32 @@ +import { afterEach, expect, test } from 'vitest'; +import { page } from 'vitest/browser'; +import { cleanup, render } from 'vitest-browser-svelte'; +import VisibilitySelect from './VisibilitySelect.svelte'; +import { setLocale } from '$lib/i18n'; + +afterEach(cleanup); + +test('visibility defaults to Public and explains each selection', async () => { + setLocale('en'); + await render(VisibilitySelect); + const control = page.getByRole('button', { name: 'Visibility' }); + await expect.element(control).toHaveTextContent('Public'); + await expect.element(page.getByText('Listed in public directories and bookable by anyone with the link.')).toBeVisible(); + + for (const [label, hint] of [ + ['Unlisted', 'Hidden from public directories. Anyone with the link can book; no sign-in is required.'], + ['Private', 'Hidden from public directories and unavailable through the public booking link.'], + ['Public', 'Listed in public directories and bookable by anyone with the link.'] + ]) { + await control.click(); + await page.getByRole('option', { name: label, exact: true }).click(); + await expect.element(control).toHaveTextContent(label); + await expect.element(page.getByText(hint, { exact: true })).toBeVisible(); + } +}); + +test('an existing Unlisted value is displayed on load', async () => { + setLocale('en'); + await render(VisibilitySelect, { props: { value: 'unlisted' } }); + await expect.element(page.getByRole('button', { name: 'Visibility' })).toHaveTextContent('Unlisted'); +}); diff --git a/frontend/src/lib/i18n/en.json b/frontend/src/lib/i18n/en.json index 6572f081..e03065e3 100644 --- a/frontend/src/lib/i18n/en.json +++ b/frontend/src/lib/i18n/en.json @@ -545,6 +545,17 @@ } }, "eventTypes": { + "visibility": { + "label": "Visibility", + "public": "Public", + "unlisted": "Unlisted", + "private": "Private", + "hint": { + "public": "Listed in public directories and bookable by anyone with the link.", + "unlisted": "Hidden from public directories. Anyone with the link can book; no sign-in is required.", + "private": "Hidden from public directories and unavailable through the public booking link." + } + }, "headTitle": "Event Types — Calnode", "title": "Event Types", "subtitle": { @@ -1597,9 +1608,7 @@ }, "status": { "active": "Active", - "inactive": "Inactive", - "listed": "Listed", - "unlisted": "Unlisted (link only)" + "inactive": "Inactive" }, "durationSuffix": " min" }, @@ -1622,8 +1631,6 @@ "descriptionPlaceholder": "Optional — supports **bold** and *italic* markdown", "status": "Status", "active": "Active (accepting bookings)", - "visibility": "Visibility", - "public": "Public (visible in booking page)", "showTaken": "Show booked times as unavailable", "showTakenHint": "Booked times appear struck through on the booking page instead of being hidden, so visitors can see the calendar filling up. Only times inside your working hours are shown, never the rest of your day.", "showTakenWarning": "Anyone with the booking link can see which hours are taken.", diff --git a/frontend/src/lib/i18n/fr.json b/frontend/src/lib/i18n/fr.json index 34f34ae4..6611bcbb 100644 --- a/frontend/src/lib/i18n/fr.json +++ b/frontend/src/lib/i18n/fr.json @@ -545,6 +545,17 @@ } }, "eventTypes": { + "visibility": { + "label": "Visibilité", + "public": "Public", + "unlisted": "Non répertorié", + "private": "Privé", + "hint": { + "public": "Visible dans les annuaires publics. Toute personne disposant du lien peut réserver.", + "unlisted": "Masqué dans les annuaires publics. Toute personne disposant du lien peut réserver, sans connexion.", + "private": "Masqué dans les annuaires publics et inaccessible via le lien de réservation public." + } + }, "headTitle": "Types de rendez-vous — Calnode", "title": "Types de rendez-vous", "subtitle": { @@ -1597,9 +1608,7 @@ }, "status": { "active": "Actif", - "inactive": "Inactif", - "listed": "Répertorié", - "unlisted": "Non répertorié (lien uniquement)" + "inactive": "Inactif" }, "durationSuffix": " min" }, @@ -1622,8 +1631,6 @@ "descriptionPlaceholder": "Facultatif — prend en charge le markdown **gras** et *italique*", "status": "Statut", "active": "Actif (accepte les réservations)", - "visibility": "Visibilité", - "public": "Public (visible sur la page de réservation)", "showTaken": "Afficher les horaires réservés comme indisponibles", "showTakenHint": "Les horaires réservés apparaissent barrés sur la page de réservation au lieu d'être masqués, afin que les visiteurs voient le calendrier se remplir. Seuls les horaires dans vos heures de travail sont affichés, jamais le reste de votre journée.", "showTakenWarning": "Quiconque dispose du lien de réservation peut voir quels horaires sont pris.", diff --git a/frontend/src/routes/event-types/+page.svelte b/frontend/src/routes/event-types/+page.svelte index 9a1df60f..c52dac44 100644 --- a/frontend/src/routes/event-types/+page.svelte +++ b/frontend/src/routes/event-types/+page.svelte @@ -1,4 +1,5 @@