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
16 changes: 16 additions & 0 deletions .changeset/34596-phone-home-checklist-top-bar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
'@object-ui/app-shell': patch
'@object-ui/console': patch
'@object-ui/i18n': patch
---

feat(console): on a phone, Home keeps its first screen for the apps, and the top bar's badge and title fit

Clause-②: yes (widening)
Metadata-protocol: none

**Home's setup checklist.** Below 768 px, Home draws the administrator's first-run checklist after the apps instead of above the greeting, folded to one line: its title, its progress ("2 of 5 done") and **Continue**. Continue opens the whole card in place; a fold control beside the progress closes it to one line again. A fresh visit starts folded. The rows, the progress count, the done rule and the close button are unchanged, and from 768 px up the card is drawn above the page as before. With no app yet the card stays above the empty state at every width.

`HomePage` (`@object-ui/app-shell`) takes an optional `checklist(placement)` slot: Home calls it with `'top'` on a desktop or with no app, and with `'afterApps'` on a phone, and draws what it returns there. The console's Home route passes the first-run checklist through it. `@object-ui/i18n` adds `console.firstRunChecklist.continue` to every pack.

**The phone top bar.** Below 768 px the bell's unread badge ("9+") sits inside the bell's 44 px target, on the glyph's corner, instead of 2 px above it, where the bar's top edge cut it. Below 640 px the bar's control groups draw no divider and no extra gap, and the page title beside the app pill takes no margin of its own, so the title keeps that width. The controls the bar shows are unchanged: search, the bell, the AI assistant (where the server serves AI) and the account menu.
19 changes: 12 additions & 7 deletions ui/apps/console/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import {
} from '@object-ui/app-shell';

import { AppContent, ConsolePermissionsRequest, ConsolePermissionsScope } from './AppContent';
import { FirstRunChecklist } from './pages/settings/FirstRunChecklist';
import { FirstRunChecklist, type FirstRunChecklistPlacement } from './pages/settings/FirstRunChecklist';
import { publishAuthState } from './i18nSession';
import { FaviconSync } from './components/FaviconSync';
import { RootLandingRedirect } from './components/RootLandingRedirect';
Expand Down Expand Up @@ -191,19 +191,24 @@ function NativeShellRouting() {
return null;
}

/** Home's checklist slot: the first-run checklist, where Home places it. */
function homeChecklist(placement: FirstRunChecklistPlacement) {
return <FirstRunChecklist placement={placement} />;
}

