@gntik-ai/templates 0.12.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gntik-ai/templates",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "description": "gntik-ui page templates: complete product pages (auth, dashboard, resources, settings, system) on the kit layouts and blocks.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -35,14 +35,14 @@
35
35
  "react-dom": "^19.0.0"
36
36
  },
37
37
  "dependencies": {
38
- "@gntik-ai/blocks": "0.12.0",
39
- "@gntik-ai/charts": "0.12.0",
40
- "@gntik-ai/chat": "0.12.0",
41
- "@gntik-ai/editor": "0.12.0",
42
- "@gntik-ai/flow": "0.12.0",
38
+ "@gntik-ai/blocks": "0.14.0",
39
+ "@gntik-ai/charts": "0.14.0",
40
+ "@gntik-ai/chat": "0.14.0",
41
+ "@gntik-ai/editor": "0.14.0",
42
+ "@gntik-ai/flow": "0.14.0",
43
43
  "@gntik-ai/icons": "0.5.0",
44
- "@gntik-ai/tokens": "0.4.0",
45
- "@gntik-ai/ui": "0.12.0",
44
+ "@gntik-ai/tokens": "0.5.0",
45
+ "@gntik-ai/ui": "0.14.0",
46
46
  "lucide-react": "^1.48.0"
47
47
  },
