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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ All notable changes to OpenSignup are documented here. Format follows [Keep a Ch
- A signup's pages are in the signup's language from top to bottom (#628, #629): the page as a whole (`<html lang>`, which screen readers and the browser's offer to translate go by), the language link previews are told (`og:locale`, which on the edit and unsubscribe pages said English whatever the signup's), and the site footer's links, on the signup's page, its edit and unsubscribe pages, and their not-found pages. A slug with no signup, or a deleted one, gets the instance's language. The page's own content already followed the signup's language. While only English has shipped, nothing changes.
- Organizers now read one word for a signup people can sign up on: **open**, the status beside its title (#638). The preview of an open signup said "This signup is live."; it now says "This signup is open.", which pairs with "This signup is closed." The help pages "Create and publish your first signup", "Close or reopen a signup" and "Connect an AI assistant" say open where they meant taking sign-ups, and "Create and publish your first signup" now says the signup is marked **open** at the top of the page. "Published" stays only where it means no longer a draft, and **Publish and share** and the share panel's green **Published** keep their words, since they are about the step itself. The greyed-out **Sign up** button on a preview no longer asks the organizer of an open signup to publish it: its hint reads "Preview: publish to let people sign up" on a draft and "Preview: people sign up at the public link" on an open signup. The `publish_signup` tool's description says the signup's status becomes open instead of calling it live. `docs/writing-help.md` now defines publish, published, open and closed, and the help pages' style check fails on calling a signup "live", as a new check on the connector tools' descriptions does. The stored status, the API, the tools' fields and the activity log are unchanged.
- An address no page matches now gets the site's own 404 page (#621): "Sorry, we can’t find this page", a line saying to check the address or ask whoever sent the link for a new one, a **Go to the home page** link and the site footer, in place of Next's bare "404 | This page could not be found." It is marked `lang="en"`, still answers 404 and stays out of search results. Behind it, the app now has three root layouts, one for the home, help and legal pages, one for the organizer app, sign-in and OAuth consent, and one for a signup's pages, so a later change can mark a signup's pages with the signup's language while help and legal stay static. No address changes and every other page looks the same, but following a link from one of these areas to another now loads the whole page. Link previews name the share image as `/opengraph-image.png` and `/twitter-image.png` everywhere, without the version query the home page and a few others had. A signup's page and its edit link's page each load 0.2 kB less JavaScript (one layout where there were two), and their budgets in `budgets.json` come down by the same, to 130.3 and 113.5 kB.
- The organizer pages' `<html lang>` follows the organizer (#938): the organizer app and the AI assistant's consent screen say the organizer's language, and the sign-in pages the instance's `DEFAULT_LOCALE`, else English, the same language as each page's text, so screen readers and browser translation take the whole page in it, the parts no screen marks itself too, such as the share panel's sheet on a phone. For this, the organizer app, sign-in and the consent screen each have a root layout of their own in place of the one they shared, so going from one to another loads the whole page, and a page reached by signing in or out never keeps the language of the one before. Saving a new language in account Settings updates it with no reload. While only English has shipped, which is today, every page still says `en`.
- A signup's Settings tab has one **Save** for its settings (#899's tophat). "Ask for an email address" and, once a second language has shipped, "Signup language" each had a Save of their own, and saving one dropped an unsaved change in the other without a word. Save sends only the choices changed since the tab loaded, so it no longer puts back a language changed elsewhere meanwhile (by account Settings' switch or an AI assistant). The language's help adds "People who already signed up see it in the new language too."
- The Settings tab's last card is called "Delete this signup" instead of "Danger zone" (#977's tophat), and its **Delete signup** button has a full red outline, so it reads as a button on the card's pink.
- The unsubscribe page says "The link may be incomplete, or the signup has been deleted." for a link it can't read (#931's tophat), as the edit-link page does, instead of "It may have been mangled in transit, or the signup may have been deleted."
Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Optional feature: organizers paste a description and get a draft signup. Provide

### Routes

There are three root layouts and none above them, so each can set `<html lang>` while help and legal stay static: `(site)` (home, help, legal), `(organizer)` (`/app`, `/login`, `/oauth`) and `s/[slug]` (a signup's pages). Route groups don't change URLs. What they share (metadata, viewport, font, `globals.css`, the `<html>` element) is `src/app/root-shell.tsx`; an address no page matches gets `src/app/global-not-found.tsx` (`experimental.globalNotFound`). A new page goes inside one of the three: outside them it has no root layout, and `next dev` quietly writes a bare one beside it, with no shell and no `lang`. A link from one group to another is a full page load.
There are five root layouts and none above them, so each can set `<html lang>` while help and legal stay static: `(site)` (home, help, legal); in `(organizer)`, `app` (`/app`) and `oauth` (`/oauth`), in the organizer's language (`localeOfOrganizer`, from the session their pages read anyway), and `login` (`/login`), in the site default (`signInLocale()`), which reads no session; and `s/[slug]` (a signup's pages). Route groups don't change URLs. What they share (metadata, viewport, font, `globals.css`, the `<html>` element) is `src/app/root-shell.tsx`; an address no page matches gets `src/app/global-not-found.tsx` (`experimental.globalNotFound`). A new page goes under one of them: outside them it has no root layout, and `next dev` quietly writes a bare one beside it, with no shell and no `lang`. A link from one root layout to another is a full page load. A page in the same folder as its root layout (`/login`, `/s/[slug]`) misses the layout's title template, so it writes the site name into its own tab title. A root layout isn't rendered again on a client-side navigation, but a server action that redirects renders the whole page it goes to, so saving the organizer's language in account Settings updates `<html lang>` too.

- Organizer UI: `src/app/(organizer)/app/...` (requires session).
- Public participant page: `src/app/s/[slug]/...` (no auth, cookie-based "returning participant" flow).
Expand Down
4 changes: 2 additions & 2 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ const nextConfig = {
},
experimental: {
// An address no page matches gets src/app/global-not-found.tsx. The app
// has three root layouts (src/app/root-shell.tsx says why) and none above
// them, so without this Next's built-in 404 renders in a bare document
// has several root layouts (src/app/root-shell.tsx says why) and none
// above them, so without this Next's built-in 404 renders in a bare document
// with no `<html lang>`. If the flag goes away, a
// `src/app/(site)/[...missing]/page.tsx` that calls `notFound()` with a
// `(site)/not-found.tsx` does the same job.
Expand Down
5 changes: 3 additions & 2 deletions src/app/(organizer)/app/(chrome)/signups/[id]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ export default async function SignupDetailLayout({ children, params }: LayoutPro
const { id } = await params;
const session = await requireOrganizerSession();
const actor = toActor(session);
// The header's language. It changes only with a full page load (#938), so
// this layout not re-rendering between tabs leaves it right.
// The header's language. It changes only when the organizer saves one in
// account Settings, a server action whose redirect renders every layout
// again (#938), so this layout not re-rendering between tabs leaves it right.
const locale = localeOfOrganizer(session);
const result = await loadSignupForOrganizer(actor, id);
if (!result.ok) {
Expand Down
29 changes: 29 additions & 0 deletions src/app/(organizer)/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { getOrganizerSession } from '@/auth/session';
import { localeOfOrganizer } from '@/i18n/locale';
import { RootShell, rootMetadata, rootViewport } from '../../root-shell';

export const metadata = rootMetadata;
export const viewport = rootViewport;

/**
* The root layout for the organizer app (`/app`), in the organizer's language
* (`localeOfOrganizer`), as its pages' text is. With nobody signed in, it's
* the language of an account with none stored, the site default, else
* English, which is what the page that sends them to sign in is in.
*
* Every page here reads the session itself (`requireOrganizerSession`), and
* the read is cached for the request, so this costs no statement. Sign-in's
* check and confirm pages read none, and must not start to, so the sign-in
* pages have a root layout of their own (`../login/layout.tsx`), and so does
* the AI assistant's consent screen (`../oauth/layout.tsx`), which is in the
* organizer's language too.
*
* A root layout isn't rendered again on a client-side navigation, but the
* language only changes when the organizer saves one in account Settings,
* and a server action that redirects renders the page it goes to whole, this
* layout included. Going to or from sign-in or the consent screen crosses
* root layouts, which loads the whole page.
*/
export default async function OrganizerAppLayout({ children }: { children: React.ReactNode }) {
return <RootShell lang={localeOfOrganizer(await getOrganizerSession())}>{children}</RootShell>;
}
13 changes: 0 additions & 13 deletions src/app/(organizer)/layout.tsx

This file was deleted.

18 changes: 18 additions & 0 deletions src/app/(organizer)/login/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { signInLocale } from '@/i18n/locale';
import { RootShell, rootMetadata, rootViewport } from '../../root-shell';

export const metadata = rootMetadata;
export const viewport = rootViewport;

/**
* The root layout for the sign-in pages (`/login` and its check and confirm
* pages), in the site default, else English (`signInLocale`), as their text
* is: nobody is signed in on them yet. It reads no session, so a page that
* reads none (check and confirm) doesn't start loading one, and an organizer
* who opens one while signed in sees it in the language it's written in.
* Signing in leaves for another root layout, which loads the whole page in
* the organizer's language.
*/
export default function SignInLayout({ children }: { children: React.ReactNode }) {
return <RootShell lang={signInLocale()}>{children}</RootShell>;
}
12 changes: 9 additions & 3 deletions src/app/(organizer)/login/page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { cleanup, render, screen, within } from '@testing-library/react';
import { CATALOG_LOCALES } from '@/i18n/config';
import { ship } from '@/i18n/testing/ship';
import type { ServiceError } from '@/lib/errors';
import { INSTANCE_NAME } from '@/lib/site-config';
import type { LoginForm as LoginFormType } from './login-form';

// The instance's DEFAULT_LOCALE, the sign-in providers it has set up, and
Expand Down Expand Up @@ -94,7 +95,10 @@ describe('the sign-in page', () => {
expect(screen.queryByText('or')).not.toBeInTheDocument();
const footer = within(screen.getByRole('navigation', { name: 'Footer' }));
expect(footer.getByRole('link', { name: 'Privacy' })).toHaveAttribute('href', '/privacy');
expect(await generateMetadata()).toEqual({ title: 'Sign in', robots: { index: false } });
expect(await generateMetadata()).toEqual({
title: { absolute: `Sign in · ${INSTANCE_NAME}` },
robots: { index: false },
});
});

it('offers each sign-in provider the instance has set up, in English', async () => {
Expand Down Expand Up @@ -127,7 +131,9 @@ describe('the sign-in page', () => {
const { frame } = await renderPage();
expect(frame).toHaveAttribute('lang', 'en');
expect(screen.getByRole('heading', { level: 1 })).toHaveTextContent('Sign in to OpenSignup');
expect(await generateMetadata()).toMatchObject({ title: 'Sign in' });
expect(await generateMetadata()).toMatchObject({
title: { absolute: `Sign in · ${INSTANCE_NAME}` },
});
});

it('is in that language once it has shipped to organizers', async () => {
Expand Down Expand Up @@ -159,7 +165,7 @@ describe('the sign-in page', () => {
);
expect(footer.getByRole('link', { name: `common.footer.privacy in ${other}` })).toBeVisible();
expect(await generateMetadata()).toEqual({
title: `auth.tabTitle in ${other}`,
title: { absolute: `auth.tabTitle in ${other} · ${INSTANCE_NAME}` },
robots: { index: false },
});
});
Expand Down
7 changes: 6 additions & 1 deletion src/app/(organizer)/login/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@ import { getDb } from '@/db/client';
import { signInLocale } from '@/i18n/locale';
import { getServerTranslator } from '@/i18n/server';
import { RateLimits, chargeRateLimit, ipSubject } from '@/lib/rate-limit';
import { INSTANCE_NAME } from '@/lib/site-config';
import { EmailSchema } from '@/schemas/common';
import { codeRefusal } from './code-refusal';
import { LoginForm, type CodeActionResult, type LoginActionResult } from './login-form';
import { loginFormText } from './login-text';
import { OAuthButtons } from './oauth-buttons';
import { requestMagicLink } from './request-magic-link';

// The tab title, with the site name after it. Next applies the root layout's
// title template only to the segments below the layout's own, and this page
// shares its segment with that layout (./layout.tsx), so it writes the site
// name in itself, the way the template does for every other page.
export async function generateMetadata(): Promise<Metadata> {
const t = getServerTranslator(signInLocale(), 'auth');
return { title: t('tabTitle'), robots: { index: false } };
return { title: { absolute: `${t('tabTitle')} · ${INSTANCE_NAME}` }, robots: { index: false } };
}

export default async function LoginPage({
Expand Down
22 changes: 22 additions & 0 deletions src/app/(organizer)/oauth/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { getOrganizerSession } from '@/auth/session';
import { localeOfOrganizer } from '@/i18n/locale';
import { RootShell, rootMetadata, rootViewport } from '../../root-shell';

export const metadata = rootMetadata;
export const viewport = rootViewport;

/**
* The root layout for the AI assistant's consent screen (`/oauth/consent`),
* in the organizer's language (`localeOfOrganizer`), as the screen's text is:
* they're signed in by then. With nobody signed in, the page says the request
* can't go on, or sends them to sign in, in the site default, else English,
* and so does this. The page reads the session itself, and the read is
* cached for the request, so this costs no statement. `../app/layout.tsx`
* says why the sign-in pages have a root layout of their own.
*
* The provider's error pages aren't under it: they're HTML the provider
* writes (`src/oauth/provider.ts`), in the sign-in pages' language.
*/
export default async function ConsentLayout({ children }: { children: React.ReactNode }) {
return <RootShell lang={localeOfOrganizer(await getOrganizerSession())}>{children}</RootShell>;
}
Loading
Loading