@bevel-software/platform-core-frontend 0.25.2 → 0.27.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 +2 -2
- package/src/core/CoreAppShell.tsx +87 -25
- package/src/core/ProductName.tsx +49 -0
- package/src/core/__tests__/ShellRoutes.test.tsx +22 -0
- package/src/core/__tests__/core-contributions.test.ts +16 -0
- package/src/core/core-contributions.ts +17 -0
- package/src/core/registry.ts +51 -1
- package/src/index.css +23 -5
- package/src/index.ts +5 -0
- package/src/modules/access/__tests__/ManageAccessDialog.proposal.test.tsx +1 -1
- package/src/modules/access/components/ManageAccessDialog.tsx +1 -1
- package/src/modules/admin/__tests__/RolesCorruptedBanner.test.tsx +70 -0
- package/src/modules/admin/components/RolesCorruptedBanner.tsx +9 -4
- package/src/modules/auth/components/LoginScreen.tsx +4 -1
- package/src/modules/auth/services/account.api.ts +28 -1
- package/src/modules/auth/services/sso.ts +1 -2
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.sync-banner.test.tsx +176 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +68 -0
- package/src/modules/change-requests/__tests__/ChangeRequestLink.test.tsx +182 -0
- package/src/modules/change-requests/__tests__/FileChangeBoxes.test.tsx +1 -1
- package/src/modules/change-requests/__tests__/readFileOnBranch.test.ts +79 -0
- package/src/modules/change-requests/components/ChangeBox.tsx +6 -1
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +45 -15
- package/src/modules/change-requests/components/ChangeRequestLink.tsx +151 -0
- package/src/modules/change-requests/components/CrFileTree.tsx +2 -1
- package/src/modules/change-requests/components/FileChangeBoxes.tsx +4 -2
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +6 -3
- package/src/modules/change-requests/services/change-requests.api.ts +15 -2
- package/src/modules/change-requests/utils/readFailure.ts +22 -0
- package/src/modules/embed/__tests__/EmbedLinkPage.test.tsx +74 -0
- package/src/modules/embed/__tests__/EmbedView.test.tsx +473 -0
- package/src/modules/embed/__tests__/embed-config.test.ts +128 -0
- package/src/modules/embed/__tests__/embed-host.test.ts +111 -0
- package/src/modules/embed/__tests__/mcp-app-view.test.ts +295 -0
- package/src/modules/embed/__tests__/mount.test.tsx +157 -0
- package/src/modules/embed/components/EmbedLinkPage.tsx +109 -0
- package/src/modules/embed/components/EmbedView.tsx +545 -0
- package/src/modules/embed/embed-config.ts +132 -0
- package/src/modules/embed/embed-host.ts +120 -0
- package/src/modules/embed/mount.tsx +80 -0
- package/src/modules/embed/services/embed-token.ts +22 -0
- package/src/modules/embed/services/embed.api.ts +158 -0
- package/src/modules/git/__tests__/BranchSwitcher.test.tsx +202 -4
- package/src/modules/git/__tests__/GitSyncFailedBanner.test.tsx +59 -1
- package/src/modules/git/__tests__/PullNeededBanner.test.tsx +39 -22
- package/src/modules/git/__tests__/useAutoPullUpdates.test.tsx +7 -2
- package/src/modules/git/branch-delete-menu-item.tsx +24 -0
- package/src/modules/git/components/BranchSwitcher.tsx +29 -5
- package/src/modules/git/components/GitSyncFailedBanner.tsx +53 -15
- package/src/modules/git/components/HistoryVersionPreview.tsx +5 -3
- package/src/modules/git/components/PullNeededBanner.tsx +15 -49
- package/src/modules/git/hooks/useAutoPullUpdates.ts +9 -5
- package/src/modules/git/index.ts +15 -0
- package/src/modules/git/services/__tests__/error-messages.test.ts +67 -0
- package/src/modules/git/services/__tests__/pull-failure.test.ts +36 -0
- package/src/modules/git/services/error-messages.ts +58 -1
- package/src/modules/git/services/pull-failure.ts +68 -0
- package/src/modules/git/state/branch-delete-confirm.ts +46 -0
- package/src/modules/layout/__tests__/HeaderAlignment.test.tsx +1 -0
- package/src/modules/layout/__tests__/breakpoints.test.ts +7 -1
- package/src/modules/layout/breakpoints.ts +8 -0
- package/src/modules/library/__tests__/PluginExtras.test.tsx +9 -9
- package/src/modules/library/__tests__/PluginPage.test.tsx +8 -1
- package/src/modules/library/__tests__/SkillsTree.test.tsx +13 -4
- package/src/modules/library/__tests__/ToolPage.test.tsx +53 -0
- package/src/modules/library/components/LibraryPage.tsx +22 -0
- package/src/modules/library/components/PluginExtras.tsx +23 -6
- package/src/modules/library/components/PluginPage.tsx +6 -1
- package/src/modules/library/components/tool-page/ToolPage.tsx +45 -1
- package/src/modules/library/routes/LibraryRoutes.tsx +8 -7
- package/src/modules/library/services/plugins.api.ts +4 -1
- package/src/modules/library/services/tools.api.ts +27 -0
- package/src/modules/library/state/plugins-revision.ts +28 -0
- package/src/modules/onboarding/__tests__/agent-connection-api.test.ts +55 -0
- package/src/modules/onboarding/__tests__/creator-welcome.test.tsx +87 -82
- package/src/modules/onboarding/__tests__/first-page-prompt.test.ts +109 -0
- package/src/modules/onboarding/__tests__/get-started-column.test.tsx +1001 -0
- package/src/modules/onboarding/__tests__/invite-dialog.test.tsx +392 -0
- package/src/modules/onboarding/__tests__/onboarding.test.tsx +226 -193
- package/src/modules/onboarding/__tests__/starter-pack-card.test.tsx +136 -0
- package/src/modules/onboarding/components/CreatorWelcomePage.tsx +7 -11
- package/src/modules/onboarding/components/EmailChipsInput.tsx +138 -0
- package/src/modules/onboarding/components/GetStartedColumn.tsx +651 -0
- package/src/modules/onboarding/components/InviteButton.tsx +35 -0
- package/src/modules/onboarding/components/InviteDialog.tsx +424 -0
- package/src/modules/onboarding/components/RootLanding.tsx +8 -24
- package/src/modules/onboarding/components/StarterPackCard.tsx +98 -0
- package/src/modules/onboarding/components/WelcomePage.tsx +65 -154
- package/src/modules/onboarding/first-page-prompt.ts +89 -0
- package/src/modules/onboarding/invite-emails.ts +175 -0
- package/src/modules/onboarding/services/agent-connection.api.ts +53 -0
- package/src/modules/onboarding/services/starter-packs.api.ts +83 -0
- package/src/modules/onboarding/state/agent-connection.ts +167 -0
- package/src/modules/onboarding/state/invite-dialog.context.ts +32 -0
- package/src/modules/onboarding/state/invite-dialog.tsx +31 -0
- package/src/modules/onboarding/state/onboarding.ts +133 -59
- package/src/modules/onboarding/state/starter-packs.ts +169 -0
- package/src/modules/settings/settings-nav-items.tsx +8 -3
- package/src/modules/setup/__tests__/setup.first-run-storage.test.tsx +389 -0
- package/src/modules/setup/__tests__/setup.github.test.tsx +5 -5
- package/src/modules/setup/__tests__/setup.kept-draft.test.tsx +1 -1
- package/src/modules/setup/__tests__/setup.repository-change.test.tsx +1 -1
- package/src/modules/setup/__tests__/setup.repository.test.tsx +21 -21
- package/src/modules/setup/__tests__/setup.test.tsx +65 -81
- package/src/modules/setup/__tests__/useConnectionProbe.test.tsx +123 -0
- package/src/modules/setup/components/FirstRunStorage.tsx +560 -0
- package/src/modules/setup/components/SetupGate.tsx +46 -1
- package/src/modules/setup/components/SetupScreen.tsx +92 -152
- package/src/modules/setup/hooks/useConnectionProbe.ts +93 -0
- package/src/modules/setup/services/setup.api.ts +3 -3
- package/src/modules/setup/utils/suggested-branch.ts +27 -0
- package/src/modules/toolbar/commands/__tests__/actions.test.tsx +210 -0
- package/src/modules/toolbar/commands/actions.tsx +324 -0
- package/src/modules/toolbar/commands/command-menu.ts +44 -0
- package/src/modules/toolbar/commands/useCommandActions.ts +69 -0
- package/src/modules/toolbar/commands/useCommandShortcuts.ts +121 -0
- package/src/modules/toolbar/components/AppSwitcher.tsx +106 -22
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +1 -1
- package/src/modules/toolbar/components/ProfileMenu.tsx +9 -4
- package/src/modules/toolbar/components/SearchPalette.tsx +540 -0
- package/src/modules/toolbar/components/Toolbar.tsx +10 -0
- package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +187 -54
- package/src/modules/toolbar/components/__tests__/ExternalAgentAccessPage.test.tsx +4 -4
- package/src/modules/toolbar/components/__tests__/ProfileMenu.test.tsx +64 -0
- package/src/modules/toolbar/components/__tests__/SearchPalette.test.tsx +832 -0
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +57 -2
- package/src/modules/toolbar/search/__tests__/rank.test.ts +93 -0
- package/src/modules/toolbar/search/__tests__/sources.test.ts +131 -0
- package/src/modules/toolbar/search/rank.ts +111 -0
- package/src/modules/toolbar/search/sources.ts +169 -0
- package/src/modules/workflow/hooks/useFileLock.ts +10 -7
- package/src/modules/workflow/services/__tests__/lock.api.test.ts +41 -0
- package/src/modules/workflow/services/lock.api.ts +17 -2
- package/src/modules/workspace/__tests__/useWorkspaceState.test.ts +49 -1
- package/src/modules/workspace/components/EditorTabs.tsx +39 -15
- package/src/modules/workspace/components/FileExplorer.tsx +39 -6
- package/src/modules/workspace/components/FilePaneCard.tsx +6 -2
- package/src/modules/workspace/components/FileRoute.tsx +12 -7
- package/src/modules/workspace/components/FileViewer.tsx +271 -74
- package/src/modules/workspace/components/KbPageHeader.tsx +13 -6
- package/src/modules/workspace/components/__tests__/EditorTabs.test.tsx +88 -21
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +101 -11
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +23 -3
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +330 -6
- package/src/modules/workspace/components/__tests__/KbPageHeader.test.tsx +17 -2
- package/src/modules/workspace/components/renderers/DocxRenderer.tsx +11 -16
- package/src/modules/workspace/components/renderers/DownloadFileButton.tsx +6 -0
- package/src/modules/workspace/components/renderers/EmailRenderer.tsx +23 -21
- package/src/modules/workspace/components/renderers/ImageRenderer.tsx +13 -29
- package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +9 -2
- package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +8 -0
- package/src/modules/workspace/components/renderers/PdfRenderer.tsx +14 -19
- package/src/modules/workspace/components/renderers/PptxRenderer.tsx +11 -17
- package/src/modules/workspace/components/renderers/ToolRenderer.tsx +35 -7
- package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +11 -17
- package/src/modules/workspace/components/renderers/__tests__/EmailRenderer.links.test.tsx +73 -0
- package/src/modules/workspace/components/renderers/__tests__/ToolRenderer.scaffold.test.tsx +64 -0
- package/src/modules/workspace/components/renderers/__tests__/ToolRenderer.surface.test.tsx +82 -0
- package/src/modules/workspace/components/renderers/__tests__/bridgeHarness.ts +99 -0
- package/src/modules/workspace/components/renderers/__tests__/htmlSandbox.test.ts +129 -35
- package/src/modules/workspace/components/renderers/__tests__/htmlViewsGuide.test.ts +149 -0
- package/src/modules/workspace/components/renderers/__tests__/kbMarkdownLinkPolicy.test.tsx +100 -0
- package/src/modules/workspace/components/renderers/htmlSandbox.ts +76 -20
- package/src/modules/workspace/components/renderers/index.ts +26 -0
- package/src/modules/workspace/components/renderers/kbMarkdownPipeline.tsx +51 -1
- package/src/modules/workspace/components/renderers/rendererRawRead.ts +53 -0
- package/src/modules/workspace/components/renderers/rendererSurface.ts +109 -0
- package/src/modules/workspace/components/renderers/rendererWorkspace.ts +8 -2
- package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +126 -21
- package/src/modules/workspace/hooks/useCreatePage.ts +116 -0
- package/src/modules/workspace/hooks/useWorkspaceImageResolver.ts +24 -7
- package/src/modules/workspace/hooks/useWorkspaceState.ts +42 -8
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +10 -0
- package/src/modules/workspace/routing/__tests__/md-links-parity.test.tsx +113 -0
- package/src/modules/workspace/routing/kb-routes.ts +66 -12
- package/src/modules/workspace/state/editable-page.ts +42 -0
- package/src/modules/workspace/state/workspace.context.ts +13 -4
- package/src/modules/workspace/utils/__tests__/display-file-name.test.ts +60 -0
- package/src/modules/workspace/utils/__tests__/fileTree.test.ts +75 -0
- package/src/modules/workspace/utils/__tests__/treeConfirm.test.ts +26 -14
- package/src/modules/workspace/utils/display-file-name.ts +102 -0
- package/src/modules/workspace/utils/fileTree.ts +49 -14
- package/src/modules/workspace/utils/treeConfirm.ts +22 -5
- package/src/shared/__tests__/no-builtin-confirm.test.ts +102 -0
- package/src/shared/components/ConfirmProvider.tsx +156 -0
- package/src/shared/components/Dialog.tsx +7 -0
- package/src/shared/components/__tests__/ConfirmProvider.test.tsx +198 -0
- package/src/shared/components/confirm-context.ts +94 -0
- package/src/shared/components/index.ts +3 -0
- package/src/shared/mcp/__tests__/connect-snippets.test.ts +2 -2
- package/src/shared/mcp/connect-snippets.ts +8 -5
- package/src/modules/onboarding/components/WelcomeRoute.tsx +0 -57
- package/src/modules/onboarding/welcome-state.ts +0 -36
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
+
import userEvent from '@testing-library/user-event';
|
|
4
|
+
import { AuthContext } from '../../auth/state/auth.context';
|
|
5
|
+
import { authValue } from '../../library/__tests__/auth-harness';
|
|
6
|
+
import { WorkspaceContext } from '../../workspace/state/workspace.context';
|
|
7
|
+
import { makeWorkspaceFixture } from '../../workspace/__tests__/testFixtures';
|
|
8
|
+
import { StarterPackCard } from '../components/StarterPackCard';
|
|
9
|
+
import {
|
|
10
|
+
StarterPackApiError,
|
|
11
|
+
type StarterPackApplied,
|
|
12
|
+
type StarterPackSummary,
|
|
13
|
+
type StarterPacksAnswer,
|
|
14
|
+
} from '../services/starter-packs.api';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* "What does your team do?": one chip per pack, a choice that posts and
|
|
18
|
+
* fetches the tree again before handing over, a skip, and a refusal said on
|
|
19
|
+
* the card in the server's words.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const { fetchMock, chooseMock } = vi.hoisted(() => ({
|
|
23
|
+
fetchMock: vi.fn<() => Promise<StarterPacksAnswer>>(),
|
|
24
|
+
chooseMock: vi.fn<(id: string) => Promise<StarterPackApplied>>(),
|
|
25
|
+
}));
|
|
26
|
+
vi.mock('../services/starter-packs.api', async (importOriginal) => ({
|
|
27
|
+
...(await importOriginal<typeof import('../services/starter-packs.api')>()),
|
|
28
|
+
fetchStarterPacks: fetchMock,
|
|
29
|
+
chooseStarterPack: chooseMock,
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
const PACKS: StarterPackSummary[] = [
|
|
33
|
+
{ id: 'engineering', name: 'Engineering', description: 'Pages about how you build.', order: 1 },
|
|
34
|
+
{ id: 'sales', name: 'Sales', description: 'Pages about what you sell.', order: 2 },
|
|
35
|
+
{ id: 'general', name: 'Something else', description: 'Pages about who you are.', order: 99 },
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
function mount(refreshFileTree = vi.fn(async () => null)) {
|
|
39
|
+
const onDone = vi.fn();
|
|
40
|
+
render(
|
|
41
|
+
<AuthContext.Provider value={authValue()}>
|
|
42
|
+
<WorkspaceContext.Provider value={makeWorkspaceFixture({ refreshFileTree })}>
|
|
43
|
+
<StarterPackCard packs={PACKS} onDone={onDone} />
|
|
44
|
+
</WorkspaceContext.Provider>
|
|
45
|
+
</AuthContext.Provider>,
|
|
46
|
+
);
|
|
47
|
+
return { onDone, refreshFileTree };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Every mount signs in afresh (`authValue()` makes a new user), and the
|
|
51
|
+
// starter answer is kept per signed-in user: no test sees another's.
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
fetchMock.mockReset().mockResolvedValue({ offered: false, chosen: 'sales', packs: [], chosenPack: null });
|
|
54
|
+
chooseMock.mockReset();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe('StarterPackCard', () => {
|
|
58
|
+
it('asks the question with a chip per pack, in order, and a quiet skip', () => {
|
|
59
|
+
mount();
|
|
60
|
+
expect(screen.getByRole('heading', { name: 'What does your team do?' })).toBeInTheDocument();
|
|
61
|
+
expect(screen.getByText('We’ll add starter pages and skills that fit.')).toBeInTheDocument();
|
|
62
|
+
const chips = screen.getAllByRole('button').map((b) => b.textContent);
|
|
63
|
+
expect(chips).toEqual(['Engineering', 'Sales', 'Something else', 'Skip, I’ll start from scratch']);
|
|
64
|
+
expect(screen.getByRole('button', { name: 'Sales' })).toHaveAttribute('title', 'Pages about what you sell.');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('choosing posts the pack, says it is adding, refreshes the tree and hands over what was added', async () => {
|
|
68
|
+
let finish!: (applied: StarterPackApplied) => void;
|
|
69
|
+
chooseMock.mockImplementation(() => new Promise((resolve) => (finish = resolve)));
|
|
70
|
+
let treeRefreshed!: () => void;
|
|
71
|
+
const { onDone, refreshFileTree } = mount(vi.fn(() => new Promise<null>((resolve) => (treeRefreshed = () => resolve(null)))));
|
|
72
|
+
await waitFor(() => expect(fetchMock).toHaveBeenCalledTimes(1));
|
|
73
|
+
|
|
74
|
+
await userEvent.click(screen.getByRole('button', { name: 'Sales' }));
|
|
75
|
+
|
|
76
|
+
expect(chooseMock).toHaveBeenCalledWith('sales');
|
|
77
|
+
expect(screen.getByRole('button', { name: 'Adding…' })).toBeDisabled();
|
|
78
|
+
expect(screen.getByRole('button', { name: 'Engineering' })).toBeDisabled();
|
|
79
|
+
expect(screen.getByRole('button', { name: /Skip/ })).toBeDisabled();
|
|
80
|
+
expect(screen.getByRole('status')).toHaveTextContent('Adding starter pages and skills for Sales…');
|
|
81
|
+
|
|
82
|
+
const applied = { id: 'sales', name: 'Sales', pages: 6, skills: 37, summary: 'Added 6 pages and 37 skills for Sales.' };
|
|
83
|
+
finish(applied);
|
|
84
|
+
await waitFor(() => expect(refreshFileTree).toHaveBeenCalledTimes(1));
|
|
85
|
+
// The tree comes first: nothing is handed over, and the answer is not
|
|
86
|
+
// read again, until the pages are in it.
|
|
87
|
+
expect(onDone).not.toHaveBeenCalled();
|
|
88
|
+
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
89
|
+
treeRefreshed();
|
|
90
|
+
await waitFor(() => expect(onDone).toHaveBeenCalledWith(applied));
|
|
91
|
+
// The answer is read again, so the prompt and the card follow the choice.
|
|
92
|
+
expect(fetchMock).toHaveBeenCalledTimes(2);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('skipping posts "none", says so, and has no tree to refresh', async () => {
|
|
96
|
+
let finish!: (applied: StarterPackApplied) => void;
|
|
97
|
+
chooseMock.mockImplementation(() => new Promise((resolve) => (finish = resolve)));
|
|
98
|
+
const { onDone, refreshFileTree } = mount();
|
|
99
|
+
|
|
100
|
+
await userEvent.click(screen.getByRole('button', { name: 'Skip, I’ll start from scratch' }));
|
|
101
|
+
|
|
102
|
+
expect(chooseMock).toHaveBeenCalledWith('none');
|
|
103
|
+
const skip = screen.getByRole('button', { name: 'Skipping…' });
|
|
104
|
+
expect(skip).toBeDisabled();
|
|
105
|
+
expect(skip).toHaveAttribute('aria-busy', 'true');
|
|
106
|
+
expect(screen.getByRole('status')).toHaveTextContent('Skipping…');
|
|
107
|
+
|
|
108
|
+
finish({ id: 'none', name: null, pages: 0, skills: 0, summary: '' });
|
|
109
|
+
await waitFor(() => expect(onDone).toHaveBeenCalled());
|
|
110
|
+
expect(refreshFileTree).not.toHaveBeenCalled();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('reads the answer again when the question was answered elsewhere, so the card can go', async () => {
|
|
114
|
+
chooseMock.mockRejectedValueOnce(new StarterPackApiError('Starter pages were already chosen for this knowledge base.', 409));
|
|
115
|
+
mount();
|
|
116
|
+
await waitFor(() => expect(fetchMock).toHaveBeenCalledTimes(1));
|
|
117
|
+
|
|
118
|
+
await userEvent.click(screen.getByRole('button', { name: 'Engineering' }));
|
|
119
|
+
|
|
120
|
+
expect(await screen.findByRole('alert')).toHaveTextContent('already chosen');
|
|
121
|
+
expect(fetchMock).toHaveBeenCalledTimes(2);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('says a refusal on the card and lets the admin try again', async () => {
|
|
125
|
+
chooseMock.mockRejectedValueOnce(
|
|
126
|
+
new StarterPackApiError('Someone is editing the knowledge base right now. Try again in a moment.', 409),
|
|
127
|
+
);
|
|
128
|
+
const { onDone } = mount();
|
|
129
|
+
|
|
130
|
+
await userEvent.click(screen.getByRole('button', { name: 'Engineering' }));
|
|
131
|
+
|
|
132
|
+
expect(await screen.findByRole('alert')).toHaveTextContent('Someone is editing the knowledge base right now.');
|
|
133
|
+
expect(onDone).not.toHaveBeenCalled();
|
|
134
|
+
expect(screen.getByRole('button', { name: 'Engineering' })).toBeEnabled();
|
|
135
|
+
});
|
|
136
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo, useState } from 'react';
|
|
2
2
|
import { Sparkles, Users } from 'lucide-react';
|
|
3
3
|
import { Button, Dialog, Surface } from '../../../shared/components';
|
|
4
4
|
import { useAuth } from '../../auth/state/auth.context';
|
|
@@ -6,19 +6,21 @@ import { NewPluginDialog } from '../../library/components/NewPluginDialog';
|
|
|
6
6
|
import { NewSkillPanel } from '../../library/components/NewSkillPanel';
|
|
7
7
|
import { useLibrary } from '../../library/state/library-data';
|
|
8
8
|
import { displayFirstName } from '../../library/utils/personal-plugin';
|
|
9
|
-
import { useOnboarding } from '../state/onboarding';
|
|
10
9
|
|
|
11
10
|
/**
|
|
12
|
-
* The first useful screen in an empty deployment
|
|
11
|
+
* The first useful screen in an empty deployment: Skills & Tools' empty state
|
|
12
|
+
* for an admin. `LibraryPage` shows it in place of the Everything gallery
|
|
13
|
+
* while the catalog holds no plugins and no skills or tools.
|
|
13
14
|
*
|
|
14
15
|
* A regular account needs to connect an agent before the library becomes
|
|
15
16
|
* useful. The first admin has a different job: make the shared structure that
|
|
16
17
|
* everyone else will find. This page offers the two smallest real beginnings,
|
|
17
|
-
* using the same plugin and skill creation flows available everywhere else
|
|
18
|
+
* using the same plugin and skill creation flows available everywhere else —
|
|
19
|
+
* and once either exists, the catalog is no longer empty and the gallery is
|
|
20
|
+
* back.
|
|
18
21
|
*/
|
|
19
22
|
export function CreatorWelcomePage() {
|
|
20
23
|
const { user } = useAuth();
|
|
21
|
-
const onboarding = useOnboarding();
|
|
22
24
|
const data = useLibrary();
|
|
23
25
|
const [newPluginOpen, setNewPluginOpen] = useState(false);
|
|
24
26
|
const [newSkillOpen, setNewSkillOpen] = useState(false);
|
|
@@ -31,12 +33,6 @@ export function CreatorWelcomePage() {
|
|
|
31
33
|
*/
|
|
32
34
|
const [newSkillBusy, setNewSkillBusy] = useState(false);
|
|
33
35
|
|
|
34
|
-
const { markWelcomed } = onboarding;
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
markWelcomed();
|
|
37
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps -- one idempotent welcome record per mount
|
|
38
|
-
}, []);
|
|
39
|
-
|
|
40
36
|
const pluginNames = useMemo(
|
|
41
37
|
() => [
|
|
42
38
|
...new Set([
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { useRef, type ClipboardEvent, type KeyboardEvent } from 'react';
|
|
2
|
+
import { X } from 'lucide-react';
|
|
3
|
+
import { cn } from '../../../lib/utils';
|
|
4
|
+
import { isValidEmail, splitEmails } from '../invite-emails';
|
|
5
|
+
|
|
6
|
+
/** `current` plus whatever of `added` it does not already hold, in order. */
|
|
7
|
+
function withAdded(current: string[], added: string[]): string[] {
|
|
8
|
+
const next = [...current];
|
|
9
|
+
for (const email of added) if (!next.includes(email)) next.push(email);
|
|
10
|
+
return next;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface EmailChipsInputProps {
|
|
14
|
+
/** Labels the text input (pair with a `<label htmlFor>`). */
|
|
15
|
+
id: string;
|
|
16
|
+
emails: string[];
|
|
17
|
+
onEmailsChange(next: string[]): void;
|
|
18
|
+
/** The text not yet turned into a chip. Controlled, so a submit can include it. */
|
|
19
|
+
draft: string;
|
|
20
|
+
onDraftChange(next: string): void;
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
/** Id of the hint below the field. */
|
|
23
|
+
'aria-describedby'?: string;
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* An address field that turns what you type into chips: Enter or a comma
|
|
29
|
+
* after each address, or paste a whole list at once. Backspace in an empty
|
|
30
|
+
* field takes the last chip back. An address that cannot be one stays on
|
|
31
|
+
* screen in the danger tone rather than vanishing — the person typed it,
|
|
32
|
+
* and the fix is theirs to see.
|
|
33
|
+
*
|
|
34
|
+
* Borrows Manage access's chip picker look (a TextField that grew chips), but
|
|
35
|
+
* not its code: that one picks principals from suggestions, this one only
|
|
36
|
+
* ever holds addresses.
|
|
37
|
+
*/
|
|
38
|
+
export function EmailChipsInput({
|
|
39
|
+
id,
|
|
40
|
+
emails,
|
|
41
|
+
onEmailsChange,
|
|
42
|
+
draft,
|
|
43
|
+
onDraftChange,
|
|
44
|
+
placeholder,
|
|
45
|
+
'aria-describedby': describedBy,
|
|
46
|
+
disabled = false,
|
|
47
|
+
}: EmailChipsInputProps) {
|
|
48
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
49
|
+
|
|
50
|
+
function commit(text: string) {
|
|
51
|
+
const added = splitEmails(text);
|
|
52
|
+
if (added.length > 0) onEmailsChange(withAdded(emails, added));
|
|
53
|
+
onDraftChange('');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function onKeyDown(e: KeyboardEvent<HTMLInputElement>) {
|
|
57
|
+
if ((e.key === 'Enter' || e.key === ',' || e.key === ';') && draft.trim()) {
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
commit(draft);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (e.key === 'Backspace' && draft === '' && emails.length > 0) {
|
|
63
|
+
e.preventDefault();
|
|
64
|
+
onEmailsChange(emails.slice(0, -1));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// A single pasted address is ordinary typing; a LIST becomes chips at once,
|
|
69
|
+
// so pasting thirty addresses does not leave one thirty-address chip.
|
|
70
|
+
function onPaste(e: ClipboardEvent<HTMLInputElement>) {
|
|
71
|
+
const text = e.clipboardData.getData('text');
|
|
72
|
+
if (!/[\s,;<]/.test(text.trim())) return;
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
commit(`${draft} ${text}`);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
// The box, not just the input, is the click target: clicking between
|
|
79
|
+
// chips should land the caret where the next address goes.
|
|
80
|
+
<div
|
|
81
|
+
className={cn(
|
|
82
|
+
'flex w-full cursor-text flex-wrap items-center gap-1.5 rounded-md border border-line-strong bg-surface px-2 py-1.5',
|
|
83
|
+
'focus-within:border-transparent focus-within:outline-2 focus-within:-outline-offset-1 focus-within:outline-accent',
|
|
84
|
+
disabled && 'cursor-not-allowed opacity-50',
|
|
85
|
+
)}
|
|
86
|
+
onClick={() => inputRef.current?.focus()}
|
|
87
|
+
>
|
|
88
|
+
{emails.map((email) => {
|
|
89
|
+
const valid = isValidEmail(email);
|
|
90
|
+
return (
|
|
91
|
+
<span
|
|
92
|
+
key={email}
|
|
93
|
+
className={cn(
|
|
94
|
+
'inline-flex min-w-0 max-w-full items-center gap-1 rounded-full py-0.5 pl-2 pr-1 text-detail',
|
|
95
|
+
valid ? 'bg-sunken text-ink' : 'bg-danger-soft text-danger',
|
|
96
|
+
)}
|
|
97
|
+
title={valid ? email : `${email} is not an email address`}
|
|
98
|
+
>
|
|
99
|
+
<span className="min-w-0 truncate">{email}</span>
|
|
100
|
+
{!valid && <span className="sr-only">(not an email address)</span>}
|
|
101
|
+
<button
|
|
102
|
+
type="button"
|
|
103
|
+
disabled={disabled}
|
|
104
|
+
onClick={(e) => {
|
|
105
|
+
e.stopPropagation();
|
|
106
|
+
onEmailsChange(emails.filter((x) => x !== email));
|
|
107
|
+
inputRef.current?.focus();
|
|
108
|
+
}}
|
|
109
|
+
className="flex size-4 shrink-0 items-center justify-center rounded-full text-ink-faint hover:bg-hover hover:text-ink"
|
|
110
|
+
aria-label={`Remove ${email}`}
|
|
111
|
+
>
|
|
112
|
+
<X size={10} aria-hidden />
|
|
113
|
+
</button>
|
|
114
|
+
</span>
|
|
115
|
+
);
|
|
116
|
+
})}
|
|
117
|
+
<input
|
|
118
|
+
ref={inputRef}
|
|
119
|
+
id={id}
|
|
120
|
+
value={draft}
|
|
121
|
+
disabled={disabled}
|
|
122
|
+
onChange={(e) => onDraftChange(e.target.value)}
|
|
123
|
+
onKeyDown={onKeyDown}
|
|
124
|
+
onPaste={onPaste}
|
|
125
|
+
// Leaving the field keeps what was typed: a person who types one
|
|
126
|
+
// address and reaches for the role select has not abandoned it.
|
|
127
|
+
onBlur={() => {
|
|
128
|
+
if (draft.trim()) commit(draft);
|
|
129
|
+
}}
|
|
130
|
+
placeholder={emails.length > 0 ? 'Add more…' : placeholder}
|
|
131
|
+
autoComplete="off"
|
|
132
|
+
spellCheck={false}
|
|
133
|
+
aria-describedby={describedBy}
|
|
134
|
+
className="min-w-40 flex-1 bg-transparent px-1 py-0.5 text-ui text-ink placeholder:text-ink-faint focus:outline-none"
|
|
135
|
+
/>
|
|
136
|
+
</div>
|
|
137
|
+
);
|
|
138
|
+
}
|