48
48
  "devDependencies": {
@@ -13,6 +13,7 @@ import {
13
13
  FieldError,
14
14
  FieldLabel,
15
15
  OtpInput,
16
+ QrCode,
16
17
  useI18n,
17
18
  } from '@gntik-ai/ui';
18
19
  import { useState } from 'react';
@@ -21,12 +22,14 @@ export interface MfaSetupDialogProps {
21
22
  open: boolean;
22
23
  onOpenChange: (open: boolean) => void;
23
24
  setupKey: string;
25
+ /** An `otpauth://` URI. When set, the dialog shows its QR code above the setup key, which stays as the fallback. */
26
+ otpauthUri?: string;
24
27
  /** Checks the 6-digit code; resolve `true` to finish enrolment. */
25
28
  onVerify: (code: string) => boolean | Promise<boolean>;
26
29
  }
27
30
 
28
- /** Authenticator enrolment: manual setup key and a 6-digit OtpInput, verified on completion. */
29
- export function MfaSetupDialog({ open, onOpenChange, setupKey, onVerify }: MfaSetupDialogProps) {
31
+ /** Authenticator enrolment: optional QR code, manual setup key and a 6-digit OtpInput, verified on completion. */
32
+ export function MfaSetupDialog({ open, onOpenChange, setupKey, otpauthUri, onVerify }: MfaSetupDialogProps) {
30
33
  const { t } = useI18n();
31
34
  const [code, setCode] = useState('');
32
35
  const [invalid, setInvalid] = useState(false);
@@ -65,6 +68,7 @@ export function MfaSetupDialog({ open, onOpenChange, setupKey, onVerify }: MfaSe
65
68
  </DialogDescription>
66
69
  </DialogHeader>
67
70
  <DialogBody className="flex flex-col gap-5">
71
+ {otpauthUri && <QrCode value={otpauthUri} className="self-center" />}
68
72
  <p className="text-[12.5px] text-muted-foreground">
69
73
  Setup key: <span className="font-mono text-foreground">{setupKey}</span>
70
74
  </p>
@@ -1,8 +1,10 @@
1
- import { render, screen } from '@testing-library/react';
1
+ import { render, screen, within } from '@testing-library/react';
2
2
  import userEvent from '@testing-library/user-event';
3
3
  import { describe, expect, it, vi } from 'vitest';
4
4
  import { expectNoAxeViolations } from '../test/a11y';
5
- import SettingsSecurityPage from './Page';
5
+ import WithQrCode from './examples/WithQrCode';
6
+ import { MfaSetupDialog } from './MfaSetupDialog';
7
+ import SettingsSecurityPage, { type SettingsSecurityProps } from './Page';
6
8
 
7
9
  describe('SettingsSecurityPage', () => {
8
10
  it('renders the password, MFA and sessions sections', () => {
@@ -37,8 +39,67 @@ describe('SettingsSecurityPage', () => {
37
39
  expect(await screen.findByText('Enabled')).toBeInTheDocument();
38
40
  }, 15000);
39
41
 
42
+ it('shows the QR code above the setup key and the verification code in the setup dialog', async () => {
43
+ render(<SettingsSecurityPage mfaOtpauthUri="otpauth://totp/Acme:ana@example.com?secret=ABCDEFGH&issuer=Acme" />);
44
+ await userEvent.click(screen.getByRole('switch', { name: 'Authenticator app' }));
45
+ const dialog = await screen.findByRole('dialog', { name: 'Set up two-factor authentication' });
46
+ const qr = within(dialog).getByRole('img', { name: 'QR code' });
47
+ const key = within(dialog).getByText(/Setup key:/);
48
+ const code = within(dialog).getByRole('group', { name: 'Verification code' });
49
+ expect(qr.compareDocumentPosition(key) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
50
+ expect(key.compareDocumentPosition(code) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
51
+ expect(qr.compareDocumentPosition(code) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
52
+ }, 15000);
53
+
54
+ it('shows no QR code on the page without mfaOtpauthUri and keeps the consumer setup key', async () => {
55
+ render(<SettingsSecurityPage mfaSetupKey="ABCD EFGH IJKL MNOP" />);
56
+ await userEvent.click(screen.getByRole('switch', { name: 'Authenticator app' }));
57
+ const dialog = await screen.findByRole('dialog', { name: 'Set up two-factor authentication' });
58
+ expect(within(dialog).queryByRole('img')).toBeNull();
59
+ expect(within(dialog).getByText(/Setup key:/)).toHaveTextContent('Setup key: ABCD EFGH IJKL MNOP');
60
+ expect(within(dialog).getByRole('group', { name: 'Verification code' })).toBeInTheDocument();
61
+ }, 15000);
62
+
63
+ it('shows the demo QR code in the docs example and keeps the setup key as the manual fallback', async () => {
64
+ render(<WithQrCode />);
65
+ await userEvent.click(screen.getByRole('switch', { name: 'Authenticator app' }));
66
+ const dialog = await screen.findByRole('dialog', { name: 'Set up two-factor authentication' });
67
+ expect(within(dialog).getByRole('img', { name: 'QR code' })).toBeInTheDocument();
68
+ expect(within(dialog).getByText('JBSW Y3DP EHPK 3PXP')).toBeInTheDocument();
69
+ }, 15000);
70
+
71
+ it('renders no QR code in the setup dialog without otpauthUri', () => {
72
+ render(<MfaSetupDialog open onOpenChange={() => undefined} setupKey="ABCD EFGH" onVerify={() => true} />);
73
+ const dialog = screen.getByRole('dialog', { name: 'Set up two-factor authentication' });
74
+ expect(within(dialog).queryByRole('img')).toBeNull();
75
+ expect(within(dialog).getByText(/Setup key:/)).toHaveTextContent('Setup key: ABCD EFGH');
76
+ }, 15000);
77
+
78
+ it('keeps mfaOtpauthUri optional on the exported props type', () => {
79
+ const complete: SettingsSecurityProps = {
80
+ sessions: [],
81
+ mfaEnabled: false,
82
+ mfaSetupKey: 'ABCD EFGH',
83
+ onVerifyMfa: () => true,
84
+ onMfaChange: () => undefined,
85
+ onPasswordChange: () => undefined,
86
+ onRevokeSession: () => undefined,
87
+ onRevokeOtherSessions: () => undefined,
88
+ };
89
+ render(<SettingsSecurityPage {...complete} />);
90
+ expect(screen.getByRole('switch', { name: 'Authenticator app' })).toBeInTheDocument();
91
+ }, 15000);
92
+
40
93
  it('has no axe violations', async () => {
41
94
  const { container } = render(<SettingsSecurityPage />);
42
95
  await expectNoAxeViolations(container);
43
96
  }, 15000);
97
+
98
+ it('has no axe violations with the QR setup dialog open', async () => {
99
+ render(<WithQrCode />);
100
+ await userEvent.click(screen.getByRole('switch', { name: 'Authenticator app' }));
101
+ const dialog = await screen.findByRole('dialog', { name: 'Set up two-factor authentication' });
102
+ expect(within(dialog).getByRole('img', { name: 'QR code' })).toBeInTheDocument();
103
+ await expectNoAxeViolations(document.body);
104
+ }, 15000);
44
105
  });
@@ -25,6 +25,8 @@ export interface SettingsSecurityProps extends SettingsFrameOptions {
25
25
  /** Whether two-factor authentication is on. */
26
26
  mfaEnabled: boolean;
27
27
  mfaSetupKey: string;
28
+ /** `otpauth://` URI of the enrolment; the setup dialog shows its QR code above the key. Without it, no QR code is shown. */
29
+ mfaOtpauthUri?: string;
28
30
  /** Checks an enrolment code; defaults to the demo code 123456. */
29
31
  onVerifyMfa: (code: string) => boolean | Promise<boolean>;
30
32
  onMfaChange: (enabled: boolean) => void;
@@ -39,6 +41,7 @@ export default function SettingsSecurityPage({
39
41
  sessions = defaultSessions,
40
42
  mfaEnabled = false,
41
43
  mfaSetupKey: setupKey = mfaSetupKey,
44
+ mfaOtpauthUri: otpauthUri,
42
45
  onVerifyMfa = (code) => code === DEMO_MFA_CODE,
43
46
  onMfaChange,
44
47
  onPasswordChange,
@@ -152,7 +155,13 @@ export default function SettingsSecurityPage({
152
155
  </SettingsRow>
153
156
  </FormSection>
154
157
  <SessionsDevices sessions={sessions} onRevoke={onRevokeSession} onRevokeOthers={onRevokeOtherSessions} />
155
- <MfaSetupDialog open={setupOpen} onOpenChange={setSetupOpen} setupKey={setupKey} onVerify={verify} />
158
+ <MfaSetupDialog
159
+ open={setupOpen}
160
+ onOpenChange={setSetupOpen}
161
+ setupKey={setupKey}
162
+ otpauthUri={otpauthUri}
163
+ onVerify={verify}
164
+ />
156
165
  </SettingsFrame>
157
166
  );
158
167
  }
@@ -5,7 +5,10 @@ export const sessions: DeviceSession[] = sampleDeviceSessions;
5
5
  /** Demo verification code accepted by the MFA setup dialog. */
6
6
  export const DEMO_MFA_CODE = '123456';
7
7
 
8
- /** Shown in the setup dialog for manual entry (the QR code comes from your auth provider). */
8
+ /** Shown in the setup dialog for manual entry, next to the QR code of `mfaOtpauthUri`. */
9
9
  export const mfaSetupKey = 'JBSW Y3DP EHPK 3PXP';
10
10
 
11
+ /** The enrolment URI an auth provider returns: the QR code encodes it, and its secret is `mfaSetupKey` without spaces. */
12
+ export const mfaOtpauthUri = 'otpauth://totp/Example:ana@example.com?secret=JBSWY3DPEHPK3PXP&issuer=Example';
13
+
11
14
  export const PASSWORD_MIN_LENGTH = 12;
@@ -0,0 +1,7 @@
1
+ import SettingsSecurityPage from '../Page';
2
+ import { mfaOtpauthUri } from '../data';
3
+
4
+ /** Turn on the authenticator app: the setup dialog shows a QR code of the otpauth URI above the setup key. */
5
+ export default function WithQrCode() {
6
+ return <SettingsSecurityPage mfaOtpauthUri={mfaOtpauthUri} />;
7
+ }
@@ -0,0 +1,98 @@
1
+ import { render, screen, within } from '@testing-library/react';
2
+ import userEvent from '@testing-library/user-event';
3
+ import { expectNoAxeViolations } from '../test/a11y';
4
+ import { ConsoleShell } from './ConsoleShell';
5
+
6
+ const account = { name: 'Ada Lovelace', email: 'ada@example.com' };
7
+
8
+ it('forwards tenant placeholders and the empty workspace opt-in to the header', async () => {
9
+ const user = userEvent.setup();
10
+ render(
11
+ <ConsoleShell
12
+ tenants={[{ id: 'one', name: 'One' }]}
13
+ currentTenantId={null}
14
+ tenantPlaceholder="Selecciona un tenant"
15
+ workspaces={[]}
16
+ workspaceLabel="Team spaces"
17
+ workspaceEmptyText="No team spaces yet"
18
+ topbar={{ user: null }}
19
+ >
20
+ Content
21
+ </ConsoleShell>,
22
+ );
23
+ const sidebar = screen.getByRole('complementary');
24
+ expect(within(sidebar).getByRole('combobox', { name: 'Tenant' })).toHaveTextContent('Selecciona un tenant');
25
+ await user.click(within(sidebar).getByRole('button', { name: 'Team spaces' }));
26
+ const menu = await screen.findByRole('menu');
27
+ expect(within(menu).getByText('No team spaces yet')).toBeInTheDocument();
28
+ expect(within(menu).queryByRole('menuitem', { name: 'Create workspace' })).toBeNull();
29
+ await expectNoAxeViolations();
30
+ });
31
+
32
+ describe('ConsoleShell account override', () => {
33
+ it.each([undefined, <span key="brand">Console identity</span>])(
34
+ 'keeps only the footer account when the topbar user is null (brand: %s)',
35
+ async (brand) => {
36
+ render(
37
+ <ConsoleShell user={account} topbar={{ user: null }} brand={brand}>
38
+ Content
39
+ </ConsoleShell>,
40
+ );
41
+ expect(screen.getAllByRole('button', { name: /Ada Lovelace/ })).toHaveLength(1);
42
+ expect(
43
+ within(screen.getByRole('complementary')).getByRole('button', { name: /Ada Lovelace/ }),
44
+ ).toBeInTheDocument();
45
+ expect(within(screen.getByRole('banner')).queryByRole('button', { name: /Ada Lovelace/ })).toBeNull();
46
+ await expectNoAxeViolations();
47
+ },
48
+ );
49
+
50
+ it.each([undefined, {}, { user: undefined }])('shares the account when topbar.user is undefined (%s)', (topbar) => {
51
+ render(
52
+ <ConsoleShell user={account} topbar={topbar}>
53
+ Content
54
+ </ConsoleShell>,
55
+ );
56
+ expect(screen.getAllByRole('button', { name: /Ada Lovelace/ })).toHaveLength(2);
57
+ });
58
+
59
+ it('uses a distinct topbar account without changing the footer account', () => {
60
+ render(
61
+ <ConsoleShell user={account} topbar={{ user: { name: 'Grace Hopper' } }}>
62
+ Content
63
+ </ConsoleShell>,
64
+ );
65
+ expect(within(screen.getByRole('banner')).getByRole('button', { name: /Grace Hopper/ })).toBeInTheDocument();
66
+ expect(within(screen.getByRole('complementary')).getByRole('button', { name: /Ada Lovelace/ })).toBeInTheDocument();
67
+ });
68
+ });
69
+
70
+ describe('ConsoleShell navigation name', () => {
71
+ it.each([undefined, 'Navegación principal'])(
72
+ 'names navigation in the sidebar and opened drawer (%s)',
73
+ async (navLabel) => {
74
+ const user = userEvent.setup();
75
+ render(<ConsoleShell navLabel={navLabel}>Content</ConsoleShell>);
76
+ expect(
77
+ within(screen.getByRole('complementary')).getByRole('navigation', { name: navLabel ?? 'Main' }),
78
+ ).toBeInTheDocument();
79
+ await user.click(screen.getByRole('button', { name: 'Open navigation' }));
80
+ const drawer = await screen.findByRole('dialog', { name: 'Sidebar' });
81
+ expect(within(drawer).getByRole('navigation', { name: navLabel ?? 'Main' })).toBeInTheDocument();
82
+ },
83
+ );
84
+ });
85
+
86
+ describe('ConsoleShell footer theme control', () => {
87
+ it.each([undefined, true, false])('forwards the footer theme option (%s)', async (showTheme) => {
88
+ render(
89
+ <ConsoleShell user={account} userMenuShowTheme={showTheme}>
90
+ Content
91
+ </ConsoleShell>,
92
+ );
93
+ await userEvent.click(within(screen.getByRole('complementary')).getByRole('button', { name: /Ada Lovelace/ }));
94
+ const theme = within(await screen.findByRole('menu')).queryByRole('menuitem', { name: 'Theme' });
95
+ if (showTheme === false) expect(theme).toBeNull();
96
+ else expect(theme).toBeInTheDocument();
97
+ });
98
+ });
@@ -25,21 +25,23 @@ export interface ConsoleShellProps
25
25
  Omit<AppSidebarHeaderProps, 'collapsed' | 'className' | 'workspaces'>,
26
26
  Pick<
27
27
  AppSidebarFooterProps,
28
- 'usage' | 'helpHref' | 'helpLabel' | 'userMenuItems' | 'userMenuChildren' | 'onSignOut'
28
+ 'usage' | 'helpHref' | 'helpLabel' | 'userMenuItems' | 'userMenuShowTheme' | 'userMenuChildren' | 'onSignOut'
29
29
  >,
30
30
  Pick<SidebarLayoutProps, 'sidebarLabel' | 'collapseMode'> {
31
31
  /** Page content (usually a <Page>). */
32
32
  children: ReactNode;
33
33
  /** Sidebar navigation; defaults to the NavigationProvider's groups, else the AppSidebar sample groups. */
34
34
  nav?: NavGroup[];
35
+ /** Accessible name of the primary navigation in the sidebar and mobile drawer; defaults to Main. */
36
+ navLabel?: string;
35
37
  /** Href of the current page, marks the active nav item; defaults to the NavigationProvider's active menu item. */
36
38
  currentHref?: string;
37
39
  /** Topbar trail; defaults to the NavigationProvider's active page. `null` hides it. */
38
40
  breadcrumbs?: BreadcrumbItem[] | null;
39
41
  workspaces?: Workspace[] | null;
40
42
  user?: UserMenuUser | null;
41
- /** Extra AppTopbar props (environment, notifications, theme control…). */
42
- topbar?: Omit<AppTopbarProps, 'breadcrumbs' | 'user'>;
43
+ /** Extra AppTopbar props. A defined user overrides the shared user; `null` hides only the topbar menu. */
44
+ topbar?: Omit<AppTopbarProps, 'breadcrumbs'>;
43
45
  /** localStorage key for the collapsed sidebar; `undefined` disables persistence. */
44
46
  storageKey?: string;
45
47
  }
@@ -55,6 +57,7 @@ export interface ConsoleShellProps
55
57
  export function ConsoleShell({
56
58
  children,
57
59
  nav: navProp,
60
+ navLabel,
58
61
  currentHref: currentHrefProp,
59
62
  breadcrumbs: breadcrumbsProp,
60
63
  workspaces,
@@ -66,6 +69,7 @@ export function ConsoleShell({
66
69
  helpHref,
67
70
  helpLabel,
68
71
  userMenuItems,
72
+ userMenuShowTheme,
69
73
  userMenuChildren,
70
74
  brand,
71
75
  onSignOut,
@@ -77,6 +81,7 @@ export function ConsoleShell({
77
81
  }: ConsoleShellProps) {
78
82
  const { locale } = useI18n();
79
83
  const navigation = useNavigation();
84
+ const topbarUser = topbar?.user !== undefined ? topbar.user : user;
80
85
  const nav = navProp ?? navigation?.groups;
81
86
  // No visible menu item for the active page (or no active page) leaves every item unmarked; the
82
87
  // raw pathname would re-activate routes getActivePage excludes, such as external ones.
@@ -101,7 +106,9 @@ export function ConsoleShell({
101
106
  {...contextProps}
102
107
  />
103
108
  )}
104
- sidebar={({ collapsed }) => <AppSidebarNav groups={nav} currentHref={currentHref} collapsed={collapsed} />}
109
+ sidebar={({ collapsed }) => (
110
+ <AppSidebarNav groups={nav} label={navLabel} currentHref={currentHref} collapsed={collapsed} />
111
+ )}
105
112
  sidebarFooter={({ collapsed }) => (
106
113
  <AppSidebarFooter
107
114
  collapsed={collapsed}
@@ -110,17 +117,18 @@ export function ConsoleShell({
110
117
  helpHref={helpHref}
111
118
  helpLabel={helpLabel}
112
119
  userMenuItems={userMenuItems}
120
+ userMenuShowTheme={userMenuShowTheme}
113
121
  userMenuChildren={userMenuChildren}
114
122
  onSignOut={onSignOut}
115
123
  />
116
124
  )}
117
125
  topbar={
118
126
  brand == null ? (
119
- <AppTopbar breadcrumbs={breadcrumbs} user={user} {...topbar} />
127
+ <AppTopbar breadcrumbs={breadcrumbs} {...topbar} user={topbarUser} />
120
128
  ) : (
121
129
  <>
122
130
  <div className="min-w-0 shrink-0 lg:hidden">{brand}</div>
123
- <AppTopbar breadcrumbs={breadcrumbs} user={user} {...topbar} />
131
+ <AppTopbar breadcrumbs={breadcrumbs} {...topbar} user={topbarUser} />
124
132
  </>
125
133
  )
126
134
  }
@@ -3,6 +3,23 @@ import userEvent from '@testing-library/user-event';
3
3
  import { ToastProvider, Toaster } from '@gntik-ai/ui';
4
4
 
5
5
  describe('Sidebar shell examples', () => {
6
+ it('demonstrates the tenant placeholder, navigation name and optional empty-workspace creation', async () => {
7
+ const { default: EmptyWorkspaces } = await import('./examples/EmptyWorkspaces');
8
+ const user = userEvent.setup();
9
+ render(<EmptyWorkspaces />);
10
+ expect(screen.getByRole('combobox', { name: 'Organization' })).toHaveTextContent('Choose an organization');
11
+ expect(screen.getByRole('navigation', { name: 'Primary navigation' })).toBeInTheDocument();
12
+ const trigger = screen.getByRole('button', { name: 'Team spaces' });
13
+ await user.click(trigger);
14
+ expect(within(await screen.findByRole('menu')).getByText('No team spaces yet')).toBeInTheDocument();
15
+ expect(screen.queryByRole('menuitem', { name: 'Create workspace' })).toBeNull();
16
+ await user.keyboard('{Escape}');
17
+ await user.click(screen.getByRole('button', { name: 'Enable workspace creation' }));
18
+ await user.click(trigger);
19
+ await user.click(await screen.findByRole('menuitem', { name: 'Create workspace' }));
20
+ expect(screen.getByRole('status')).toHaveTextContent('Ready to create a workspace');
21
+ });
22
+
6
23
  it('demonstrates the brand slot in the sidebar, rail and mobile topbar', async () => {
7
24
  const { default: Brand } = await import('./examples/Brand');
8
25
  render(<Brand />);
@@ -0,0 +1,33 @@
1
+ import { useState } from 'react';
2
+ import { Button, Text } from '@gntik-ai/ui';
3
+ import ShellSidebarPage from '../Page';
4
+
5
+ export default function EmptyWorkspaces() {
6
+ const [currentTenantId, onTenantSelect] = useState<string | null>(null);
7
+ const [canCreate, setCanCreate] = useState(false);
8
+ const [message, setMessage] = useState('');
9
+ return (
10
+ <ShellSidebarPage
11
+ shell={{
12
+ tenants: [
13
+ { id: 'one', name: 'One' },
14
+ { id: 'two', name: 'Two' },
15
+ ],
16
+ currentTenantId,
17
+ onTenantSelect,
18
+ tenantLabel: 'Organization',
19
+ tenantPlaceholder: 'Choose an organization',
20
+ navLabel: 'Primary navigation',
21
+ workspaces: [],
22
+ workspaceLabel: 'Team spaces',
23
+ workspaceEmptyText: 'No team spaces yet',
24
+ onCreateWorkspace: canCreate ? () => setMessage('Ready to create a workspace') : undefined,
25
+ }}
26
+ >
27
+ <Button onClick={() => setCanCreate(!canCreate)}>
28
+ {canCreate ? 'Disable workspace creation' : 'Enable workspace creation'}
29
+ </Button>
30
+ <Text role="status">{message}</Text>
31
+ </ShellSidebarPage>
32
+ );
33
+ }
@@ -9,6 +9,8 @@ export default function UserMenuChildren() {
9
9
  shell={{
10
10
  usage: null,
11
11
  helpHref: '',
12
+ topbar: { user: null },
13
+ userMenuShowTheme: false,
12
14
  userMenuItems: [{ label: 'Account settings', href: '#account' }],
13
15
  userMenuChildren: (
14
16
  <MenuRadioGroup value={language} onValueChange={setLanguage}>
@@ -6,7 +6,7 @@ export const meta: TemplateMeta = {
6
6
  priority: 'P1',
7
7
  status: 'stable',
8
8
  description:
9
- 'Console starter: app sidebar, topbar and an empty Page. Optional tenant selection, workspace context, a named busy region, account-menu content and a brand slot are shared through ConsoleShell.',
9
+ 'Console starter: app sidebar, topbar and an empty Page. ConsoleShell shares optional tenant selection (tenantPlaceholder), empty workspace menus (workspaceEmptyText), navigation naming (navLabel), a named busy region, account-menu content and a brand slot. userMenuShowTheme=false hides the footer Theme item; a defined topbar.user overrides only the topbar account, with null hiding it.',
10
10
  layout: 'SidebarLayout',
11
11
  blocks: ['app-sidebar', 'app-topbar', 'page-header', 'empty-states'],
12
12
  };
@@ -120,6 +120,24 @@ describe('FlowBuilderPage', () => {
120
120
  );
121
121
  });
122
122
 
123
+ it('offers undo by default and passes history through to the builder', async () => {
124
+ const { rerender } = render(<FlowBuilderPage />);
125
+ expect(screen.getByRole('button', { name: 'Undo' })).toHaveAttribute('aria-disabled', 'true');
126
+ expect(screen.getByRole('button', { name: 'Redo' })).toBeInTheDocument();
127
+ rerender(<FlowBuilderPage history={false} />);
128
+ expect(screen.queryByRole('button', { name: 'Undo' })).toBeNull();
129
+ expect(screen.queryByRole('button', { name: 'Redo' })).toBeNull();
130
+ });
131
+
132
+ it('saves the graph an undo restored', async () => {
133
+ const onSave = vi.fn<(graph: FlowGraph) => Promise<void>>(() => Promise.resolve());
134
+ render(<FlowBuilderPage onSave={onSave} />);
135
+ await userEvent.click(screen.getByRole('button', { name: 'Add Step' }));
136
+ await userEvent.click(screen.getByRole('button', { name: 'Undo' }));
137
+ await userEvent.click(screen.getByRole('button', { name: 'Save' }));
138
+ expect(onSave.mock.calls[0]?.[0].nodes).toHaveLength(5);
139
+ });
140
+
123
141
  it('renders the editor chrome and the flow builder', { timeout: 15000 }, async () => {
124
142
  render(<FlowBuilderPage />);
125
143
  expect(screen.getByRole('main', { name: 'Order sync editor' })).toBeInTheDocument();
@@ -31,6 +31,7 @@ export interface FlowBuilderPageProps<Kind extends string = FlowNodeKind> extend
31
31
  | 'onNodeSelect'
32
32
  | 'graph'
33
33
  | 'onGraphChange'
34
+ | 'history'
34
35
  > {
35
36
  /** Optional companion code panel; run mode forces readOnly. */
36
37
  codePanel?: CodePanelProps;
@@ -88,6 +89,7 @@ export default function FlowBuilderPage<Kind extends string = FlowNodeKind>(
88
89
  onNodeSelect,
89
90
  graph,
90
91
  onGraphChange,
92
+ history,
91
93
  codePanel,
92
94
  breadcrumbs = flowBuilderBreadcrumbs,
93
95
  height = 640,
@@ -175,6 +177,7 @@ export default function FlowBuilderPage<Kind extends string = FlowNodeKind>(
175
177
  mode={mode}
176
178
  nodeStatus={nodeStatus}
177
179
  onNodeSelect={onNodeSelect}
180
+ history={history}
178
181
  />
179
182
  {codePanel && (
180
183
  <CodePanel