diff --git a/.changeset/36739-org-basics-checklist-pill.md b/.changeset/36739-org-basics-checklist-pill.md new file mode 100644 index 00000000000..b3c5bfde34a --- /dev/null +++ b/.changeset/36739-org-basics-checklist-pill.md @@ -0,0 +1,19 @@ +--- +'@object-ui/console': patch +'@object-ui/app-shell': patch +'@object-ui/i18n': patch +--- + +feat(console): the first-run checklist asks for the organization's basics in one form, leaves the rest optional, and follows the administrator as a 「Get started n/m」 pill in the sidebar + +Clause-②: yes (widening) +Metadata-protocol: none + +The administrator's first-run checklist had five setup rows that each saved on their own (the organization's name, language and country, timezone, currency) and counted every row, so it only went away once mail, invitations and AI were set up too. Following the maintainer's ruling on objectstack#36739: + +- **One form, one save.** A single 「Organization basics」 row opens one form with the organization's name, default language, country, timezone and currency. Values the server does not hold yet are suggested from the browser, and a setting with neither a value nor a suggestion must be filled in like the name; nothing is written until Save, which renames the organization (when the name changed) and writes the four settings in one call. A refused rename or a refused setting shows on its field, as before. The row is done once the organization has a real name and all four settings are set. +- **Only the basics are required.** Mail, invitations, the built-in AI provider and connecting an outside assistant become optional rows (marked 「Optional」); they still tick themselves when the server says they are done. On the hosted profile, 「Put in your first app」 stays required. The checklist is complete, and stands aside on Home, once the required rows are done; its progress (n/m) still counts every row. +- **A pill in every app.** For the administrator only, a 「Get started n/m」 pill sits at the bottom of every app's sidebar (on the folded icon rail it keeps its icon, with the count in its accessible name and tooltip). A press opens the checklist in place in a popover; the popover's X only closes it, and 「Hide on this device」 under the list hides the pill and Home's card. On a phone, which has no resident sidebar, the pill sits after the app's menu on the app's home page. It disappears once the required rows are done, or once the administrator hides it on this device. +- **Setup's first page keeps the full list**, done rows included, even after the checklist is complete or hidden; a completed list folds to one line with 「Show list」. + +`@object-ui/app-shell` exports a product-neutral `SidebarFooterSlotProvider` (with its `SidebarFooterSlot` and `SidebarFooterSlotPlace` types; places `'sidebar' | 'phoneAppHome'`) that the console fills; the shell names no checklist. `@object-ui/i18n` replaces the per-setting checklist strings in all eleven packs. Added under `console.firstRunChecklist`: `showList`, `hideHere`, `organizationBasics.{title,todo,name,nameRequired,prefilled,save,saved}`, `pill.{label,count,aria}`. Removed from `console.firstRunChecklist` (no reader is left in the console; a consumer that indexed them reads the new keys instead): `showDoneSplit`, `confirm`, `prefilled`, `organizationName.{title,todo,action}`, `languageCountry.{title,todo,saved}`, `timezone.{title,todo,saved}`, `currency.{title,todo,saved}`. diff --git a/ui/apps/console/src/AppContent.tsx b/ui/apps/console/src/AppContent.tsx index cdf3e490f21..0ec9fdd5d5a 100644 --- a/ui/apps/console/src/AppContent.tsx +++ b/ui/apps/console/src/AppContent.tsx @@ -11,13 +11,15 @@ import { lazy, Suspense, useEffect, useMemo, type ReactNode } from 'react'; import { Route, useParams, useLocation, Navigate } from 'react-router-dom'; -import { DefaultAppContent, ENVIRONMENT_SCOPE_QUERY, LauncherAppsProvider, LoadingFallback, LoadingScreen, SetupFirstPageSlotProvider, setupMetadataStudioPath, useAdapter } from '@object-ui/app-shell'; +import { DefaultAppContent, ENVIRONMENT_SCOPE_QUERY, LauncherAppsProvider, LoadingFallback, LoadingScreen, SetupFirstPageSlotProvider, SidebarFooterSlotProvider, setupMetadataStudioPath, useAdapter, type SidebarFooterSlotPlace } from '@object-ui/app-shell'; import { AdapterCtx } from '@object-ui/react'; import { MePermissionsProvider, ServerReadScope, releaseMePermissionsRequest, startMePermissionsRequest } from '@object-ui/permissions'; import { createAuthenticatedFetch, useAuth } from '@object-ui/auth'; import type { DataSource } from '@object-ui/types'; import { LocalizationFetchProvider } from './LocalizationFetchProvider'; import { FirstRunChecklist } from './pages/settings/FirstRunChecklist'; +import { FirstRunChecklistPill } from './pages/settings/FirstRunChecklistPill'; +import { FirstRunChecklistProvider } from './pages/settings/firstRunChecklistState'; import { InAppFormRoute } from './components/InternalFormRoute'; import { APPROVAL_ACTION_OBJECT, APPROVAL_REQUEST_OBJECT, routeApprovalRecordReads } from './services/approvalRequestsDataSource'; import { studioLandingPath } from '@object-ui/app-shell'; @@ -422,12 +424,23 @@ export function ConsolePermissionsRequest(): null { /** * objectstack#36732 (item 5, option A) — an administrator's first-run * checklist at the top of the Setup app's first page, now that the desktop's - * home page retired. The checklist decides who sees it (a session that may - * write the settings it lists) and hides once the list is done; this route - * sits under `ConsolePermissionsScope`, which answers the first. + * home page retired. Since objectstack#36739 this is the FULL list, done rows + * included, kept for looking back once it is finished. The checklist decides + * who sees it (a session that may write the settings it lists); this route + * sits under `ConsolePermissionsScope`, which answers that. */ function setupFirstPageChecklist() { - return ; + return ; +} + +/** + * objectstack#36739 — the administrator's 「Get started n/m」 pill at the bottom + * of every app's sidebar (after the app's menu on a phone), opening the + * first-run checklist in place. It stands aside for a member and once the + * required rows are done. + */ +function sidebarFooterPill(where: SidebarFooterSlotPlace) { + return ; } /** @@ -486,7 +499,12 @@ export function ConsolePermissionsScope({ children }: { children: ReactNode }) { drops an app the user's permission sets hide. One read for Home and every app, so this common ancestor holds it, beside the answer above. */} - {children} + {/* objectstack#36739 — the first-run checklist's reads, made once for + every place it is drawn (the sidebar pill, Setup's first page, + Home), so moving between apps asks nothing again. */} + + {children} + ); diff --git a/ui/apps/console/src/pages/settings/FirstRunChecklist.tsx b/ui/apps/console/src/pages/settings/FirstRunChecklist.tsx index 0e6773f333e..f443c499cc8 100644 --- a/ui/apps/console/src/pages/settings/FirstRunChecklist.tsx +++ b/ui/apps/console/src/pages/settings/FirstRunChecklist.tsx @@ -1,137 +1,77 @@ // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. /** - * — what an administrator sets up first, at the top of Home - * (objectstack#30206). It replaces the dialog that asked for the workspace - * timezone and default currency on the first screens (objectui#11758, - * objectstack#28872), which opened before anything needed a currency and once - * covered the toast that said how to share an invitation (objectstack#30125 - * row 3). + * — what an administrator sets up first (objectstack#30206), + * drawn from the one set of reads `FirstRunChecklistProvider` makes + * (`firstRunChecklistState.tsx`). It replaces the dialog that asked for the + * workspace timezone and default currency on the first screens (objectui#11758, + * objectstack#28872). * - * ## Where it is drawn + * ## Where it is drawn (`placement`) * - * From 768 px up, at the top of the Setup app's first page (objectstack#36732, - * item 5, option A): the desktop's platform home page retired, so an - * administrator who has an app lands in it, and Setup's first page is where - * the platform is set up. Handed to app-shell's `SetupFirstPageSlotProvider` - * by the console's app route (`AppContent.tsx`). + * - `popover`: opened in place from the sidebar's 「Get started n/m」 pill + * (`FirstRunChecklistPill`), in every app, while a required row is left + * (objectstack#36739). Done rows fold away; its X only closes the popover, + * and 「Hide on this device」 under the list hides the pill and Home's card. + * - `setupPage`: the top of the Setup app's first page (objectstack#36732), + * handed to app-shell's `SetupFirstPageSlotProvider` by the console's app + * route. The FULL list, done rows included, so an administrator can look + * back at it: it is drawn whether or not the list is finished or hidden on + * this device, and once the required rows are done it folds to one line that + * opens the list again. + * - `top` and `afterApps`: Home's checklist slot (app-shell's `HomePage`): on a + * desktop that is the no-apps empty state, on a phone the card after the apps + * (`afterApps`, which starts folded to one line, objectstack#34596). Both + * stand aside once the required rows are done or the checklist was hidden. + * Above the page (`top`), with two rows left or fewer, the card folds to one + * line: its title, its progress, each row left by its title and a Set button. * - * And Home (`/home`), in the slot Home's page gives its host's checklist - * (app-shell's `HomePage`, `checklist`): on a desktop that is the no-apps - * empty state, so a new environment's first administrator meets it on the - * first screen. Mounted by the console's Home route (`App.tsx`). + * Nothing is drawn for a session the checklist is not for: a member, or one + * whose answers have not arrived (`useFirstRunChecklist` answers `null`). * - * Both mounts sit inside `ConsolePermissionsScope`: that provider is what - * answers which capabilities this session holds. + * ## The rows * - * Home names the placement (`placement`). `top`, above the page's sections - * (a desktop, or a page with no app yet), draws the card as it always was. - * `afterApps` is a phone's: the card sits in the content column after the - * apps and starts folded to one line, its title, its progress and Continue, - * so the first screen keeps the launcher (objectstack#34596). Continue opens - * the card in place, and a fold control closes it again; like the done rows' - * fold, this is the mount's own state and a fresh visit starts folded. - * Folding changes no row and no completion rule. + * Each row's done state is read from the real setting, never from a click + * (`checklistRows`); the required ones come first. * - * ## Who sees it, and what each row says + * 1. The organization's basics, the ONE required platform row + * (objectstack#36739): its name, default language and country, time zone + * and currency, in one form saved by one button. The name is written + * through the organization (`updateOrganization`), the other four through + * the Settings page's own write (`saveSettingsNamespace('localization')`, + * one `PUT /api/settings/localization`, judged against the manifest's + * `writePermission` and audited like any settings save). The browser only + * PRE-FILLS the four keys (objectui#11693 B2): nothing is written until the + * administrator presses Save. Done once the organization carries a name of + * its own and every key is set. + * 2. Email delivery (objectstack#32643), 3. invite colleagues, 4. the + * built-in AI (`live.provider`, never the saved value), 5. connect an + * external AI assistant (`useConnectedAccess`; while it is drawn and not + * done it claims Home's `connect_assistant` item). All OPTIONAL: each says + * so, ticks itself from the real records, and never holds the checklist + * open. Each links to the Setup page where it is done. * - * An administrator: a session that may write `localization` - * (`readChecklistSettings`). A member never sees it, and neither does a - * session whose capability answer has not arrived. Each row's done state is - * read from the real setting (`firstRunChecklistLogic.ts`), never from a click: + * A host adds rows through its profile (`firstRunChecklistProfile.ts`, selected + * by `features.cloudManaged`): on a managed environment 「Put your first app + * in」 (required) and 「Add your first record」 (optional), and the mail row + * only once it reads delivering. * - * 1. Organization name: the organization no longer carries the name the - * platform gave it; links to Setup → Organization. - * 2. Language and country, 3. timezone, 4. default currency: the - * localization keys, edited in place with the Settings page's own fields, - * pre-filled from the browser and written only on the row's Confirm. - * 5. Email delivery, OPTIONAL (objectstack#32643): mail can deliver; links - * to Setup → Mail Delivery. Only for a session that may write mail. The - * row says it is optional and never holds the checklist open - * (`OPTIONAL_ROWS`): a deployment that sends no mail has nothing to set - * up. A setup that delivers still reads done. - * 6. Invite colleagues: a second member or a pending invitation; links to - * Setup → Users, where Invite User is. - * 7. The built-in AI: a provider is in use in the running system, as the - * server states it (`live.provider` of `GET /api/settings/ai`, never the - * saved `values.provider`, which misses a provider the runtime detected - * from its boot environment). The row names the provider and where it - * came from (Setup, or the server's environment) and links to Setup → - * AI & Embedder. Only for a session that may write `ai`; a server that - * states nothing about the provider gets no row (unknown is not unset). - * 8. Connect an external AI assistant: done once this administrator has - * authorized an AI assistant or holds an API key that still works, read - * from those records by `useConnectedAccess` (the read Connect an AI - * Assistant's Connected line uses), never from a click; links to that - * page. Only where the served Account app carries the page (MCP turned - * on). Its words say it is for assistants outside the product, over MCP, - * and not the built-in AI (Setup → AI & Embedder). While this row is - * drawn and not done it claims the `connect_assistant` item, and Home's - * Connect an AI Assistant card stands aside. - * - * ## What the host adds: the profile - * - * The rows above are the platform's. A host can add rows, hide rows that do - * not apply to it, and leave rows optional, through the checklist's PROFILE - * (`firstRunChecklistProfile.ts`), which the served auth config selects - * (`features.cloudManaged`). This component reads the profile's lists and - * never which host it runs on. On a self-hosted deployment the profile is - * empty and the checklist is exactly the rows above. On a managed one: - * - * 9. Put your first app in: the launcher lists an app that is not a platform - * built-in (the launcher's own `/me/apps` answer, no request of its own). - * 10. Add your first record, OPTIONAL there: a person created a record on an - * object those apps list (one `sys_activity` read; the feed keeps 14 days, - * which is why the row is optional). Links to the first of those apps. - * - * and the mail row is drawn only once it reads done. Until the auth config - * answers, nothing is drawn; a config that cannot be read is self-hosted. + * The progress counts every row drawn; the checklist is finished once its + * REQUIRED rows are done (`checklistCompletion`), and comes back on its own if + * a setting is unset again. * * Language and country are named in the page's language (`Intl.DisplayNames`), - * not by the setting's option label: the language options are autonyms, so a - * zh-CN page read 「当前为English、美国 (US)」. - * - * A row whose state cannot be read is left out rather than shown as not done. - * Once every REQUIRED row shown is done the checklist draws nothing, whatever - * the optional rows say (`checklistCompletion`), and its progress line counts - * the required rows alone; it comes back on its own if a setting is unset - * again. - * - * Rows that are done are folded away: the list draws the rows still to do, and - * one control under them names how many are done and shows them (in their - * place in the list) or folds them again, so the card keeps the first screen - * for the work left (objectstack#32157). Unfolding is this mount's own state: - * a fresh visit starts folded. The control counts the required rows and the - * optional ones apart once an optional row is done, since the progress line - * counts the required rows alone (`checklistDoneCount`). - * - * Above the page, once few rows are left to do (`drawsOneLine`: two or fewer, - * optional ones included), the card folds to one line: its title, its - * progress, each row left by its title and a Set button, and the close - * button; no description, no done rows and no control to unfold them. The - * line wraps on a narrow page rather than scroll. A localization row's Set - * opens the full card with that row's editor, and the card folds back to the - * line once the editor closes; every other row's Set opens the page its row - * links to. A phone's card (`afterApps`) folds its own way, above. - * - * ## Hiding it - * - * The close button hides it for this administrator in this workspace on this - * device (`dismissRecordKey`). Nothing is written to the server and no row - * changes: the deployment works the same with every row left as it is. + * not by the setting's option label: the language options are autonyms. * * ## The writes * - * A row's Confirm is `saveSettingsNamespace('localization', changes)`, the - * function `SettingsView` saves through: one `PUT /api/settings/localization`, - * judged by the server against the manifest's `writePermission` and audited - * like any other settings save. Its refusals land where the Settings page puts - * them: a lock names the key, a validation refusal goes to the field's error - * slot (in the console's words for a format miss, `settingsFieldRefusals`), - * anything else carries the server's sentence. Cancel writes nothing. - * - * Its reads wait for the console's first paint (`whenBootPainted`, - * objectui#12980), so they never go out beside the page's own first reads. + * Save writes only what changed: the name when it differs, and the keys whose + * value is not already the key's own (an unset key is written even when the + * offer equals its default, which is what makes it set). Refusals land where + * the Settings page puts them: a lock names the key, a validation refusal goes + * to the field's error slot (in the console's words for a format miss, + * `settingsFieldRefusals`), anything else carries the server's sentence. + * Cancel writes nothing; neither does hiding the checklist. */ import { useEffect, useState, type ReactNode } from 'react'; @@ -139,25 +79,14 @@ import { Link } from 'react-router-dom'; import { toast } from 'sonner'; import { CheckCircle2, ChevronDown, ChevronRight, ChevronUp, Circle, Loader2, X } from 'lucide-react'; import { Button, cn } from '@object-ui/components'; -import { - appRouteSegment, - connectAssistantPath, - resolveSetupAppPath, - useAdapter, - useConnectedAccess, - useHomeItemClaim, - useLauncherApps, - useMetadata, -} from '@object-ui/app-shell'; +import { appRouteSegment, useHomeItemClaim } from '@object-ui/app-shell'; import { useAuth } from '@object-ui/auth'; import { useObjectTranslation } from '@object-ui/i18n'; -import { usePermissions } from '@object-ui/permissions'; import { SettingsField } from './SettingsField'; -import { getSettingsNamespace, lockedKeyOf, saveSettingsNamespace } from './api'; +import { lockedKeyOf, saveSettingsNamespace } from './api'; import { fieldWording, settingsFieldRefusals } from './settingsFieldRefusals'; -import { resolveLabel, type ResolvedSettingValue } from './types'; +import { resolveLabel, type ResolvedSettingValue, type Specifier } from './types'; import { useSettingsLabel, type SettingsLabelHelpers } from './useSettingsLabel'; -import { whenBootPainted } from '../../loadLocales'; import { AI_NAMESPACE, AI_PROVIDER_KEY, @@ -165,36 +94,12 @@ import { CURRENCY_KEY, LOCALE_KEY, LOCALIZATION_NAMESPACE, - TIMEZONE_KEY, - checklistCompletion, - checklistDoneCount, - deviceStorage, - dismissRecordKey, drawsOneLine, - hasInvitedColleagues, isOrganizationNamed, - localizationRows, - markDismissed, - readBrowserAnswers, - readChecklistSettings, - wasDismissed, type ChecklistField, - type ChecklistSettingsRow, - type ChecklistSettingsState, + type OrganizationBasics, } from './firstRunChecklistLogic'; -import { - SELF_HOSTED_PROFILE, - appObjectNames, - checklistProfileFor, - hasOwnApp, - isProfileOptionalRow, - ownApps, - profileDrawsRow, - readFirstRecordCreated, - type ChecklistApp, - type FirstRecordSource, - type FirstRunChecklistProfile, -} from './firstRunChecklistProfile'; +import { useFirstRunChecklist, type ChecklistRowState, type FirstRunChecklistData } from './firstRunChecklistState'; type Translate = (key: string, options?: Record) => string; @@ -305,134 +210,164 @@ function RowLink({ to, label, testId }: { to: string; label: string; testId: str ); } -/** A localization row's title. */ -function settingsRowTitle(row: ChecklistSettingsRow, t: Translate): string { - if (row.id === 'language_country') return t('console.firstRunChecklist.languageCountry.title'); - if (row.id === 'timezone') return t('console.firstRunChecklist.timezone.title'); - return t('console.firstRunChecklist.currency.title'); -} - -/** The line under a localization row's title. */ -function settingsRowDetail( - row: ChecklistSettingsRow, - labels: SettingsLabelHelpers, - language: string, - t: Translate, -): string { - // A row that is done shows its value alone; two values are joined by the - // pack's own list separator, the one the Settings page's toasts use. - const named = (field: ChecklistField) => describeValue(field, currentValue(field.resolved), labels, language); - if (row.done) return row.fields.map(named).join(t('validation.formInvalidJoiner')); - if (row.id === 'language_country') { - const [locale, country] = row.fields; - return t('console.firstRunChecklist.languageCountry.todo', { language: named(locale), country: named(country) }); - } - if (row.id === 'timezone') return t('console.firstRunChecklist.timezone.todo', { current: named(row.fields[0]) }); - return t('console.firstRunChecklist.currency.todo'); -} - -/** The toast a localization row's Confirm raises once the server took the write. */ -function savedMessage( - row: ChecklistSettingsRow, - changes: Record, +/** The line under the basics row's title: the five values once done, else what the form holds. */ +function basicsDetail( + basics: OrganizationBasics, + name: string, labels: SettingsLabelHelpers, language: string, t: Translate, ): string { - if (row.id === 'timezone') return t('console.firstRunChecklist.timezone.saved', { zone: changes[TIMEZONE_KEY] }); - if (row.id === 'currency') { - const field = row.fields[0]; - return t('console.firstRunChecklist.currency.saved', { - currency: describeValue(field, changes[CURRENCY_KEY], labels, language), - }); - } - return t('console.firstRunChecklist.languageCountry.saved'); + if (!basics.done) return t('console.firstRunChecklist.organizationBasics.todo'); + const values = basics.fields.map((field) => describeValue(field, currentValue(field.resolved), labels, language)); + return [name, ...values].join(t('validation.formInvalidJoiner')); } type FieldErrors = Record; +/** The organization name's key in the form: not a settings key, never sent to the settings door. */ +const NAME_FIELD = 'organization_name'; + /** - * A localization row's editor: the Settings page's own field for each key, - * pre-filled with the current value of a set key or the browser's offer for an - * unset one, and Confirm / Cancel. + * The basics form: the organization's name and the Settings page's own field + * for each localization key, pre-filled with the current value of a set key or + * the browser's offer for an unset one; one Save and Cancel. */ -function SettingsRowEditor({ - row, +function OrganizationBasicsEditor({ + data, labels, - onSaved, - onCancel, + onDone, }: { - row: ChecklistSettingsRow; + data: FirstRunChecklistData; labels: SettingsLabelHelpers; - onSaved: (values: Record) => void; - onCancel: () => void; + onDone: () => void; }) { - const { t, language } = useObjectTranslation(); + const { t } = useObjectTranslation(); + const { updateOrganization } = useAuth(); + const basics = data.readings.basics; + const [name, setName] = useState(() => (basics.named ? data.organizationName : '')); const [drafts, setDrafts] = useState>(() => Object.fromEntries( - row.fields.map((field) => [field.key, field.set ? currentValue(field.resolved) : field.offer ?? '']), + basics.fields.map((field) => [field.key, field.set ? currentValue(field.resolved) : field.offer ?? '']), ), ); const [saving, setSaving] = useState(false); const [fieldErrors, setFieldErrors] = useState({}); - // The keys Confirm writes: a field holding a value that is not already the - // key's own. A cleared field is left as it is. + // The keys Save writes: a field holding a value that is not already the + // key's own. A field the server already holds that is cleared here is left + // as it is; one it holds no value for is required (`onSave`). const changes: Record = {}; - for (const field of row.fields) { + for (const field of basics.fields) { const draft = drafts[field.key] ?? ''; if (draft === '') continue; if (field.set && draft === currentValue(field.resolved)) continue; changes[field.key] = draft; } - const hasChanges = Object.keys(changes).length > 0; - const specifiers = row.fields.map((field) => field.spec); + const trimmed = name.trim(); + const renames = trimmed !== '' && trimmed !== data.organizationName.trim(); + const hasChanges = renames || Object.keys(changes).length > 0; + const specifiers = basics.fields.map((field) => field.spec); + const nameSpec: Specifier = { + type: 'text', + key: NAME_FIELD, + label: t('console.firstRunChecklist.organizationBasics.name'), + maxLength: 120, + }; - const onConfirm = async () => { - if (!hasChanges || saving) return; + const onSave = async () => { + if (saving) return; + // The row is done only with a name of the organization's own: the name the + // platform created it with does not count, so it is not accepted here. + // The row is done only once every setting holds a value too, so a field + // the server holds no value for and the browser offered none for (an + // `es-419` browser names no country, so no currency either) is required + // here like the name: Save never reports 「saved」 and closes while the + // row it was opened from stays undone. + const missing: FieldErrors = {}; + if (!isOrganizationNamed(trimmed)) { + missing[NAME_FIELD] = t('console.firstRunChecklist.organizationBasics.nameRequired'); + } + for (const field of basics.fields) { + if (!field.set && (drafts[field.key] ?? '') === '') missing[field.key] = t('form.fieldRequired'); + } + if (Object.keys(missing).length > 0) { + setFieldErrors(missing); + return; + } + if (!hasChanges) { + onDone(); + return; + } setSaving(true); setFieldErrors({}); try { - const res = await saveSettingsNamespace(LOCALIZATION_NAMESPACE, changes); - toast.success(savedMessage(row, changes, labels, language, t)); - onSaved(res.values); - } catch (err) { - // The Settings page's own reading of a refused save, for the keys this - // row writes. `api.ts` parks the raw error body on `err.payload`. - const failure = err as { message?: string; payload?: { error?: { code?: unknown } } } | undefined; - const apiError = failure?.payload?.error; - if (apiError?.code === 'SETTINGS_LOCKED') { - const key = lockedKeyOf(apiError); - toast.error( - key ? t('console.settingsView.lockedByEnv', { key }) : t('console.settingsView.lockedByEnvNoKey'), - ); - } else { - const refused: FieldErrors = {}; - const perField = settingsFieldRefusals(apiError, specifiers, fieldWording(labels), t); - for (const f of perField ?? []) { - if (row.fields.some((field) => field.key === f.field)) refused[f.field] = f.message; + if (renames) { + try { + await updateOrganization(data.orgId, { name: trimmed }); + } catch (err) { + const message = (err as { message?: string } | undefined)?.message; + setFieldErrors({ [NAME_FIELD]: message || t('console.settingsView.saveFailed') }); + toast.error(message || t('console.settingsView.saveFailed')); + return; + } + } + if (Object.keys(changes).length > 0) { + try { + const res = await saveSettingsNamespace(LOCALIZATION_NAMESPACE, changes); + data.localizationSaved(res.values); + } catch (err) { + // The Settings page's own reading of a refused save, for the keys + // this form writes. `api.ts` parks the raw error body on `err.payload`. + const failure = err as { message?: string; payload?: { error?: { code?: unknown } } } | undefined; + const apiError = failure?.payload?.error; + if (apiError?.code === 'SETTINGS_LOCKED') { + const key = lockedKeyOf(apiError); + toast.error( + key ? t('console.settingsView.lockedByEnv', { key }) : t('console.settingsView.lockedByEnvNoKey'), + ); + } else { + const refused: FieldErrors = {}; + const perField = settingsFieldRefusals(apiError, specifiers, fieldWording(labels), t); + for (const f of perField ?? []) { + if (basics.fields.some((field) => field.key === f.field)) refused[f.field] = f.message; + } + setFieldErrors(refused); + toast.error( + Object.keys(refused).length > 0 + ? t('console.settingsView.fieldErrorsToast', { + count: Object.keys(refused).length, + settings: basics.fields + .filter((field) => refused[field.key]) + .map((field) => labels.fieldLabel(field.key, resolveLabel(field.spec.label))) + .join(t('validation.formInvalidJoiner')), + }) + : failure?.message ?? t('console.settingsView.saveFailed'), + ); + } + return; } - setFieldErrors(refused); - toast.error( - Object.keys(refused).length > 0 - ? t('console.settingsView.fieldErrorsToast', { - count: Object.keys(refused).length, - settings: row.fields - .filter((field) => refused[field.key]) - .map((field) => labels.fieldLabel(field.key, resolveLabel(field.spec.label))) - .join(t('validation.formInvalidJoiner')), - }) - : failure?.message ?? t('console.settingsView.saveFailed'), - ); } + toast.success(t('console.firstRunChecklist.organizationBasics.saved')); + onDone(); } finally { setSaving(false); } }; return ( -
- {row.fields.map((field) => ( +
+ { + setName(next == null ? '' : String(next)); + setFieldErrors((prev) => ({ ...prev, [NAME_FIELD]: undefined })); + }} + saving={saving} + error={fieldErrors[NAME_FIELD]} + /> + {basics.fields.map((field) => ( ))} -

{t('console.firstRunChecklist.prefilled')}

+

{t('console.firstRunChecklist.organizationBasics.prefilled')}

- @@ -473,336 +403,139 @@ function SettingsRowEditor({ ); } -/** - * Where Home draws the checklist: app-shell's `HomeChecklistPlacement`, by - * value (see the module doc). - */ -export type FirstRunChecklistPlacement = 'top' | 'afterApps'; +/** Where the checklist is drawn; see the module doc. */ +export type FirstRunChecklistPlacement = 'top' | 'afterApps' | 'setupPage' | 'popover'; /** * One row as the checklist draws it: the full row (`node`), and what the * one-line form draws of it, its title and where its Set goes (a page to open, - * or the localization row to open for editing in the full card). + * or the basics form to open in the full card). */ -interface ChecklistDrawnRow { - id: string; - done: boolean; +interface ChecklistDrawnRow extends ChecklistRowState { title: string; - set?: { to: string } | { edit: ChecklistSettingsRow['id'] }; + set?: { to: string } | { edit: true }; node: ReactNode; } -export function FirstRunChecklist({ placement = 'top' }: { placement?: FirstRunChecklistPlacement } = {}) { +export function FirstRunChecklist({ + placement = 'top', + onClose, +}: { + placement?: FirstRunChecklistPlacement; + /** The popover's: called when the checklist is hidden from inside it. */ + onClose?: () => void; +} = {}) { const { t, language } = useObjectTranslation(); - const { user, activeOrganization, getMembers, listInvitations, getAuthConfig } = useAuth(); - const { systemPermissions } = usePermissions(); - const { apps } = useMetadata(); - const dataSource = useAdapter(); - // The apps the launcher offers this user: the `/meta/app` list narrowed by - // the console's one `/me/apps` read. "Put your first app in" reads it. - const launcher = useLauncherApps((apps ?? []) as Array>); + const data = useFirstRunChecklist(); const labels = useSettingsLabel(LOCALIZATION_NAMESPACE); const aiLabels = useSettingsLabel(AI_NAMESPACE); - const [editing, setEditing] = useState(null); - // Whether the rows that are done are drawn; folded on every visit. - const [showDone, setShowDone] = useState(false); - // A phone's card starts folded to one line; folded on every visit. - const foldable = placement === 'afterApps'; + const [editing, setEditing] = useState(false); + // Whether the rows that are done are drawn: the Setup page's full list draws + // them; elsewhere they are folded on every visit. + const [showDone, setShowDone] = useState(placement === 'setupPage'); + // A phone's card, and the Setup page's finished list, start folded to one line. const [unfolded, setUnfolded] = useState(false); - // The browser's answers are read once per mount: what the rows offer does not - // change under the administrator while they look at it. - const [browser] = useState(readBrowserAnswers); - - const userId = user?.id; - const orgId = activeOrganization?.id; - // Keyed on the capability LIST's content, never on the array's identity - // (AGENTS.md #10): a provider refetch that answers the same set must not - // re-run the reads. `null` keeps "not reported" apart from "holds nothing". - const heldKey = Array.isArray(systemPermissions) ? systemPermissions.join('\n') : null; - // Who is reading, where, holding what. Every answer below is stored with the - // identity it was read for, so an answer read for another one is never drawn. - const identity = userId && orgId && heldKey !== null ? [orgId, userId, heldKey].join('\u0000') : null; - const recordKey = userId && orgId ? dismissRecordKey(orgId, userId) : null; - - const [loaded, setLoaded] = useState<{ identity: string; settings: ChecklistSettingsState } | null>(null); - const [invited, setInvited] = useState<{ identity: string; colleagues: boolean } | null>(null); - // Hidden in this mount by the close button; a record from an earlier visit is - // read from the device below. - const [hiddenKey, setHiddenKey] = useState(null); - // The host's profile, from the served auth config (`firstRunChecklistProfile.ts`). - // `null` until the config answers: drawing the self-hosted rows first and - // the host's a moment later would move the list under the reader. - const [profile, setProfile] = useState(null); - // Whether a person created a record, read for one identity and object list. - const [firstRecord, setFirstRecord] = useState<{ key: string; created: boolean } | null>(null); - - useEffect(() => { - let cancelled = false; - // The auth client holds one config answer per signed-in stretch, which - // sign-in already read: this asks no new request. - Promise.resolve(getAuthConfig?.()) - .then((config) => { - if (!cancelled) setProfile(checklistProfileFor(config?.features)); - }) - .catch(() => { - // Unreadable: the checklist is what it is without a host. - if (!cancelled) setProfile(SELF_HOSTED_PROFILE); - }); - return () => { - cancelled = true; - }; - }, [getAuthConfig]); - useEffect(() => { - if (!identity || !userId || !orgId || heldKey === null) return; - if (wasDismissed(deviceStorage(), dismissRecordKey(orgId, userId))) return; - const held = heldKey === '' ? [] : heldKey.split('\n'); - - let cancelled = false; - whenBootPainted() - .then(() => (cancelled ? null : readChecklistSettings(held))) - .then((found) => { - if (cancelled || !found) return; - setLoaded({ identity, settings: found }); - // Only an administrator's checklist asks who else is here. - Promise.all([getMembers(orgId), listInvitations(orgId)]) - .then(([members, invitations]) => { - if (!cancelled) setInvited({ identity, colleagues: hasInvitedColleagues(members, invitations) }); - }) - .catch(() => { - // Members or invitations unreadable: the invite row is left out. - }); - }) - .catch(() => { - // A settings service that is absent or failing shows no checklist. - }); - return () => { - cancelled = true; - }; - // `getMembers` / `listInvitations` are the provider's stable callbacks; - // the reads re-run on who is signed in, where, and what they may do, all - // of which `identity` carries. - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [identity]); - - const settings = loaded && loaded.identity === identity ? loaded.settings : null; - const colleagues = invited && invited.identity === identity ? invited.colleagues : undefined; - const dismissed = - recordKey !== null && (hiddenKey === recordKey || wasDismissed(deviceStorage(), recordKey)); - // Connect an AI Assistant: the row reads whether this administrator has - // connected one only once the checklist is going to draw. - const assistantPath = connectAssistantPath(apps); - const assistant = useConnectedAccess({ enabled: Boolean(settings && !dismissed && assistantPath) }); // One Home card per item (app-shell's `homeItemClaims`): this checklist's - // assistant row, while it is open, outranks Home's Connect an AI Assistant card. + // assistant row, while it is open on Home, outranks Home's Connect an AI + // Assistant card. + const homeCard = placement === 'top' || placement === 'afterApps'; + const assistant = data?.readings.assistant; const drawsAssistantRow = Boolean( - settings && !dismissed && orgId && userId && recordKey && assistantPath && - assistant.state === 'ready' && !assistant.connected, + homeCard && data && !data.dismissed && !data.completion.complete && assistant && !assistant.connected, ); useHomeItemClaim('connect_assistant', drawsAssistantRow); - // Add your first record: read once the checklist is going to draw, the - // profile adds the row and the launcher has answered, for the objects the - // environment's own apps list. Keyed on that list's content, never on the - // array's identity (AGENTS.md #10). - const own = ownApps(launcher.apps); - const recordObjects = appObjectNames(own); - const firstRecordKey = - settings && !dismissed && identity && profile?.addedRows.includes('first_record') && !launcher.pending && dataSource - ? [identity, recordObjects.join(',')].join('\u0001') - : null; - useEffect(() => { - if (!firstRecordKey || !dataSource) return; - let cancelled = false; - readFirstRecordCreated(dataSource as unknown as FirstRecordSource, recordObjects) - .then((created) => { - if (!cancelled) setFirstRecord({ key: firstRecordKey, created }); - }) - .catch(() => { - // Unreadable (no activity feed, or a refused read): the row is left out. - }); - return () => { - cancelled = true; - }; - // `recordObjects` and `dataSource` are carried by the key's content. - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [firstRecordKey]); - const recordCreated = firstRecord && firstRecord.key === firstRecordKey ? firstRecord.created : undefined; - const setSettings = (update: (prev: ChecklistSettingsState) => ChecklistSettingsState) => - setLoaded((prev) => (prev ? { identity: prev.identity, settings: update(prev.settings) } : prev)); - - if (!settings || !profile || dismissed || !orgId || !userId || !recordKey) return null; - const optionalRow = (id: string) => isProfileOptionalRow(profile, id); - - const setupPath = resolveSetupAppPath(apps); - const localization = localizationRows(settings.localization.manifest, settings.localization.values, browser); - const organizationNamed = isOrganizationNamed(activeOrganization?.name); - - const rows: ChecklistDrawnRow[] = []; + // A row finished elsewhere closes the form here. + const basicsDone = data?.readings.basics.done ?? false; + useEffect(() => { + if (basicsDone) setEditing(false); + }, [basicsDone]); - const organizationPath = `${setupPath}/sys_organization/record/${encodeURIComponent(orgId)}`; - rows.push({ - id: 'organization_name', - done: organizationNamed, - title: t('console.firstRunChecklist.organizationName.title'), - set: { to: organizationPath }, - node: ( - - } - /> - ), - }); + if (!data) return null; + if (homeCard && (data.dismissed || data.completion.complete)) return null; + const { readings, setupPath, completion } = data; - for (const row of localization) { - const open = editing === row.id; - rows.push({ - id: row.id, - done: row.done, - title: settingsRowTitle(row, t), - set: { edit: row.id }, - node: ( - - ) : open ? null : ( + const rows: ChecklistDrawnRow[] = data.rows.map((state) => { + const { id, done, optional } = state; + const row = (title: string, props: { detail?: string; action?: ReactNode; children?: ReactNode }) => ( + + ); + switch (id) { + case 'organization_basics': { + const title = t('console.firstRunChecklist.organizationBasics.title'); + return { + ...state, + title, + set: { edit: true }, + node: row(title, { + detail: basicsDetail(readings.basics, data.organizationName, labels, language, t), + action: editing ? null : ( - ) - } - > - {open && !row.done ? ( - setEditing(null)} - onSaved={(values) => { - setEditing(null); - setSettings((prev) => ({ - ...prev, - localization: { ...prev.localization, values: { ...prev.localization.values, ...values } }, - })); - // The write's read-back is merged at once; the namespace is - // then read again, as the Settings page does after a save, so - // every row shows what the server now resolves. - getSettingsNamespace(LOCALIZATION_NAMESPACE) - .then((fresh) => { - setSettings((prev) => ({ ...prev, localization: { manifest: fresh.manifest, values: fresh.values } })); - }) - .catch(() => { - // Keep what is on screen; the next visit reads again. - }); - }} - /> - ) : null} - - ), - }); - } - - if (settings.mail) { - const done = settings.mail.done; - rows.push({ - id: 'mail', - done, - title: t('console.firstRunChecklist.mail.title'), - set: { to: `${setupPath}/system/settings/mail` }, - node: ( - - } - /> - ), - }); - } - - if (colleagues !== undefined) { - rows.push({ - id: 'invite', - done: colleagues, - title: t('console.firstRunChecklist.invite.title'), - set: { to: `${setupPath}/sys_user/view/all_users` }, - node: ( - - } - /> - ), - }); - } - - if (settings.ai) { - const ai = settings.ai; - const provider = ai.value ? aiLabels.optionLabel(AI_PROVIDER_KEY, ai.value, ai.optionLabel ?? ai.value) : ''; - rows.push({ - id: 'ai_provider', - done: ai.done, - title: t('console.firstRunChecklist.aiProvider.title'), - set: { to: `${setupPath}/system/settings/${AI_NAMESPACE}` }, - node: ( - setEditing(false)} /> + ) : null, + }), + }; + } + case 'mail': { + const title = t('console.firstRunChecklist.mail.title'); + const to = `${setupPath}/system/settings/mail`; + return { + ...state, + title, + set: { to }, + node: row(title, { + detail: done ? t('console.firstRunChecklist.mail.done') : t('console.firstRunChecklist.mail.todo'), + action: ( + + ), + }), + }; + } + case 'invite': { + const title = t('console.firstRunChecklist.invite.title'); + const to = `${setupPath}/sys_user/view/all_users`; + return { + ...state, + title, + set: { to }, + node: row(title, { + detail: done ? t('console.firstRunChecklist.invite.done') : t('console.firstRunChecklist.invite.todo'), + action: ( + + ), + }), + }; + } + case 'ai_provider': { + const ai = readings.ai!; + const provider = ai.value ? aiLabels.optionLabel(AI_PROVIDER_KEY, ai.value, ai.optionLabel ?? ai.value) : ''; + const title = t('console.firstRunChecklist.aiProvider.title'); + const to = `${setupPath}/system/settings/${AI_NAMESPACE}`; + return { + ...state, + title, + set: { to }, + node: row(title, { + detail: !ai.done ? t('console.firstRunChecklist.aiProvider.todo') : ai.source === 'environment' ? provider @@ -810,135 +543,119 @@ export function FirstRunChecklist({ placement = 'top' }: { placement?: FirstRunC : // In use, handed over by the host, and named by no option: // there is no provider name to put in the sentence. t('console.settingsView.aiProviderManaged') - : t('console.firstRunChecklist.aiProvider.doneSettings', { provider }) - } - action={ - - } - /> - ), - }); - } - - if (assistantPath && assistant.state === 'ready') { - const done = assistant.connected; - rows.push({ - id: 'connect_assistant', - done, - title: t('console.firstRunChecklist.connectAssistant.title'), - set: { to: assistantPath }, - node: ( - + ), + }), + }; + } + case 'connect_assistant': { + const title = t('console.firstRunChecklist.connectAssistant.title'); + const to = assistant!.path; + return { + ...state, + title, + set: { to }, + node: row(title, { + detail: done ? t('console.firstRunChecklist.connectAssistant.done') - : t('console.firstRunChecklist.connectAssistant.todo') - } - action={ - - } - /> - ), - }); - } - - for (const added of profile.addedRows) { - if (added === 'first_app' && !launcher.pending) { - const done = hasOwnApp(launcher.apps); - rows.push({ - id: 'first_app', - done, - title: t('console.firstRunChecklist.firstApp.title'), - node: ( - - ), - }); - } - if (added === 'first_record' && recordCreated !== undefined) { - const done = recordCreated; - const firstOwn = own[0]; - rows.push({ - id: 'first_record', - done, - title: t('console.firstRunChecklist.firstRecord.title'), - set: firstOwn ? { to: `/apps/${appRouteSegment(firstOwn)}` } : undefined, - node: ( - - ) : undefined - } - /> - ), - }); + : t('console.firstRunChecklist.connectAssistant.todo'), + action: ( + + ), + }), + }; + } + case 'first_app': { + const title = t('console.firstRunChecklist.firstApp.title'); + return { + ...state, + title, + node: row(title, { + detail: done ? t('console.firstRunChecklist.firstApp.done') : t('console.firstRunChecklist.firstApp.todo'), + }), + }; + } + default: { + // `first_record`, the last row a profile adds. + const title = t('console.firstRunChecklist.firstRecord.title'); + const firstOwn = data.ownApps[0]; + const to = firstOwn ? `/apps/${appRouteSegment(firstOwn)}` : undefined; + return { + ...state, + title, + set: to ? { to } : undefined, + node: row(title, { + detail: done ? t('console.firstRunChecklist.firstRecord.done') : t('console.firstRunChecklist.firstRecord.todo'), + action: to ? ( + + ) : undefined, + }), + }; + } } - } + }); - // The host hides the rows that do not apply to it while they read not done. - const drawn = rows.filter((row) => profileDrawsRow(profile, row.id, row.done)); - // Done rows are folded away, the optional ones included; only the required - // ones decide whether the checklist is still drawn and what its progress says. - // The control that unfolds them names the required and the optional apart, - // so its count never reads larger than the progress line's. - const doneCount = checklistDoneCount(drawn, optionalRow); - const completion = checklistCompletion(drawn, optionalRow); - if (completion.complete) return null; + const doneCount = completion.done; + const progress = t('console.firstRunChecklist.progress', { done: completion.done, total: completion.total }); const hide = () => { - markDismissed(deviceStorage(), recordKey); - setHiddenKey(recordKey); + data.hide(); + onClose?.(); }; + // Home's card: the X hides the checklist on this device (the pill too). + // In the popover the X only closes it, as a popover's X does; hiding there + // is its own labelled action under the list, so a press meant to close the + // popover never hides the pill for good. + const dismissButton = + placement === 'setupPage' ? null : placement === 'popover' ? ( + + ) : ( + + ); - const progress = t('console.firstRunChecklist.progress', { done: completion.done, total: completion.total }); - - const dismissButton = ( - + const titleLine = ( +

+ + {t('console.firstRunChecklist.title')} + + + {progress} + +

); - // Above the page, with few rows left and none open for editing: one line, - // each row left by its title and its Set. A localization row's Set opens the - // full card with that row's editor; the others open their page. - if (!foldable && editing === null && drawsOneLine(drawn)) { + // Above Home's page, with few rows left and none open for editing: one line, + // each row left by its title and its Set. The basics row's Set opens the + // full card with its form; the others open their page. + if (placement === 'top' && !editing && drawsOneLine(rows)) { return (
-

- - {t('console.firstRunChecklist.title')} - - - {progress} - -

+ {titleLine}
    - {drawn + {rows .filter((row) => !row.done) - .map(({ id, title, set }) => ( + .map(({ id, title, set, optional }) => (
  • {title} - {optionalRow(id) ? ( + {optional ? ( setEditing(set.edit)} + onClick={() => setEditing(true)} data-testid={`first-run-checklist-set-${id}`} > {t('console.firstRunChecklist.set')} @@ -1002,22 +712,21 @@ export function FirstRunChecklist({ placement = 'top' }: { placement?: FirstRunC ); } + // A phone's card, and the Setup page's list once its required rows are + // done, start folded to one line; the line's button opens the list in place. + const foldable = placement === 'afterApps' || (placement === 'setupPage' && completion.complete); if (foldable && !unfolded) { - return ( + const line = (
    -

    - - {t('console.firstRunChecklist.title')} - - - {progress} - -

    + {titleLine}
    ); + return placement === 'setupPage' ?
    {line}
    : line; } + const popover = placement === 'popover'; const card = (
    @@ -1072,10 +784,11 @@ export function FirstRunChecklist({ placement = 'top' }: { placement?: FirstRunC
    - {drawn.filter((row) => showDone || !row.done).map((row) => row.node)} + {rows.filter((row) => showDone || !row.done).map((row) => row.node)}
- {doneCount.required + doneCount.optional > 0 ? ( -
+ {doneCount > 0 || popover ? ( +
+ {doneCount > 0 ? ( + ) : ( + + )} + {popover ? ( + + ) : null}
) : null} ); - // In the content column (a phone's placement) the column gives the width - // and the gutters; above the page the card brings its own. - return foldable ? card :
{card}
; + // In the content column (a phone's placement) and in the popover the host + // gives the width and the gutters; above a page the card brings its own. + return placement === 'afterApps' || popover ? card :
{card}
; } diff --git a/ui/apps/console/src/pages/settings/FirstRunChecklistPill.tsx b/ui/apps/console/src/pages/settings/FirstRunChecklistPill.tsx new file mode 100644 index 00000000000..f16b0cdece3 --- /dev/null +++ b/ui/apps/console/src/pages/settings/FirstRunChecklistPill.tsx @@ -0,0 +1,103 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +/** + * — 「Get started n/m」 at the bottom of the sidebar + * (objectstack#36739, after Attio's 「Getting started 2/6」), drawn into + * app-shell's `SidebarFooterSlotProvider` by the console's permissions scope, + * so it is in every app. + * + * - Only for the administrator the checklist is for (`useFirstRunChecklist` + * answers `null` for anyone else, a member included). + * - It reads the rows done of the rows drawn, optional ones included, and + * stands aside once the REQUIRED rows are done (`completion.complete`), or + * once this administrator hid the checklist on this device. + * - A press opens the checklist in place, in a popover beside the pill; a row's + * link closes it as the page it opens loads. + * - From 768 px up it sits in the sidebar's footer; while the sidebar is folded + * to its icon rail it keeps only its icon, the count staying in its + * accessible name and tooltip. On a phone, which has no + * resident sidebar, it sits after the app's menu on the app's home page. + * + * @module + */ + +import { useState } from 'react'; +import { useLocation } from 'react-router-dom'; +import { ListChecks } from 'lucide-react'; +import { Popover, PopoverContent, PopoverTrigger, cn } from '@object-ui/components'; +import type { SidebarFooterSlotPlace } from '@object-ui/app-shell'; +import { useObjectTranslation } from '@object-ui/i18n'; +import { FirstRunChecklist } from './FirstRunChecklist'; +import { useFirstRunChecklist } from './firstRunChecklistState'; + +export function FirstRunChecklistPill({ where }: { where: SidebarFooterSlotPlace }) { + const { t } = useObjectTranslation(); + const data = useFirstRunChecklist(); + const location = useLocation(); + // The popover is open on the page it was opened on. A row's link that opens + // another page closes it for good: the record is cleared while rendering + // the new page (no effect to run), so coming Back to the page it was opened + // on does not open it again by itself. + const here = `${location.pathname}${location.search}`; + const [openOn, setOpenOn] = useState(null); + if (openOn !== null && openOn !== here) setOpenOn(null); + const open = openOn === here; + const setOpen = (next: boolean) => setOpenOn(next ? here : null); + + if (!data || data.dismissed || data.completion.complete) return null; + const { done, total } = data.completion; + const label = t('console.firstRunChecklist.pill.label'); + const count = t('console.firstRunChecklist.pill.count', { done, total }); + const phone = where === 'phoneAppHome'; + + // On a phone the pill is the app home's last row, and the page's own end + // padding does not scroll out from under the bottom bar there (the route + // slot is `h-full` and the page overflows it), so the slot keeps the bar's + // height (3.5 rem plus the safe area, as `ConsoleLayout` sizes it) free + // below the pill itself. + return ( +
+ + + + + + setOpen(false)} /> + + +
+ ); +} diff --git a/ui/apps/console/src/pages/settings/__tests__/FirstRunChecklist.test.tsx b/ui/apps/console/src/pages/settings/__tests__/FirstRunChecklist.test.tsx index 89c8c16fbf0..4831f8c4113 100644 --- a/ui/apps/console/src/pages/settings/__tests__/FirstRunChecklist.test.tsx +++ b/ui/apps/console/src/pages/settings/__tests__/FirstRunChecklist.test.tsx @@ -1,8 +1,10 @@ // Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. /** - * The administrator's first-run checklist on Home (objectstack#30206), which - * replaces the dialog that asked for the workspace timezone and currency. + * The administrator's first-run checklist (objectstack#30206), which replaces + * the dialog that asked for the workspace timezone and currency, and since + * objectstack#36739 carries one required form (the organization's basics), the + * other platform rows optional, and a sidebar 「Get started n/m」 pill. * * The two rules the dialog's rulings set still hold, and are pinned here on the * wire: the browser's answers only PRE-FILL a row, and nothing is written until @@ -19,7 +21,7 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'; -import { MemoryRouter, Route, Routes } from 'react-router-dom'; +import { MemoryRouter, Route, Routes, useNavigate } from 'react-router-dom'; import { I18nProvider } from '@object-ui/i18n'; import { MePermissionsProvider, @@ -38,6 +40,8 @@ const { AUTH, toastError, toastSuccess, SHELL } = vi.hoisted(() => ({ listInvitations: vi.fn(), // The served auth config: its `features.cloudManaged` selects the host profile. getAuthConfig: vi.fn(), + // The organization rename the basics form's Save sends with the settings write. + updateOrganization: vi.fn(), }, toastError: vi.fn(), toastSuccess: vi.fn(), @@ -63,6 +67,8 @@ vi.mock('@object-ui/react', async (importOriginal) => ({ import { useHomeItemClaimed, type HomeItem } from '@object-ui/app-shell'; import { FirstRunChecklist, type FirstRunChecklistPlacement } from '../FirstRunChecklist'; +import { FirstRunChecklistPill } from '../FirstRunChecklistPill'; +import { FirstRunChecklistProvider } from '../firstRunChecklistState'; import { __resetBootPainted } from '../../../loadLocales'; import type { Specifier } from '../types'; import { builtInLocales } from '@object-ui/i18n/locales'; @@ -220,7 +226,31 @@ function renderChecklist( - + + + + + + , + ); +} + +/** The browser's Back, as a button the test presses. */ +function BackButton() { + const navigate = useNavigate(); + return