/**
* Wraps `DefaultHomeLayout` so the FAB gets the signed-in user id, and draws
* an administrator's first-run checklist above the page's own sections
* (objectstack#30206). The route sits under `ConsolePermissionsScope`, which
* is what tells the checklist whether this session may write the settings it
* lists; for anyone else it draws nothing.
* an administrator's first-run checklist in Home's checklist slot
* (objectstack#30206): above the page's own sections on a desktop, after the
* apps on a phone (objectstack#34596). The route sits under
* `ConsolePermissionsScope`, which is what tells the checklist whether this
* session may write the settings it lists; for anyone else it draws nothing.
*/
function HomeRoute() {
const { user } = useAuth();
return (
<DefaultHomeLayout userId={user?.id}>
<FirstRunChecklist />
<DefaultHomePage />
<DefaultHomePage checklist={homeChecklist} />
</DefaultHomeLayout>
);
}
Expand Down
172 changes: 122 additions & 50 deletions ui/apps/console/src/pages/settings/FirstRunChecklist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,23 @@
*
* ## Where it is drawn
*
* Home (`/home`), above the page's own sections. Home is the environment's own
* home (ObjectUI ADR-0075): every deployment that declares no landing app opens
* Home (`/home`), in the slot Home's page gives its host's checklist
* (app-shell's `HomePage`, `checklist`). Home is the environment's own home
* (ObjectUI ADR-0075): every deployment that declares no landing app opens
* there after sign-in, the Setup-only one included (`RootLandingRedirect`).
* Mounted by the console's Home route (`App.tsx`), inside the
* `ConsolePermissionsScope` that route already sits under: that provider is
* what answers which capabilities this session holds.
*
* 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.
*
* ## Who sees it, and what each row says
*
* An administrator: a session that may write `localization`
Expand Down Expand Up @@ -110,7 +120,7 @@
import { useEffect, useState, type ReactNode } from 'react';
import { Link } from 'react-router-dom';
import { toast } from 'sonner';
import { CheckCircle2, ChevronDown, ChevronUp, Circle, Loader2, X } from 'lucide-react';
import { CheckCircle2, ChevronDown, ChevronRight, ChevronUp, Circle, Loader2, X } from 'lucide-react';
import { Button, cn } from '@object-ui/components';
import {
appRouteSegment,
Expand Down Expand Up @@ -444,7 +454,13 @@ function SettingsRowEditor({
);
}

export function FirstRunChecklist() {
/**
* Where Home draws the checklist: app-shell's `HomeChecklistPlacement`, by
* value (see the module doc).
*/
export type FirstRunChecklistPlacement = 'top' | 'afterApps';

export function FirstRunChecklist({ placement = 'top' }: { placement?: FirstRunChecklistPlacement } = {}) {
const { t, language } = useObjectTranslation();
const { user, activeOrganization, getMembers, listInvitations, getAuthConfig } = useAuth();
const { systemPermissions } = usePermissions();
Expand All @@ -459,6 +475,9 @@ export function FirstRunChecklist() {
const [editing, setEditing] = useState<ChecklistSettingsRow['id'] | null>(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 [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);
Expand Down Expand Up @@ -847,61 +866,114 @@ export function FirstRunChecklist() {
setHiddenKey(recordKey);
};

return (
<div className="px-4 pt-4 sm:px-6 lg:px-8">
const progress = t('console.firstRunChecklist.progress', { done: completion.done, total: completion.total });

if (foldable && !unfolded) {
return (
<section
className="mx-auto max-w-[1120px] rounded-xl border border-border bg-card px-5 pt-4 pb-1"
className="flex items-center justify-between gap-2 rounded-xl border border-border bg-card py-2 pl-4 pr-1.5"
data-testid="first-run-checklist"
data-folded="true"
aria-labelledby="first-run-checklist-title"
>
<div className="flex items-start justify-between gap-4">
<div className="min-w-0">
<h2 id="first-run-checklist-title" className="text-base font-semibold tracking-tight">
{t('console.firstRunChecklist.title')}
</h2>
<p className="mt-1 text-[13px] text-muted-foreground">{t('console.firstRunChecklist.description')}</p>
</div>
<div className="flex shrink-0 items-center gap-2">
<span className="text-xs text-muted-foreground" data-testid="first-run-checklist-progress">
{t('console.firstRunChecklist.progress', { done: completion.done, total: completion.total })}
</span>
<button
type="button"
onClick={hide}
aria-label={t('console.firstRunChecklist.dismiss')}
title={t('console.firstRunChecklist.dismiss')}
className="rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-foreground"
data-testid="first-run-checklist-dismiss"
>
<X className="h-4 w-4" />
</button>
</div>
<p className="flex min-w-0 items-baseline gap-2">
<span id="first-run-checklist-title" className="truncate text-[13px] font-semibold tracking-tight">
{t('console.firstRunChecklist.title')}
</span>
<span className="shrink-0 text-xs text-muted-foreground" data-testid="first-run-checklist-progress">
{progress}
</span>
</p>
<Button
size="sm"
variant="ghost"
className="shrink-0 gap-0.5 px-1.5 text-primary"
onClick={() => setUnfolded(true)}
aria-expanded={false}
data-testid="first-run-checklist-continue"
>
{t('console.firstRunChecklist.continue')}
<ChevronRight className="h-4 w-4" aria-hidden />
</Button>
</section>
);
}

const card = (
<section
className={cn(
'rounded-xl border border-border bg-card px-5 pt-4 pb-1',
!foldable && 'mx-auto max-w-[1120px]',
)}
data-testid="first-run-checklist"
data-folded={foldable ? 'false' : undefined}
aria-labelledby="first-run-checklist-title"
>
<div className="flex items-start justify-between gap-4">
<div className="min-w-0">
<h2 id="first-run-checklist-title" className="text-base font-semibold tracking-tight">
{t('console.firstRunChecklist.title')}
</h2>
<p className="mt-1 text-[13px] text-muted-foreground">{t('console.firstRunChecklist.description')}</p>
</div>
<ol className="mt-2 divide-y divide-border" id="first-run-checklist-rows">
{drawn.filter((row) => showDone || !row.done).map((row) => row.node)}
</ol>
{doneCount > 0 ? (
<div className="border-t border-border py-2">
<div className="flex shrink-0 items-center gap-2">
<span className="text-xs text-muted-foreground" data-testid="first-run-checklist-progress">
{progress}
</span>
{foldable ? (
<button
type="button"
onClick={() => setShowDone((shown) => !shown)}
aria-expanded={showDone}
onClick={() => setUnfolded(false)}
aria-expanded
aria-controls="first-run-checklist-rows"
className="inline-flex items-center gap-1 rounded-md px-1 py-0.5 text-xs text-muted-foreground hover:bg-accent hover:text-foreground"
data-testid="first-run-checklist-toggle-done"
aria-label={t('common.collapse')}
title={t('common.collapse')}
className="rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-foreground"
data-testid="first-run-checklist-fold"
>
{showDone ? (
<ChevronUp className="h-3.5 w-3.5" aria-hidden />
) : (
<ChevronDown className="h-3.5 w-3.5" aria-hidden />
)}
{showDone
? t('console.firstRunChecklist.hideDone')
: t('console.firstRunChecklist.showDone', { done: doneCount })}
<ChevronUp className="h-4 w-4" aria-hidden />
</button>
</div>
) : null}
</section>
</div>
) : null}
<button
type="button"
onClick={hide}
aria-label={t('console.firstRunChecklist.dismiss')}
title={t('console.firstRunChecklist.dismiss')}
className="rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-foreground"
data-testid="first-run-checklist-dismiss"
>
<X className="h-4 w-4" />
</button>
</div>
</div>
<ol className="mt-2 divide-y divide-border" id="first-run-checklist-rows">
{drawn.filter((row) => showDone || !row.done).map((row) => row.node)}
</ol>
{doneCount > 0 ? (
<div className="border-t border-border py-2">
<button
type="button"
onClick={() => setShowDone((shown) => !shown)}
aria-expanded={showDone}
aria-controls="first-run-checklist-rows"
className="inline-flex items-center gap-1 rounded-md px-1 py-0.5 text-xs text-muted-foreground hover:bg-accent hover:text-foreground"
data-testid="first-run-checklist-toggle-done"
>
{showDone ? (
<ChevronUp className="h-3.5 w-3.5" aria-hidden />
) : (
<ChevronDown className="h-3.5 w-3.5" aria-hidden />
)}
{showDone
? t('console.firstRunChecklist.hideDone')
: t('console.firstRunChecklist.showDone', { done: doneCount })}
</button>
</div>
) : null}
</section>
);

// 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 : <div className="px-4 pt-4 sm:px-6 lg:px-8">{card}</div>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ vi.mock('@object-ui/react', async (importOriginal) => ({
}));

import { useHomeItemClaimed, type HomeItem } from '@object-ui/app-shell';
import { FirstRunChecklist } from '../FirstRunChecklist';
import { FirstRunChecklist, type FirstRunChecklistPlacement } from '../FirstRunChecklist';
import { __resetBootPainted } from '../../../loadLocales';
import type { Specifier } from '../types';

Expand Down Expand Up @@ -205,12 +205,16 @@ const ADMIN = ['setup.access', 'setup.write', 'manage_platform_settings'];
const MEMBER = ['setup.access'];

/** No default for `systemPermissions`: "not reported" must stay apart from the admin set. */
function renderChecklist(systemPermissions: string[] | undefined, language = 'en') {
function renderChecklist(
systemPermissions: string[] | undefined,
language = 'en',
placement?: FirstRunChecklistPlacement,
) {
return render(
<MemoryRouter>
<I18nProvider config={{ defaultLanguage: language, detectBrowserLanguage: false }}>
<MePermissionsProvider initialPermissions={permissionsPayload(systemPermissions)}>
<FirstRunChecklist />
<FirstRunChecklist placement={placement} />
</MePermissionsProvider>
</I18nProvider>
</MemoryRouter>,
Expand Down Expand Up @@ -1041,3 +1045,72 @@ describe('the host profile: a managed environment adds the first-app and first-r
expect(within(await screen.findByTestId('first-run-checklist-row-first_record')).getByText('添加第一条记录')).toBeTruthy();
});
});

describe('on a phone, after the apps, the card starts folded to one line (objectstack#34596)', () => {
const card = () => screen.getByTestId('first-run-checklist');
const progress = () => screen.getByTestId('first-run-checklist-progress').textContent;

it('one line: the title, the progress and Continue; no row is drawn and nothing is written', async () => {
renderChecklist(ADMIN, 'en', 'afterApps');
await waitFor(() => expect(progress()).toBe('0 of 5 done'));
expect(card().getAttribute('data-folded')).toBe('true');
expect(within(card()).getByText('Get your system ready')).toBeTruthy();
expect(within(card()).queryAllByRole('listitem')).toHaveLength(0);
const go = screen.getByTestId('first-run-checklist-continue');
expect(go.textContent).toBe('Continue');
expect(go.getAttribute('aria-expanded')).toBe('false');
expect(screen.queryByTestId('first-run-checklist-dismiss')).toBeNull();
expect(puts()).toHaveLength(0);
});

it('Continue opens the card in place with every row; the fold control closes it to one line again', async () => {
renderChecklist(ADMIN, 'en', 'afterApps');
fireEvent.click(await screen.findByTestId('first-run-checklist-continue'));
expect(card().getAttribute('data-folded')).toBe('false');
expect(await screen.findByTestId('first-run-checklist-row-invite')).toBeTruthy();
const fold = screen.getByTestId('first-run-checklist-fold');
expect(fold.getAttribute('aria-expanded')).toBe('true');
expect(fold.getAttribute('aria-controls')).toBe(screen.getByRole('list').id);
expect(screen.getByTestId('first-run-checklist-dismiss')).toBeTruthy();
expect(progress()).toBe('0 of 5 done');

fireEvent.click(fold);
expect(card().getAttribute('data-folded')).toBe('true');
expect(screen.queryByTestId('first-run-checklist-row-invite')).toBeNull();
expect(progress()).toBe('0 of 5 done');
});

it('folding changes no completion rule: the folded line counts what the card counts, and a set workspace draws nothing', async () => {
localizationValues = {
locale: resolved('zh-CN', 'tenant'),
default_country: resolved('CN', 'tenant'),
timezone: resolved('Asia/Shanghai', 'tenant'),
currency: resolved('CNY', 'tenant'),
};
renderChecklist(ADMIN, 'en', 'afterApps');
await waitFor(() => expect(progress()).toBe('3 of 5 done'));
cleanup();

AUTH.activeOrganization = { id: 'org_1', name: 'Acme' };
AUTH.getMembers.mockResolvedValue([{ id: 'm_1' }, { id: 'm_2' }]);
mailValues = { provider: resolved('smtp', 'global'), smtp_host: resolved('mx', 'global'), from_email: resolved('a@b.co', 'global') };
renderChecklist(ADMIN, 'en', 'afterApps');
await settle();
await waitFor(() => expect(AUTH.getMembers).toHaveBeenCalled());
await settle();
expect(screen.queryByTestId('first-run-checklist')).toBeNull();
});

it('zh: Continue reads in the reader language', async () => {
renderChecklist(ADMIN, 'zh', 'afterApps');
expect((await screen.findByTestId('first-run-checklist-continue')).textContent).toBe('继续');
});

it('CONTROL: above the page the card is drawn whole, with no Continue and no fold control', async () => {
renderChecklist(ADMIN, 'en', 'top');
expect(await screen.findByTestId('first-run-checklist-row-invite')).toBeTruthy();
expect(card().getAttribute('data-folded')).toBeNull();
expect(screen.queryByTestId('first-run-checklist-continue')).toBeNull();
expect(screen.queryByTestId('first-run-checklist-fold')).toBeNull();
});
});
Loading
Loading