From d0fc11030d3cd0afc30c2928637eb52eaf162d49 Mon Sep 17 00:00:00 2001 From: eleith Date: Sat, 21 Nov 2026 06:47:51 -0800 Subject: [PATCH] fix(admin): show the GoTo title and app icon --- .changeset/admin-nav-title.md | 7 ++++ README.md | 9 ++--- apps/cli/src/cli.test.ts | 22 +++++++----- apps/web/e2e/auth.e2e.ts | 26 +++++++++----- .../src/lib/components/admin/AdminNav.svelte | 34 ++++++++++--------- .../src/lib/components/admin/AdminPage.svelte | 6 ++-- .../src/lib/server/request-context.test.ts | 5 ++- .../routes/(admin)/(auth)/admin/+page.svelte | 2 +- .../admin/domains/[domain]/+page.svelte | 1 - .../admin/domains/[domain]/links/+page.svelte | 1 - .../[domain]/links/[...path]/+page.svelte | 1 - .../(admin)/(auth)/admin/health/+page.svelte | 2 +- .../(auth)/admin/tags/[tag]/+page.svelte | 1 - .../(admin)/(public)/signin/+page.svelte | 4 +-- apps/web/src/routes/(admin)/+layout.server.ts | 5 --- examples/goto.yaml | 3 -- packages/config/src/config.schema.json | 34 ------------------- packages/config/src/diagnostics.test.ts | 16 ++++----- packages/config/src/editor-schema.test.ts | 5 ++- packages/config/src/load.test.ts | 34 +++++-------------- packages/config/src/schema.ts | 20 ----------- 21 files changed, 87 insertions(+), 151 deletions(-) create mode 100644 .changeset/admin-nav-title.md delete mode 100644 apps/web/src/routes/(admin)/+layout.server.ts diff --git a/.changeset/admin-nav-title.md b/.changeset/admin-nav-title.md new file mode 100644 index 0000000..c042090 --- /dev/null +++ b/.changeset/admin-nav-title.md @@ -0,0 +1,7 @@ +--- +'@goto/web': patch +'@goto/cli': patch +'@goto/worker': patch +--- + +Fix the admin and sign-in title to GoTo and remove the `site` config section. Show the app icon beside the title, link the pair to Overview only from other pages, and move Health next to the theme switcher. diff --git a/README.md b/README.md index 9a09e10..7a96885 100644 --- a/README.md +++ b/README.md @@ -50,10 +50,11 @@ The shared `@goto/config` package validates the YAML contract; the web runtime d not load it yet. See [the example](examples/goto.yaml) and [the package API](packages/config/README.md). -Configuration is a single `config/goto.yaml` with `site`, `appearance`, `auth`, -`database`, `analytics`, `defaults`, and `domains` sections. Unknown fields and -null values fail validation. Auth declares exactly one OIDC or shared-credentials -provider; `auth.secret` is optional and is not generated by the loader. +Configuration is a single `config/goto.yaml` with top-level keys `version`, +`url`, `appearance`, `auth`, `database`, `analytics`, `link_defaults`, `fallback`, +and `domains`. Unknown fields and null values fail validation. Auth declares +exactly one OIDC or shared-credentials provider; `auth.secret` is optional and +is not generated by the loader. Redirect status and query forwarding inherit built-in → global → domain → link. Fallback inherits only through domain scope. Defaults are 302, forwarding off, diff --git a/apps/cli/src/cli.test.ts b/apps/cli/src/cli.test.ts index d67faa9..97d5ed2 100644 --- a/apps/cli/src/cli.test.ts +++ b/apps/cli/src/cli.test.ts @@ -176,11 +176,12 @@ describe('goto-cli config validate', () => { environment: env }, { - name: 'actual error alongside dropped tags', - source: `${validYaml} tags: [., ""]\nsite: {title: null}\n`, - environment: env + name: 'invalid appearance alongside dropped tags', + source: `${validYaml} tags: [., ""]\nappearance: false\n`, + environment: env, + issue: '\n /appearance: Expected object\n' } - ])('reports $name without disclosing configuration', async ({ source, environment }) => { + ])('reports $name without disclosing configuration', async ({ source, environment, issue }) => { await writeConfiguration('config/goto.yaml', source); const output = createOutput(); @@ -190,6 +191,7 @@ describe('goto-cli config validate', () => { expect.stringMatching(/^Configuration validation failed\.\n/) ); const diagnostic = output.stderr.mock.calls[0]?.[0]; + if (issue !== undefined) expect(diagnostic).toContain(issue); for (const sensitive of [...Object.values(env), ...Object.values(environment)]) { if (sensitive !== undefined) expect(diagnostic).not.toContain(sensitive); } @@ -198,17 +200,19 @@ describe('goto-cli config validate', () => { expect(diagnostic).not.toContain('config/goto.yaml'); }); - it('reports the site section for an unsupported site.url without printing its value', async () => { - const oldSiteUrl = 'https://old.example.test/private-do-not-print'; - await writeConfiguration('config/goto.yaml', `${validYaml}site:\n url: ${oldSiteUrl}\n`); + it('rejects the removed site section without printing its custom title', async () => { + const oldTitle = 'Private title not for diagnostics'; + await writeConfiguration('config/goto.yaml', `${validYaml}site:\n title: ${oldTitle}\n`); const output = createOutput(); expect(await runCli(['config', 'validate'], output, { cwd, env })).toBe(1); expect(output.stdout).not.toHaveBeenCalled(); expect(output.stderr).toHaveBeenCalledExactlyOnceWith( - expect.stringMatching(/^Configuration validation failed\.\n {2}\/site: \S[^\n]*\n$/) + expect.stringMatching( + /^Configuration validation failed\.\n {2}\/: Unexpected property\.[^\n]*\n$/ + ) ); - expect(output.stderr.mock.calls[0]?.[0]).not.toContain(oldSiteUrl); + expect(output.stderr.mock.calls[0]?.[0]).not.toContain(oldTitle); }); it('reports a missing file without disclosing the path', async () => { diff --git a/apps/web/e2e/auth.e2e.ts b/apps/web/e2e/auth.e2e.ts index 9a3604e..bc2f8a3 100644 --- a/apps/web/e2e/auth.e2e.ts +++ b/apps/web/e2e/auth.e2e.ts @@ -32,6 +32,8 @@ test('shared credentials protect admin pages and sign-out removes access', async const signInPage = await page.goto(`${appServer.origin}/admin`); await expect(page).toHaveURL(/\/signin\?/); expect(signInPage?.headers()['cache-control']).toBe('private, no-store'); + await expect(page).toHaveTitle('Sign in — GoTo'); + await expect(page.getByRole('heading', { name: 'Sign in to GoTo', exact: true })).toBeVisible(); await page.getByLabel('Username', { exact: true }).fill('example'); await page.getByLabel('Password', { exact: true }).fill('incorrect'); const failedSignIn = page.waitForResponse(`${appServer.origin}/auth/sign-in/credentials`); @@ -145,11 +147,15 @@ test('shared credentials protect admin pages and sign-out removes access', async await expect(visitsValue).toHaveText('4'); await expect(graph).toHaveAccessibleName(/^Visits by week\. Total: 4\./); expect(navigationWarnings).toEqual([]); + const adminNav = page.getByRole('navigation', { name: 'Administration', exact: true }); + const overviewLink = adminNav.getByRole('link', { name: 'GoTo', exact: true }); + await expect(adminNav.getByText('GoTo', { exact: true })).toBeVisible(); + await expect(overviewLink).toHaveCount(0); await domainLink.click(); await expect(page.getByRole('heading', { name: 'Domain', exact: true })).toBeVisible(); const context = page.locator('.admin-context'); await expect(context).toHaveCount(0); - await expect(page).toHaveTitle('Domain — go.example.org — Goto'); + await expect(page).toHaveTitle('Domain — go.example.org — GoTo'); await expect(acceptedLanguages).toBeVisible(); await expect(browsers.getByRole('columnheader')).toHaveText(['Browser', 'Visits', 'Share']); await expect(operatingSystems.getByRole('columnheader')).toHaveText([ @@ -158,10 +164,12 @@ test('shared credentials protect admin pages and sign-out removes access', async 'Share' ]); await expect(browsers.getByRole('rowheader', { name: 'Other', exact: true })).toBeVisible(); - const overviewLink = page - .getByRole('navigation', { name: 'Administration', exact: true }) - .getByRole('link', { name: 'Goto', exact: true }); await expect(overviewLink).toHaveAttribute('href', '/admin?period=all'); + const appIcon = overviewLink.locator('img[src="/@static/favicon.svg"]'); + await expect(appIcon).toBeVisible(); + await expect + .poll(() => appIcon.evaluate((image: HTMLImageElement) => image.naturalWidth)) + .toBeGreaterThan(0); await expect(page.getByRole('link', { name: 'Overview', exact: true })).toHaveCount(0); await expect(graph).toHaveAttribute('aria-busy', 'false'); await expect(graph).toHaveAccessibleName(/^Visits by week\. Total: 3\./); @@ -297,7 +305,7 @@ test('shared credentials protect admin pages and sign-out removes access', async await expect(redirectCard.locator('dd').nth(1)).toHaveText('/docs'); await expect(page.locator('.admin-cards .admin-stat-label')).toHaveText(['Visits', 'Status']); await expect(page.getByRole('region', { name: 'Status', exact: true })).toContainText('Active'); - await expect(page).toHaveTitle('Link — go.example.org/docs — Goto'); + await expect(page).toHaveTitle('Link — go.example.org/docs — GoTo'); await expect(graph).toHaveAttribute('aria-busy', 'false'); await expect(chartTable).toHaveAccessibleName('Visits'); await expect(graph).toHaveAccessibleName(/^Visits by week\. Total: 1\./); @@ -343,7 +351,7 @@ test('shared credentials protect admin pages and sign-out removes access', async const tagHeading = page.getByRole('heading', { name: `Tag: ${sharedTag}`, exact: true }); await expect(tagHeading).toBeVisible(); await expect(tagHeading).toHaveAttribute('title', `Tag: ${sharedTag}`); - await expect(page).toHaveTitle(`Tag: ${sharedTag} — Goto`); + await expect(page).toHaveTitle(`Tag: ${sharedTag} — GoTo`); await expect(page.getByRole('region', { name: 'Tag details', exact: true })).toHaveCount(0); const taggedLinks = page.getByRole('region', { name: `Links tagged ${sharedTag}`, exact: true }); await expect(taggedLinks.getByRole('link')).toHaveCount(2); @@ -373,7 +381,7 @@ test('shared credentials protect admin pages and sign-out removes access', async await domainLink.click(); await page.getByRole('link', { name: '/a%2Fb', exact: true }).click(); await expect(page.getByRole('heading', { name: 'Link', exact: true })).toBeVisible(); - await expect(page).toHaveTitle('Link — go.example.org/a%2Fb — Goto'); + await expect(page).toHaveTitle('Link — go.example.org/a%2Fb — GoTo'); await expect(redirectCard.getByText('Title', { exact: true })).toHaveCount(0); await expect(page).toHaveURL( `${appServer.origin}/admin/domains/go.example.org/links/a%252Fb?period=all` @@ -385,14 +393,14 @@ test('shared credentials protect admin pages and sign-out removes access', async `${appServer.origin}/admin/domains/go.example.org/links/a/b?period=all` ); await expect(page.getByRole('heading', { name: 'Link', exact: true })).toBeVisible(); - await expect(page).toHaveTitle('Link — go.example.org/a/b — Goto'); + await expect(page).toHaveTitle('Link — go.example.org/a/b — GoTo'); await expect(visitsValue).toHaveText('0'); await page.goBack(); await rootLink.click(); await expect(page).toHaveURL(`${appServer.origin}/admin/domains/go.example.org/links?period=all`); await expect(page.getByRole('heading', { name: 'Root', exact: true })).toBeVisible(); - await expect(page).toHaveTitle('Root — go.example.org — Goto'); + await expect(page).toHaveTitle('Root — go.example.org — GoTo'); await expect(acceptedLanguages).toBeVisible(); await expect(visitsValue).toHaveText('1'); await expect(page.getByRole('region', { name: 'Status', exact: true })).toHaveCount(0); diff --git a/apps/web/src/lib/components/admin/AdminNav.svelte b/apps/web/src/lib/components/admin/AdminNav.svelte index 916d96f..765766a 100644 --- a/apps/web/src/lib/components/admin/AdminNav.svelte +++ b/apps/web/src/lib/components/admin/AdminNav.svelte @@ -5,9 +5,10 @@ import { authClient } from '#lib/auth-client.js'; import ThemeToggle from '../ThemeToggle.svelte'; - let { title, overviewHref }: { title: string; overviewHref: string } = $props(); + let { overviewHref }: { overviewHref: string } = $props(); let currentPath = $derived(page.url.pathname + page.url.search); + let onOverview = $derived(page.url.pathname === '/admin'); let pending = $state(false); let signoutError = $state<'rate' | 'network' | 'auth' | null>(null); @@ -47,12 +48,19 @@ }} /> +{#snippet titleWithIcon()} + + GoTo +{/snippet} +
- + {#if signoutError}
diff --git a/apps/web/src/lib/server/request-context.test.ts b/apps/web/src/lib/server/request-context.test.ts index 4a91c54..8e99d0b 100644 --- a/apps/web/src/lib/server/request-context.test.ts +++ b/apps/web/src/lib/server/request-context.test.ts @@ -111,8 +111,7 @@ test('an existing request retains its snapshot when the application publishes an current = prepareSnapshot( loadConfig( { - url: { app: 'https://admin.example.org' }, - site: { title: 'Updated' }, + url: { app: 'https://updated-admin.example.org' }, auth: { credentials: { username: 'example', password: 'test-password' } }, domains: {} }, @@ -124,7 +123,7 @@ test('an existing request retains its snapshot when the application publishes an expect(requestSnapshot(first)).toBe(initial); expect(requestSnapshot(second)).toBe(current); - expect(requestSnapshot(first)?.configuration.site.title).toBe('Goto'); + expect(requestSnapshot(first)?.configuration.url.app).toBe('https://admin.example.org'); }); test('binding neither consumes the request body nor serializes private configuration', async () => { diff --git a/apps/web/src/routes/(admin)/(auth)/admin/+page.svelte b/apps/web/src/routes/(admin)/(auth)/admin/+page.svelte index f22cf9e..3a7bb6f 100644 --- a/apps/web/src/routes/(admin)/(auth)/admin/+page.svelte +++ b/apps/web/src/routes/(admin)/(auth)/admin/+page.svelte @@ -26,7 +26,7 @@ let acceptedLanguageVisits = $derived(data.acceptedLanguageVisitsByTimeframe[timeframe] ?? null); - + {#snippet actions()} {#if data.available && data.timeframes.length > 0} - +

Application

diff --git a/apps/web/src/routes/(admin)/(auth)/admin/tags/[tag]/+page.svelte b/apps/web/src/routes/(admin)/(auth)/admin/tags/[tag]/+page.svelte index 7415a23..9e2e62e 100644 --- a/apps/web/src/routes/(admin)/(auth)/admin/tags/[tag]/+page.svelte +++ b/apps/web/src/routes/(admin)/(auth)/admin/tags/[tag]/+page.svelte @@ -28,7 +28,6 @@ - Sign in — {data.title} + Sign in — GoTo