@gntik-ai/templates 0.10.0 → 0.12.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/dist/index.d.ts +58 -18
- package/dist/index.js +471 -391
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/assistant-chat/Page.test.tsx +37 -7
- package/src/assistant-chat/Page.tsx +98 -137
- package/src/assistant-chat/data.ts +69 -1
- package/src/assistant-chat/examples/AdapterChat.tsx +9 -0
- package/src/assistant-chat/template.meta.ts +1 -1
- package/src/board/Lane.tsx +1 -1
- package/src/code-editor/Page.test.tsx +12 -0
- package/src/code-editor/Page.tsx +2 -1
- package/src/code-editor/examples/PaletteTypography.tsx +130 -0
- package/src/code-editor/template.meta.ts +1 -1
- package/src/contact/Page.test.tsx +106 -0
- package/src/contact/Page.tsx +21 -3
- package/src/contact/PublicFrame.tsx +2 -17
- package/src/contact/examples/CustomFailure.tsx +24 -0
- package/src/contact/examples/FailedSend.tsx +19 -0
- package/src/contact/template.meta.ts +2 -2
- package/src/docs-article/Page.tsx +1 -1
- package/src/help-home/Page.test.tsx +10 -0
- package/src/help-home/Page.tsx +2 -4
- package/src/incident-console/Page.tsx +1 -1
- package/src/keyboard-shortcuts/Page.test.tsx +23 -1
- package/src/keyboard-shortcuts/Page.tsx +13 -3
- package/src/keyboard-shortcuts/ShortcutSheet.tsx +4 -5
- package/src/landing/Page.tsx +3 -17
- package/src/landing/template.meta.ts +1 -1
- package/src/messaging/Page.test.tsx +20 -3
- package/src/messaging/Page.tsx +15 -43
- package/src/messaging/template.meta.ts +1 -1
- package/src/notification-inbox/Page.tsx +1 -1
- package/src/pending-activation/Page.test.tsx +1 -1
- package/src/pricing/PublicFrame.tsx +2 -17
- package/src/pricing/template.meta.ts +1 -1
- package/src/resource-detail/CustomTabs.tsx +41 -0
- package/src/resource-detail/Page.default.test.tsx +29 -0
- package/src/resource-detail/Page.shell-less.test.tsx +36 -0
- package/src/resource-detail/Page.tabs.test.tsx +116 -0
- package/src/resource-detail/Page.tsx +62 -27
- package/src/resource-detail/__snapshots__/Page.default.test.tsx.snap +5 -0
- package/src/resource-detail/examples/embedded-custom-tabs.tsx +44 -0
- package/src/resource-detail/template.meta.ts +1 -1
- package/src/resource-index/Page.test.tsx +178 -1
- package/src/resource-index/Page.tsx +59 -3
- package/src/resource-index/examples/UrlSynced.tsx +10 -0
- package/src/resource-index/template.meta.ts +1 -1
- package/src/resource-tree/Page.tsx +1 -1
- package/src/run-trace/Page.tsx +2 -2
- package/src/scorecard/Page.test.tsx +54 -0
- package/src/scorecard/Page.tsx +2 -0
- package/src/scorecard/data.ts +1 -1
- package/src/search-results/Page.tsx +3 -6
- package/src/settings-appearance/Page.test.tsx +36 -1
- package/src/settings-appearance/Page.tsx +15 -2
- package/src/settings-appearance/template.meta.ts +2 -1
- package/src/settings-profile/__tests__/dom.ts +4 -2
- package/src/settings-profile/fixtures/editable.snap +1 -1
- package/src/shared/ConsoleShell.context.test.tsx +125 -0
- package/src/shared/ConsoleShell.navigation.test.tsx +100 -0
- package/src/shared/ConsoleShell.tsx +38 -9
- package/src/shell-sidebar/Examples.test.tsx +73 -0
- package/src/shell-sidebar/examples/Brand.tsx +16 -0
- package/src/shell-sidebar/examples/ContextRegion.tsx +26 -0
- package/src/shell-sidebar/examples/PlatformWide.tsx +11 -0
- package/src/shell-sidebar/examples/Tenants.tsx +42 -0
- package/src/shell-sidebar/examples/UserMenuChildren.tsx +23 -0
- package/src/shell-sidebar/template.meta.ts +1 -1
- package/src/sign-in/BrandPanel.tsx +2 -2
- package/src/sign-in/Page.test.tsx +5 -0
- package/src/sso-login/Page.test.tsx +6 -0
- package/src/sso-login/Page.tsx +1 -0
- package/src/test/public-footer.test.tsx +44 -0
- package/src/test/without-forced-colors.test.ts +44 -0
- package/src/test/without-forced-colors.ts +14 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { MenuItem } from '@gntik-ai/ui';
|
|
2
|
+
import { render, screen, within } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { createHash } from 'node:crypto';
|
|
5
|
+
import { renderToStaticMarkup } from 'react-dom/server';
|
|
6
|
+
import { ConsoleShell } from './ConsoleShell';
|
|
7
|
+
|
|
8
|
+
const tenants = [
|
|
9
|
+
{ id: 't1', name: 'One' },
|
|
10
|
+
{ id: 't2', name: 'Two' },
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
describe('ConsoleShell context', () => {
|
|
14
|
+
it('keeps default shell markup stable, including palette label utilities and generated IDs', () => {
|
|
15
|
+
const html = renderToStaticMarkup(<ConsoleShell>Content</ConsoleShell>);
|
|
16
|
+
expect(createHash('sha256').update(html).digest('hex')).toBe(
|
|
17
|
+
'841b9bccf1601461bbf56ed0ebed6719a765250344c9a01c6703fc1e7735f6a5',
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
it('applies palette label case only to the navigation group labels', () => {
|
|
21
|
+
render(<ConsoleShell>Content</ConsoleShell>);
|
|
22
|
+
const navigation = screen.getByRole('navigation', { name: 'Main' });
|
|
23
|
+
for (const label of ['Workspace', 'Admin']) {
|
|
24
|
+
expect(within(navigation).getByText(label, { exact: true })).toHaveClass('label-case');
|
|
25
|
+
}
|
|
26
|
+
expect(Array.from(navigation.querySelectorAll('.label-case'), (element) => element.textContent)).toEqual([
|
|
27
|
+
'Workspace',
|
|
28
|
+
'Admin',
|
|
29
|
+
]);
|
|
30
|
+
});
|
|
31
|
+
it('keeps context out of the rail and renders expanded context and portalled menu extras in the drawer', async () => {
|
|
32
|
+
const user = userEvent.setup();
|
|
33
|
+
render(
|
|
34
|
+
<ConsoleShell
|
|
35
|
+
tenants={tenants}
|
|
36
|
+
currentTenantId="t1"
|
|
37
|
+
contextRegionLabel="Active context"
|
|
38
|
+
brand={<span>Console identity</span>}
|
|
39
|
+
userMenuChildren={<MenuItem>Language</MenuItem>}
|
|
40
|
+
>
|
|
41
|
+
Content
|
|
42
|
+
</ConsoleShell>,
|
|
43
|
+
);
|
|
44
|
+
await user.click(screen.getByRole('button', { name: 'Collapse sidebar' }));
|
|
45
|
+
const sidebar = screen.getByRole('complementary');
|
|
46
|
+
expect(within(sidebar).queryByRole('combobox')).toBeNull();
|
|
47
|
+
expect(within(sidebar).queryByRole('region')).toBeNull();
|
|
48
|
+
expect(within(sidebar).getByText('Console identity')).toBeInTheDocument();
|
|
49
|
+
await user.click(screen.getByRole('button', { name: 'Open navigation' }));
|
|
50
|
+
const drawer = await screen.findByRole('dialog', { name: 'Sidebar' });
|
|
51
|
+
const region = within(drawer).getByRole('region', { name: 'Active context' });
|
|
52
|
+
expect(within(region).getByRole('combobox', { name: 'Tenant' })).toHaveTextContent('One');
|
|
53
|
+
expect(within(region).getByRole('button', { name: /Acme Industries/ })).toBeInTheDocument();
|
|
54
|
+
expect(within(drawer).getByText('Console identity')).toBeInTheDocument();
|
|
55
|
+
await user.click(within(drawer).getByRole('button', { name: /Dana Whitfield/ }));
|
|
56
|
+
expect(within(await screen.findByRole('menu')).getByRole('menuitem', { name: 'Language' })).toBeInTheDocument();
|
|
57
|
+
});
|
|
58
|
+
it('forwards optional context and footer props and adds mobile branding only when supplied', async () => {
|
|
59
|
+
const user = userEvent.setup();
|
|
60
|
+
const onTenantSelect = vi.fn();
|
|
61
|
+
const { rerender } = render(<ConsoleShell>Content</ConsoleShell>);
|
|
62
|
+
const topbar = screen.getByRole('banner');
|
|
63
|
+
const defaultNodes = topbar.lastElementChild!.childElementCount;
|
|
64
|
+
expect(screen.queryByRole('combobox', { name: 'Organization' })).toBeNull();
|
|
65
|
+
rerender(
|
|
66
|
+
<ConsoleShell
|
|
67
|
+
tenants={tenants}
|
|
68
|
+
currentTenantId="t1"
|
|
69
|
+
onTenantSelect={onTenantSelect}
|
|
70
|
+
tenantLabel="Organization"
|
|
71
|
+
tenantEmptyText="No organizations"
|
|
72
|
+
workspaceLabel="Spaces"
|
|
73
|
+
workspaceEmptyText="No spaces"
|
|
74
|
+
contextRegionLabel="Active context"
|
|
75
|
+
contextBusy
|
|
76
|
+
contextStatus={<span role="status">Updating</span>}
|
|
77
|
+
brand={<span>Console identity</span>}
|
|
78
|
+
userMenuChildren={<MenuItem>Language</MenuItem>}
|
|
79
|
+
usage={null}
|
|
80
|
+
helpHref=""
|
|
81
|
+
>
|
|
82
|
+
Content
|
|
83
|
+
</ConsoleShell>,
|
|
84
|
+
);
|
|
85
|
+
const sidebar = screen.getByRole('complementary');
|
|
86
|
+
const region = within(sidebar).getByRole('region', { name: 'Active context' });
|
|
87
|
+
expect(region).toHaveAttribute('aria-busy', 'true');
|
|
88
|
+
expect(within(region).getByRole('status')).toHaveTextContent('Updating');
|
|
89
|
+
const tenant = within(region).getByRole('combobox', { name: 'Organization' });
|
|
90
|
+
expect(tenant).toHaveTextContent('One');
|
|
91
|
+
expect(within(region).getByRole('button', { name: /Spaces/ })).toBeInTheDocument();
|
|
92
|
+
const mobileBrand = within(topbar).getByText('Console identity').parentElement;
|
|
93
|
+
expect(mobileBrand).toHaveClass('lg:hidden', 'min-w-0', 'shrink-0');
|
|
94
|
+
expect(topbar.lastElementChild!.childElementCount).toBe(defaultNodes + 1);
|
|
95
|
+
expect(screen.queryByRole('meter')).toBeNull();
|
|
96
|
+
expect(within(sidebar).queryByRole('link', { name: 'Help & docs' })).toBeNull();
|
|
97
|
+
await user.click(tenant);
|
|
98
|
+
await user.click(await screen.findByRole('option', { name: 'Two' }));
|
|
99
|
+
expect(onTenantSelect).toHaveBeenCalledWith('t2');
|
|
100
|
+
await user.click(within(sidebar).getByRole('button', { name: /Dana Whitfield/ }));
|
|
101
|
+
expect(within(await screen.findByRole('menu')).getByRole('menuitem', { name: 'Language' })).toBeInTheDocument();
|
|
102
|
+
await user.keyboard('{Escape}');
|
|
103
|
+
rerender(
|
|
104
|
+
<ConsoleShell tenants={[]} tenantEmptyText="No organizations" brand={<span>Console identity</span>}>
|
|
105
|
+
Content
|
|
106
|
+
</ConsoleShell>,
|
|
107
|
+
);
|
|
108
|
+
expect(screen.getByRole('combobox', { name: 'Tenant' })).toHaveTextContent('No organizations');
|
|
109
|
+
rerender(
|
|
110
|
+
<ConsoleShell
|
|
111
|
+
tenants={tenants}
|
|
112
|
+
hideWorkspaceContext
|
|
113
|
+
contextRegionLabel="Active context"
|
|
114
|
+
brand={<span>Console identity</span>}
|
|
115
|
+
>
|
|
116
|
+
Content
|
|
117
|
+
</ConsoleShell>,
|
|
118
|
+
);
|
|
119
|
+
expect(screen.queryByRole('region')).toBeNull();
|
|
120
|
+
expect(screen.queryByRole('combobox')).toBeNull();
|
|
121
|
+
expect(within(sidebar).getByText('Console identity')).toBeInTheDocument();
|
|
122
|
+
rerender(<ConsoleShell>Content</ConsoleShell>);
|
|
123
|
+
expect(topbar.lastElementChild!.childElementCount).toBe(defaultNodes);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { NavigationProvider, type NavRoute } from '@gntik-ai/ui';
|
|
2
|
+
import { render, screen, within } from '@testing-library/react';
|
|
3
|
+
import { createHash } from 'node:crypto';
|
|
4
|
+
import { renderToStaticMarkup } from 'react-dom/server';
|
|
5
|
+
import { ConsoleShell } from './ConsoleShell';
|
|
6
|
+
|
|
7
|
+
const routes: NavRoute[] = [
|
|
8
|
+
{
|
|
9
|
+
path: '/functions',
|
|
10
|
+
title: 'Functions',
|
|
11
|
+
group: 'Build',
|
|
12
|
+
hideChildrenInMenu: true,
|
|
13
|
+
children: [{ path: '/functions/:id', title: (p) => p.id ?? '' }],
|
|
14
|
+
},
|
|
15
|
+
{ path: '/logs', title: 'Logs', group: 'Operate' },
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
const inProvider = (pathname: string, shell: React.ReactNode) => (
|
|
19
|
+
<NavigationProvider routes={routes} pathname={pathname} home={{ label: 'Home', href: '/' }}>
|
|
20
|
+
{shell}
|
|
21
|
+
</NavigationProvider>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
describe('ConsoleShell inside a NavigationProvider', () => {
|
|
25
|
+
it('derives the sidebar, the current item and the trail from the route tree', () => {
|
|
26
|
+
render(inProvider('/functions/fn-42', <ConsoleShell>Content</ConsoleShell>));
|
|
27
|
+
const sidebar = screen.getByRole('navigation', { name: 'Main' });
|
|
28
|
+
expect(within(sidebar).getByRole('link', { name: 'Functions' })).toHaveAttribute('aria-current', 'page');
|
|
29
|
+
expect(within(sidebar).queryByRole('link', { name: 'Logs' })).not.toHaveAttribute('aria-current');
|
|
30
|
+
expect(within(sidebar).getByText('Build')).toBeInTheDocument();
|
|
31
|
+
expect(within(sidebar).queryByText('Workspace')).toBeNull();
|
|
32
|
+
const trail = screen.getByRole('navigation', { name: 'Breadcrumb' });
|
|
33
|
+
expect(within(trail).getByRole('link', { name: 'Home' })).toHaveAttribute('href', '/');
|
|
34
|
+
expect(within(trail).getByRole('link', { name: 'Functions' })).toHaveAttribute('href', '/functions');
|
|
35
|
+
expect(within(trail).getByText('fn-42')).toHaveAttribute('aria-current', 'page');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('lets explicit nav, currentHref and breadcrumbs win', () => {
|
|
39
|
+
render(
|
|
40
|
+
inProvider(
|
|
41
|
+
'/functions/fn-42',
|
|
42
|
+
<ConsoleShell
|
|
43
|
+
nav={[
|
|
44
|
+
{
|
|
45
|
+
label: 'Mine',
|
|
46
|
+
items: [
|
|
47
|
+
{ label: 'Alpha', href: '/alpha' },
|
|
48
|
+
{ label: 'Beta', href: '/beta' },
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
]}
|
|
52
|
+
currentHref="/beta"
|
|
53
|
+
breadcrumbs={[{ label: 'Explicit' }]}
|
|
54
|
+
>
|
|
55
|
+
Content
|
|
56
|
+
</ConsoleShell>,
|
|
57
|
+
),
|
|
58
|
+
);
|
|
59
|
+
const sidebar = screen.getByRole('navigation', { name: 'Main' });
|
|
60
|
+
expect(within(sidebar).getByRole('link', { name: 'Beta' })).toHaveAttribute('aria-current', 'page');
|
|
61
|
+
expect(within(sidebar).queryByRole('link', { name: 'Functions' })).toBeNull();
|
|
62
|
+
const trail = screen.getByRole('navigation', { name: 'Breadcrumb' });
|
|
63
|
+
expect(within(trail).getByText('Explicit')).toBeInTheDocument();
|
|
64
|
+
expect(within(trail).queryByText('fn-42')).toBeNull();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('hides the trail for breadcrumbs={null}, and for an unknown path', () => {
|
|
68
|
+
const { unmount } = render(inProvider('/functions/fn-42', <ConsoleShell breadcrumbs={null}>Content</ConsoleShell>));
|
|
69
|
+
expect(screen.queryByRole('navigation', { name: 'Breadcrumb' })).toBeNull();
|
|
70
|
+
unmount();
|
|
71
|
+
render(inProvider('/nowhere', <ConsoleShell>Content</ConsoleShell>));
|
|
72
|
+
expect(screen.queryByRole('navigation', { name: 'Breadcrumb' })).toBeNull();
|
|
73
|
+
const sidebar = screen.getByRole('navigation', { name: 'Main' });
|
|
74
|
+
expect(within(sidebar).queryByRole('link', { current: 'page' })).toBeNull();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('does not mark an external route current even when its path is the pathname', () => {
|
|
78
|
+
const external: NavRoute[] = [
|
|
79
|
+
{ path: '/logs', title: 'Logs', group: 'Operate' },
|
|
80
|
+
{ path: '/docs', title: 'Docs', group: 'Operate', target: '_blank' },
|
|
81
|
+
];
|
|
82
|
+
render(
|
|
83
|
+
<NavigationProvider routes={external} pathname="/docs">
|
|
84
|
+
<ConsoleShell>Content</ConsoleShell>
|
|
85
|
+
</NavigationProvider>,
|
|
86
|
+
);
|
|
87
|
+
const sidebar = screen.getByRole('navigation', { name: 'Main' });
|
|
88
|
+
expect(within(sidebar).getByRole('link', { name: 'Docs' })).toBeInTheDocument();
|
|
89
|
+
expect(within(sidebar).queryByRole('link', { current: 'page' })).toBeNull();
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
describe('ConsoleShell outside a NavigationProvider', () => {
|
|
94
|
+
it('renders the same DOM as before the provider existed', () => {
|
|
95
|
+
const html = renderToStaticMarkup(<ConsoleShell>Content</ConsoleShell>);
|
|
96
|
+
expect(createHash('sha256').update(html).digest('hex')).toBe(
|
|
97
|
+
'841b9bccf1601461bbf56ed0ebed6719a765250344c9a01c6703fc1e7735f6a5',
|
|
98
|
+
);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
import {
|
|
12
12
|
SidebarLayout,
|
|
13
13
|
useI18n,
|
|
14
|
+
useNavigation,
|
|
14
15
|
type BreadcrumbItem,
|
|
15
16
|
type NavGroup,
|
|
16
17
|
type SidebarLayoutProps,
|
|
@@ -21,15 +22,19 @@ import type { ReactNode } from 'react';
|
|
|
21
22
|
|
|
22
23
|
export interface ConsoleShellProps
|
|
23
24
|
extends
|
|
24
|
-
|
|
25
|
-
Pick<
|
|
25
|
+
Omit<AppSidebarHeaderProps, 'collapsed' | 'className' | 'workspaces'>,
|
|
26
|
+
Pick<
|
|
27
|
+
AppSidebarFooterProps,
|
|
28
|
+
'usage' | 'helpHref' | 'helpLabel' | 'userMenuItems' | 'userMenuChildren' | 'onSignOut'
|
|
29
|
+
>,
|
|
26
30
|
Pick<SidebarLayoutProps, 'sidebarLabel' | 'collapseMode'> {
|
|
27
31
|
/** Page content (usually a <Page>). */
|
|
28
32
|
children: ReactNode;
|
|
29
|
-
/** Sidebar navigation; defaults to the AppSidebar sample groups. */
|
|
33
|
+
/** Sidebar navigation; defaults to the NavigationProvider's groups, else the AppSidebar sample groups. */
|
|
30
34
|
nav?: NavGroup[];
|
|
31
|
-
/** Href of the current page, marks the active nav item. */
|
|
35
|
+
/** Href of the current page, marks the active nav item; defaults to the NavigationProvider's active menu item. */
|
|
32
36
|
currentHref?: string;
|
|
37
|
+
/** Topbar trail; defaults to the NavigationProvider's active page. `null` hides it. */
|
|
33
38
|
breadcrumbs?: BreadcrumbItem[] | null;
|
|
34
39
|
workspaces?: Workspace[] | null;
|
|
35
40
|
user?: UserMenuUser | null;
|
|
@@ -43,13 +48,15 @@ export interface ConsoleShellProps
|
|
|
43
48
|
* The console frame shared by the templates: SidebarLayout with the AppSidebar header, nav and
|
|
44
49
|
* footer, and the AppTopbar (breadcrumb, ⌘K search, notifications, theme, user menu).
|
|
45
50
|
* Templates fill it with a Page; products swap the nav, workspaces, user, usage meter, help
|
|
46
|
-
* link and user-menu items.
|
|
51
|
+
* link and user-menu items. Inside a NavigationProvider, an omitted `nav`, `currentHref` or
|
|
52
|
+
* `breadcrumbs` comes from the route tree; explicit props always win, and without a provider the
|
|
53
|
+
* defaults are unchanged.
|
|
47
54
|
*/
|
|
48
55
|
export function ConsoleShell({
|
|
49
56
|
children,
|
|
50
|
-
nav,
|
|
51
|
-
currentHref,
|
|
52
|
-
breadcrumbs,
|
|
57
|
+
nav: navProp,
|
|
58
|
+
currentHref: currentHrefProp,
|
|
59
|
+
breadcrumbs: breadcrumbsProp,
|
|
53
60
|
workspaces,
|
|
54
61
|
currentWorkspaceId,
|
|
55
62
|
onWorkspaceChange,
|
|
@@ -59,13 +66,23 @@ export function ConsoleShell({
|
|
|
59
66
|
helpHref,
|
|
60
67
|
helpLabel,
|
|
61
68
|
userMenuItems,
|
|
69
|
+
userMenuChildren,
|
|
70
|
+
brand,
|
|
62
71
|
onSignOut,
|
|
63
72
|
topbar,
|
|
64
73
|
storageKey,
|
|
65
74
|
sidebarLabel,
|
|
66
75
|
collapseMode,
|
|
76
|
+
...contextProps
|
|
67
77
|
}: ConsoleShellProps) {
|
|
68
78
|
const { locale } = useI18n();
|
|
79
|
+
const navigation = useNavigation();
|
|
80
|
+
const nav = navProp ?? navigation?.groups;
|
|
81
|
+
// No visible menu item for the active page (or no active page) leaves every item unmarked; the
|
|
82
|
+
// raw pathname would re-activate routes getActivePage excludes, such as external ones.
|
|
83
|
+
const currentHref = currentHrefProp ?? (navigation ? (navigation.activePage?.menuHref ?? '') : undefined);
|
|
84
|
+
const breadcrumbs =
|
|
85
|
+
breadcrumbsProp === undefined && navigation ? (navigation.activePage?.breadcrumbs ?? null) : breadcrumbsProp;
|
|
69
86
|
return (
|
|
70
87
|
<ChartLocaleProvider locale={locale}>
|
|
71
88
|
<SidebarLayout
|
|
@@ -80,6 +97,8 @@ export function ConsoleShell({
|
|
|
80
97
|
currentWorkspaceId={currentWorkspaceId}
|
|
81
98
|
onWorkspaceChange={onWorkspaceChange}
|
|
82
99
|
onCreateWorkspace={onCreateWorkspace}
|
|
100
|
+
brand={brand}
|
|
101
|
+
{...contextProps}
|
|
83
102
|
/>
|
|
84
103
|
)}
|
|
85
104
|
sidebar={({ collapsed }) => <AppSidebarNav groups={nav} currentHref={currentHref} collapsed={collapsed} />}
|
|
@@ -91,10 +110,20 @@ export function ConsoleShell({
|
|
|
91
110
|
helpHref={helpHref}
|
|
92
111
|
helpLabel={helpLabel}
|
|
93
112
|
userMenuItems={userMenuItems}
|
|
113
|
+
userMenuChildren={userMenuChildren}
|
|
94
114
|
onSignOut={onSignOut}
|
|
95
115
|
/>
|
|
96
116
|
)}
|
|
97
|
-
topbar={
|
|
117
|
+
topbar={
|
|
118
|
+
brand == null ? (
|
|
119
|
+
<AppTopbar breadcrumbs={breadcrumbs} user={user} {...topbar} />
|
|
120
|
+
) : (
|
|
121
|
+
<>
|
|
122
|
+
<div className="min-w-0 shrink-0 lg:hidden">{brand}</div>
|
|
123
|
+
<AppTopbar breadcrumbs={breadcrumbs} user={user} {...topbar} />
|
|
124
|
+
</>
|
|
125
|
+
)
|
|
126
|
+
}
|
|
98
127
|
>
|
|
99
128
|
{children}
|
|
100
129
|
</SidebarLayout>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { render, screen, within } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
3
|
+
import { ToastProvider, Toaster } from '@gntik-ai/ui';
|
|
4
|
+
|
|
5
|
+
describe('Sidebar shell examples', () => {
|
|
6
|
+
it('demonstrates the brand slot in the sidebar, rail and mobile topbar', async () => {
|
|
7
|
+
const { default: Brand } = await import('./examples/Brand');
|
|
8
|
+
render(<Brand />);
|
|
9
|
+
expect(within(screen.getByRole('complementary')).getByText('Console identity')).toBeInTheDocument();
|
|
10
|
+
expect(within(screen.getAllByRole('banner')[0]!).getByText('Console identity').parentElement).toHaveClass(
|
|
11
|
+
'lg:hidden',
|
|
12
|
+
);
|
|
13
|
+
await userEvent.click(screen.getByRole('button', { name: 'Collapse sidebar' }));
|
|
14
|
+
expect(within(screen.getByRole('complementary')).getByText('Console identity')).toBeInTheDocument();
|
|
15
|
+
});
|
|
16
|
+
it('demonstrates language choices alongside standard account actions', async () => {
|
|
17
|
+
const { default: UserMenuChildren } = await import('./examples/UserMenuChildren');
|
|
18
|
+
render(<UserMenuChildren />);
|
|
19
|
+
const sidebar = screen.getByRole('complementary');
|
|
20
|
+
await userEvent.click(within(sidebar).getByRole('button', { name: /Dana Whitfield/ }));
|
|
21
|
+
const menu = await screen.findByRole('menu');
|
|
22
|
+
expect(within(menu).getByRole('menuitem', { name: 'Account settings' })).toBeInTheDocument();
|
|
23
|
+
expect(within(menu).getByRole('menuitemradio', { name: 'English' })).toHaveAttribute('aria-checked', 'true');
|
|
24
|
+
await userEvent.click(within(menu).getByRole('menuitemradio', { name: 'French' }));
|
|
25
|
+
await userEvent.click(within(sidebar).getByRole('button', { name: /Dana Whitfield/ }));
|
|
26
|
+
expect(within(await screen.findByRole('menu')).getByRole('menuitemradio', { name: 'French' })).toHaveAttribute(
|
|
27
|
+
'aria-checked',
|
|
28
|
+
'true',
|
|
29
|
+
);
|
|
30
|
+
expect(screen.queryByRole('meter')).toBeNull();
|
|
31
|
+
expect(within(sidebar).queryByRole('link', { name: 'Help & docs' })).toBeNull();
|
|
32
|
+
});
|
|
33
|
+
it('demonstrates a busy context region whose consumer resets it', async () => {
|
|
34
|
+
const { default: ContextRegion } = await import('./examples/ContextRegion');
|
|
35
|
+
render(<ContextRegion />);
|
|
36
|
+
const region = screen.getByRole('region', { name: 'Active context' });
|
|
37
|
+
expect(region).toHaveAttribute('aria-busy', 'true');
|
|
38
|
+
expect(screen.getByRole('status')).toHaveTextContent('Updating context');
|
|
39
|
+
await userEvent.click(screen.getByRole('button', { name: 'Finish context update' }));
|
|
40
|
+
expect(region).toHaveAttribute('aria-busy', 'false');
|
|
41
|
+
expect(screen.getByRole('status')).toHaveTextContent('Context ready');
|
|
42
|
+
});
|
|
43
|
+
it('demonstrates platform-wide context with a brand and no context controls', async () => {
|
|
44
|
+
const { default: PlatformWide } = await import('./examples/PlatformWide');
|
|
45
|
+
render(
|
|
46
|
+
<ToastProvider>
|
|
47
|
+
<PlatformWide />
|
|
48
|
+
<Toaster />
|
|
49
|
+
</ToastProvider>,
|
|
50
|
+
);
|
|
51
|
+
expect(screen.getAllByText('Platform console').length).toBeGreaterThan(0);
|
|
52
|
+
expect(screen.queryByRole('combobox')).toBeNull();
|
|
53
|
+
expect(within(screen.getByRole('complementary')).queryByRole('region')).toBeNull();
|
|
54
|
+
expect(screen.getByRole('region', { name: 'Notifications' })).toBeInTheDocument();
|
|
55
|
+
});
|
|
56
|
+
it('demonstrates tenant selection, clearing and custom workspace copy', async () => {
|
|
57
|
+
const { default: Tenants } = await import('./examples/Tenants');
|
|
58
|
+
render(<Tenants />);
|
|
59
|
+
const user = userEvent.setup();
|
|
60
|
+
const tenant = screen.getByRole('combobox', { name: 'Organization' });
|
|
61
|
+
expect(tenant).toHaveTextContent('One');
|
|
62
|
+
await user.click(tenant);
|
|
63
|
+
await user.click(await screen.findByRole('option', { name: 'Two' }));
|
|
64
|
+
expect(tenant).toHaveTextContent('Two');
|
|
65
|
+
tenant.focus();
|
|
66
|
+
await user.keyboard('{Delete}');
|
|
67
|
+
expect(tenant).toHaveTextContent('Select tenant');
|
|
68
|
+
expect(screen.getByRole('combobox', { name: /Team spaces/ })).toBeInTheDocument();
|
|
69
|
+
expect(screen.getByRole('status')).toHaveTextContent('Platform context');
|
|
70
|
+
await user.click(screen.getByRole('button', { name: 'Show empty tenant list' }));
|
|
71
|
+
expect(tenant).toHaveTextContent('No organizations');
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Text } from '@gntik-ai/ui';
|
|
2
|
+
import ShellSidebarPage from '../Page';
|
|
3
|
+
|
|
4
|
+
export default function Brand() {
|
|
5
|
+
return (
|
|
6
|
+
<ShellSidebarPage
|
|
7
|
+
shell={{
|
|
8
|
+
brand: (
|
|
9
|
+
<Text variant="label" className="truncate">
|
|
10
|
+
Console identity
|
|
11
|
+
</Text>
|
|
12
|
+
),
|
|
13
|
+
}}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Badge, Button } from '@gntik-ai/ui';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import ShellSidebarPage from '../Page';
|
|
4
|
+
|
|
5
|
+
export default function ContextRegion() {
|
|
6
|
+
const [busy, setBusy] = useState(true);
|
|
7
|
+
const [currentTenantId, onTenantSelect] = useState<string | null>('t1');
|
|
8
|
+
return (
|
|
9
|
+
<ShellSidebarPage
|
|
10
|
+
shell={{
|
|
11
|
+
tenants: [
|
|
12
|
+
{ id: 't1', name: 'One' },
|
|
13
|
+
{ id: 't2', name: 'Two' },
|
|
14
|
+
],
|
|
15
|
+
currentTenantId,
|
|
16
|
+
onTenantSelect,
|
|
17
|
+
contextRegionLabel: 'Active context',
|
|
18
|
+
// The consumer owns this lifetime and must reset it when loading completes.
|
|
19
|
+
contextBusy: busy,
|
|
20
|
+
contextStatus: <Badge role="status">{busy ? 'Updating context' : 'Context ready'}</Badge>,
|
|
21
|
+
}}
|
|
22
|
+
>
|
|
23
|
+
<Button onClick={() => setBusy(!busy)}>{busy ? 'Finish context update' : 'Reload context'}</Button>
|
|
24
|
+
</ShellSidebarPage>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Text } from '@gntik-ai/ui';
|
|
2
|
+
import ShellSidebarPage from '../Page';
|
|
3
|
+
|
|
4
|
+
export default function PlatformWide() {
|
|
5
|
+
return (
|
|
6
|
+
<ShellSidebarPage
|
|
7
|
+
title="Platform overview"
|
|
8
|
+
shell={{ hideWorkspaceContext: true, brand: <Text variant="label">Platform console</Text> }}
|
|
9
|
+
/>
|
|
10
|
+
);
|
|
11
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { Button, Text } from '@gntik-ai/ui';
|
|
3
|
+
import ShellSidebarPage from '../Page';
|
|
4
|
+
|
|
5
|
+
const tenants = [
|
|
6
|
+
{ id: 't1', name: 'One' },
|
|
7
|
+
{ id: 't2', name: 'Two' },
|
|
8
|
+
];
|
|
9
|
+
const workspaces = Array.from({ length: 7 }, (_, i) => ({ id: `space-${i}`, name: `Space ${i + 1}` }));
|
|
10
|
+
|
|
11
|
+
export default function Tenants() {
|
|
12
|
+
const [currentTenantId, onTenantSelect] = useState<string | null>('t1');
|
|
13
|
+
const [empty, setEmpty] = useState(false);
|
|
14
|
+
return (
|
|
15
|
+
<ShellSidebarPage
|
|
16
|
+
shell={{
|
|
17
|
+
tenants: empty ? [] : tenants,
|
|
18
|
+
currentTenantId,
|
|
19
|
+
onTenantSelect,
|
|
20
|
+
tenantLabel: 'Organization',
|
|
21
|
+
tenantEmptyText: 'No organizations',
|
|
22
|
+
workspaces,
|
|
23
|
+
workspaceLabel: 'Team spaces',
|
|
24
|
+
workspaceEmptyText: 'No matching team spaces',
|
|
25
|
+
contextStatus: (
|
|
26
|
+
<Text variant="caption" role="status">
|
|
27
|
+
{currentTenantId ? `Organization ${currentTenantId === 't1' ? 'One' : 'Two'}` : 'Platform context'}
|
|
28
|
+
</Text>
|
|
29
|
+
),
|
|
30
|
+
}}
|
|
31
|
+
>
|
|
32
|
+
<Button
|
|
33
|
+
onClick={() => {
|
|
34
|
+
setEmpty(!empty);
|
|
35
|
+
onTenantSelect(null);
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
{empty ? 'Restore tenants' : 'Show empty tenant list'}
|
|
39
|
+
</Button>
|
|
40
|
+
</ShellSidebarPage>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { MenuGroupLabel, MenuRadioGroup, MenuRadioItem } from '@gntik-ai/ui';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import ShellSidebarPage from '../Page';
|
|
4
|
+
|
|
5
|
+
export default function UserMenuChildren() {
|
|
6
|
+
const [language, setLanguage] = useState('en');
|
|
7
|
+
return (
|
|
8
|
+
<ShellSidebarPage
|
|
9
|
+
shell={{
|
|
10
|
+
usage: null,
|
|
11
|
+
helpHref: '',
|
|
12
|
+
userMenuItems: [{ label: 'Account settings', href: '#account' }],
|
|
13
|
+
userMenuChildren: (
|
|
14
|
+
<MenuRadioGroup value={language} onValueChange={setLanguage}>
|
|
15
|
+
<MenuGroupLabel>Language</MenuGroupLabel>
|
|
16
|
+
<MenuRadioItem value="en">English</MenuRadioItem>
|
|
17
|
+
<MenuRadioItem value="fr">French</MenuRadioItem>
|
|
18
|
+
</MenuRadioGroup>
|
|
19
|
+
),
|
|
20
|
+
}}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -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
|
|
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.',
|
|
10
10
|
layout: 'SidebarLayout',
|
|
11
11
|
blocks: ['app-sidebar', 'app-topbar', 'page-header', 'empty-states'],
|
|
12
12
|
};
|
|
@@ -12,10 +12,10 @@ export function BrandPanel({ eyebrow, headline, features }: BrandPanelCopy) {
|
|
|
12
12
|
return (
|
|
13
13
|
<Stack gap={8}>
|
|
14
14
|
<Stack gap={4}>
|
|
15
|
-
<Text variant="caption" tone="primary" className="font-mono tracking-[0.18em]
|
|
15
|
+
<Text variant="caption" tone="primary" className="font-mono tracking-[0.18em] label-case">
|
|
16
16
|
{eyebrow}
|
|
17
17
|
</Text>
|
|
18
|
-
<Text variant="display" className="text-[32px] text-balance">
|
|
18
|
+
<Text variant="display" className="text-[32px] font-bold tracking-tight text-balance">
|
|
19
19
|
{headline}
|
|
20
20
|
</Text>
|
|
21
21
|
</Stack>
|
|
@@ -4,6 +4,11 @@ import { expectNoAxeViolations } from '../test/a11y';
|
|
|
4
4
|
import SignInPage from './Page';
|
|
5
5
|
|
|
6
6
|
describe('SignInPage', () => {
|
|
7
|
+
it('keeps the brand headline bold and tightly tracked at its custom font size', () => {
|
|
8
|
+
render(<SignInPage brand={{ eyebrow: 'Workspace', headline: 'A place for your team', features: [] }} />);
|
|
9
|
+
expect(screen.getByText('A place for your team')).toHaveClass('text-[32px]', 'font-bold', 'tracking-tight');
|
|
10
|
+
});
|
|
11
|
+
|
|
7
12
|
it('renders the form, SSO options and brand panel', async () => {
|
|
8
13
|
const { container } = render(<SignInPage />);
|
|
9
14
|
expect(screen.getByRole('main')).toBeInTheDocument();
|
|
@@ -4,6 +4,12 @@ import { expectNoAxeViolations } from '../test/a11y';
|
|
|
4
4
|
import SsoLoginPage from './Page';
|
|
5
5
|
|
|
6
6
|
describe('SsoLoginPage', () => {
|
|
7
|
+
it('matches the 44px work email field to the SSO button', () => {
|
|
8
|
+
render(<SsoLoginPage />);
|
|
9
|
+
expect(screen.getByLabelText('Work email').parentElement).toHaveClass('h-11');
|
|
10
|
+
expect(screen.getByRole('button', { name: 'Continue with SSO' })).toHaveClass('h-11');
|
|
11
|
+
});
|
|
12
|
+
|
|
7
13
|
it('renders the work email step', async () => {
|
|
8
14
|
const { container } = render(<SsoLoginPage />);
|
|
9
15
|
expect(screen.getByRole('main')).toBeInTheDocument();
|
package/src/sso-login/Page.tsx
CHANGED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { render, screen, within } from '@testing-library/react';
|
|
2
|
+
import { I18nProvider } from '@gntik-ai/ui';
|
|
3
|
+
import LandingPage from '../landing/Page';
|
|
4
|
+
import PricingPage from '../pricing/Page';
|
|
5
|
+
import ContactPage from '../contact/Page';
|
|
6
|
+
import { expectNoAxeViolations } from './a11y';
|
|
7
|
+
|
|
8
|
+
describe.each([
|
|
9
|
+
['landing', LandingPage],
|
|
10
|
+
['pricing', PricingPage],
|
|
11
|
+
['contact', ContactPage],
|
|
12
|
+
] as const)('%s public footer', (_name, Page) => {
|
|
13
|
+
it.each(['dark', 'light', 'high_contrast'])(
|
|
14
|
+
'keeps one footer with the public links (%s)',
|
|
15
|
+
{ timeout: 15000 },
|
|
16
|
+
async (theme) => {
|
|
17
|
+
document.documentElement.className = theme;
|
|
18
|
+
const { container } = render(<Page />);
|
|
19
|
+
const footers = screen.getAllByRole('contentinfo');
|
|
20
|
+
expect(footers).toHaveLength(1);
|
|
21
|
+
const footer = footers[0]!;
|
|
22
|
+
expect(footer.querySelector('footer')).toBeNull();
|
|
23
|
+
const nav = within(footer).getByRole('navigation', { name: 'Footer' });
|
|
24
|
+
expect(
|
|
25
|
+
within(nav)
|
|
26
|
+
.getAllByRole('link')
|
|
27
|
+
.map((link) => link.textContent),
|
|
28
|
+
).toEqual(['Status', 'Privacy', 'Terms']);
|
|
29
|
+
await expectNoAxeViolations(container);
|
|
30
|
+
},
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
it('uses the footer catalog and keeps caller footerLinks and copyright', () => {
|
|
34
|
+
render(
|
|
35
|
+
<I18nProvider locale="es">
|
|
36
|
+
<Page footerLinks={[{ label: 'Custom link', href: '/custom' }]} copyright="© Custom" />
|
|
37
|
+
</I18nProvider>,
|
|
38
|
+
);
|
|
39
|
+
const footer = screen.getByRole('contentinfo');
|
|
40
|
+
const nav = within(footer).getByRole('navigation', { name: 'Pie de página' });
|
|
41
|
+
expect(within(nav).getByRole('link', { name: 'Custom link' })).toHaveAttribute('href', '/custom');
|
|
42
|
+
expect(within(footer).getByText('© Custom')).toBeInTheDocument();
|
|
43
|
+
});
|
|
44
|
+
});
|