@bevel-software/platform-core-frontend 0.26.0 → 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/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/routes/LibraryRoutes.tsx +8 -7
- package/src/modules/library/services/plugins.api.ts +4 -1
- 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 +56 -15
- 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 +81 -84
- 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__/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 +92 -4
- 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 +16 -0
- 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 +15 -0
- 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/modules/onboarding/components/WelcomeRoute.tsx +0 -57
- package/src/modules/onboarding/welcome-state.ts +0 -36
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
} from '../state/auto-update.context';
|
|
7
7
|
import type { WorkspaceContextValue } from '../../workspace/state/workspace.context';
|
|
8
8
|
import { sanitizeErrorText } from '../services/error-messages';
|
|
9
|
+
import { pullFailureDetail } from '../services/pull-failure';
|
|
9
10
|
import { PR_STALE_EVENT } from '../../../core/events';
|
|
10
11
|
|
|
11
12
|
export function useAutoPullUpdates(
|
|
@@ -63,15 +64,18 @@ export function useAutoPullUpdates(
|
|
|
63
64
|
await pull();
|
|
64
65
|
} catch (err) {
|
|
65
66
|
if (cancelled) return;
|
|
66
|
-
|
|
67
|
+
// What the banner shows under "Couldn’t get the latest changes": the
|
|
68
|
+
// reader's words for it, not the sanitized error, which still speaks git.
|
|
67
69
|
setAutoUpdate({
|
|
68
70
|
status: 'failed',
|
|
69
71
|
branch: status.branch,
|
|
70
|
-
reason:
|
|
72
|
+
reason: pullFailureDetail(err) ?? 'Something unexpected went wrong.',
|
|
71
73
|
});
|
|
72
|
-
//
|
|
73
|
-
//
|
|
74
|
-
|
|
74
|
+
// The log keeps git's own words, scrubbed: that is the diagnostic, and
|
|
75
|
+
// the summary above would fold distinct failures into one sentence.
|
|
76
|
+
// Only the sanitized text — raw err.message can contain urls, tokens,
|
|
77
|
+
// or local paths.
|
|
78
|
+
console.debug('[git] auto-pull skipped:', sanitizeErrorText(err), {
|
|
75
79
|
branch: status.branch,
|
|
76
80
|
});
|
|
77
81
|
return;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git's public surface for the shell: what git contributes to the app outside
|
|
3
|
+
* its own components. Other modules compose these through the shell rather
|
|
4
|
+
* than reaching into git's files.
|
|
5
|
+
*/
|
|
6
|
+
import type { AdminMenuItem } from '../../core/registry';
|
|
7
|
+
import { BRANCH_DELETE_CONFIRM_MENU_ITEM } from './branch-delete-menu-item';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Git's profile-menu rows, merged into the registry by the shell
|
|
11
|
+
* (`withCoreModuleContributions`) ahead of registry-contributed rows. Today
|
|
12
|
+
* only "Ask before deleting branches", shown while this person's
|
|
13
|
+
* branch-delete question is off.
|
|
14
|
+
*/
|
|
15
|
+
export const GIT_MENU_ITEMS: readonly AdminMenuItem[] = [BRANCH_DELETE_CONFIRM_MENU_ITEM];
|
|
@@ -2,6 +2,7 @@ import { describe, it, expect } from 'vitest';
|
|
|
2
2
|
import { GitApiError } from '../git.api';
|
|
3
3
|
import {
|
|
4
4
|
friendlyGitError,
|
|
5
|
+
friendlyGitMessage,
|
|
5
6
|
parseGitError,
|
|
6
7
|
NO_SHARED_HISTORY_KIND,
|
|
7
8
|
NO_SHARED_HISTORY_RECOVERY_PROMPT,
|
|
@@ -111,6 +112,72 @@ describe('friendlyGitError: translates raw backend git messages', () => {
|
|
|
111
112
|
});
|
|
112
113
|
});
|
|
113
114
|
|
|
115
|
+
describe('friendlyGitMessage: a change request that lands reads as published', () => {
|
|
116
|
+
it('says a refused apply in publish words, keeping the reasons', () => {
|
|
117
|
+
expect(
|
|
118
|
+
friendlyGitMessage(
|
|
119
|
+
'Merge gate rejected: Waiting on approval for Docs/a.md from Owners.; Ali need to re-approve Docs/b.md after the latest push.',
|
|
120
|
+
),
|
|
121
|
+
).toBe(
|
|
122
|
+
"Can't publish this yet. Waiting on approval for Docs/a.md from Owners.; Ali must re-approve Docs/b.md after the latest changes.",
|
|
123
|
+
);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it('keeps every separator where it was, since a reason can carry one of its own', () => {
|
|
127
|
+
// A role and a named approver on one file are joined by the same `; `
|
|
128
|
+
// the gate joins its reasons with; splitting on it would read as
|
|
129
|
+
// "Product Manager Bob".
|
|
130
|
+
expect(friendlyGitMessage('Merge gate rejected: Waiting on approval for Docs/a.md from Product Manager; Bob.')).toBe(
|
|
131
|
+
"Can't publish this yet. Waiting on approval for Docs/a.md from Product Manager; Bob.",
|
|
132
|
+
);
|
|
133
|
+
expect(friendlyGitMessage('Admin need to re-approve Docs/b.md after the latest push.')).toBe(
|
|
134
|
+
'Admin must re-approve Docs/b.md after the latest changes.',
|
|
135
|
+
);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('rewrites the merge outcomes and the bypass refusal', () => {
|
|
139
|
+
expect(friendlyGitMessage('Merge failed')).toBe("Couldn't publish this change.");
|
|
140
|
+
expect(friendlyGitMessage('Merge failed: the host refused the write')).toBe(
|
|
141
|
+
"Couldn't publish this change: the host refused the write",
|
|
142
|
+
);
|
|
143
|
+
expect(friendlyGitMessage('This change request has already been merged.')).toBe(
|
|
144
|
+
'This change request is already published.',
|
|
145
|
+
);
|
|
146
|
+
expect(
|
|
147
|
+
friendlyGitMessage(
|
|
148
|
+
'Only admins can merge with bypass. You need write access to roles.yaml on the base branch to skip approval warnings.',
|
|
149
|
+
),
|
|
150
|
+
).toBe('Only an admin can publish a change before everyone has approved it.');
|
|
151
|
+
expect(friendlyGitMessage('This draft conflicts with the target and needs resolving first.')).toBe(
|
|
152
|
+
"Files changed after this was proposed, so it can't be published as it is.",
|
|
153
|
+
);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('never leaves merge or push in what it returns for those messages', () => {
|
|
157
|
+
for (const raw of [
|
|
158
|
+
'Merge gate rejected: This pull request has already been merged.',
|
|
159
|
+
'Merge gate rejected: This pull request has no file changes to approve.',
|
|
160
|
+
'Ali need to re-approve Docs/b.md after the latest push.',
|
|
161
|
+
]) {
|
|
162
|
+
expect(friendlyGitMessage(raw)).not.toMatch(/merg|push|pull request/i);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('names who has access, not access.md, when nobody can approve a file', () => {
|
|
167
|
+
const said = friendlyGitMessage(
|
|
168
|
+
'No one is eligible to approve this file — broaden the access.md rules covering it first',
|
|
169
|
+
);
|
|
170
|
+
expect(said).toBe(
|
|
171
|
+
'No one can approve this file yet: nobody has edit access to its folder. Ask an admin to change who has access.',
|
|
172
|
+
);
|
|
173
|
+
expect(said).not.toContain('access.md');
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it('is what friendlyGitError says for the same text in an error', () => {
|
|
177
|
+
expect(friendlyGitError(new GitApiError(422, 'Merge failed'))).toBe("Couldn't publish this change.");
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
114
181
|
describe('parseGitError: structured form for actionable UIs', () => {
|
|
115
182
|
it('returns kind="plain" for arbitrary errors', () => {
|
|
116
183
|
const info = parseGitError(new Error('oops'));
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { describePullFailure, pullFailureDetail, pullFailurePhrase } from '../pull-failure';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* One sorting of a failed pull serves two readers: the sentence a person
|
|
6
|
+
* sees on the banner, and the phrase the change-request port hands the
|
|
7
|
+
* assistant. Both are checked here against git's own words, so neither can
|
|
8
|
+
* leak them.
|
|
9
|
+
*/
|
|
10
|
+
describe('a failed pull, sorted by what it was', () => {
|
|
11
|
+
const GIT_WORDS = /uncommitted|working tree|stash|HEAD|merge conflict|fatal|rebase/i;
|
|
12
|
+
|
|
13
|
+
it.each([
|
|
14
|
+
['CONFLICT (content): Merge conflict in Docs/a.md', 'two versions of the same file need to be reconciled', 'changed both here and by a teammate'],
|
|
15
|
+
['error: cannot pull with rebase: You have unstaged changes. working tree has uncommitted changes', 'there are local changes that need to be sorted out first', 'haven’t been saved to the knowledge base yet'],
|
|
16
|
+
['fatal: Authentication failed for https://example.com/org/repo', 'a connection or permission problem', 'couldn’t be reached, or refused this deployment'],
|
|
17
|
+
['fatal: could not resolve host example.com', 'a connection or permission problem', 'couldn’t be reached, or refused this deployment'],
|
|
18
|
+
['remote: HTTP Basic: Access denied. 403', 'a connection or permission problem', 'couldn’t be reached, or refused this deployment'],
|
|
19
|
+
])('%s', (raw, phrase, detail) => {
|
|
20
|
+
const err = new Error(raw);
|
|
21
|
+
expect(pullFailurePhrase(err)).toBe(phrase);
|
|
22
|
+
expect(pullFailureDetail(err)).toContain(detail);
|
|
23
|
+
expect(describePullFailure(err)).toMatch(/^Couldn’t get the latest changes\. /);
|
|
24
|
+
for (const said of [pullFailurePhrase(err), describePullFailure(err)]) {
|
|
25
|
+
expect(said).not.toMatch(GIT_WORDS);
|
|
26
|
+
expect(said).not.toContain('example.com');
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('says only that it failed when the words match nothing it knows', () => {
|
|
31
|
+
const err = new Error('boom');
|
|
32
|
+
expect(pullFailurePhrase(err)).toBe('something unexpected went wrong');
|
|
33
|
+
expect(pullFailureDetail(err)).toBeNull();
|
|
34
|
+
expect(describePullFailure(err)).toBe('Couldn’t get the latest changes.');
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -112,8 +112,16 @@ export function friendlyGitError(err: unknown): string {
|
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
return friendlyGitMessage(rawMessage(err));
|
|
116
|
+
}
|
|
116
117
|
|
|
118
|
+
/**
|
|
119
|
+
* The string half of {@link friendlyGitError}: a backend message, as text,
|
|
120
|
+
* in plain words. For the places a message reaches the UI as a string, not an
|
|
121
|
+
* error — an event's `reason`, a reason the server stored, a warning in a
|
|
122
|
+
* change request's detail.
|
|
123
|
+
*/
|
|
124
|
+
export function friendlyGitMessage(raw: string): string {
|
|
117
125
|
// Protected-branch rejections — `branch` is always quoted. Under the
|
|
118
126
|
// current model the agent's writes against the official versions are NOT
|
|
119
127
|
// hard-rejected on the name alone; path-level access control decides at
|
|
@@ -238,9 +246,58 @@ export function friendlyGitError(err: unknown): string {
|
|
|
238
246
|
return "Couldn't cancel this change request right now. Try again in a moment.";
|
|
239
247
|
}
|
|
240
248
|
|
|
249
|
+
// Applying a change request. The backend merges it and says so; what the
|
|
250
|
+
// reader cares about is whether it was published. Approving stays the
|
|
251
|
+
// reader's own act, so only the outcome is renamed.
|
|
252
|
+
const gate = raw.match(/^Merge gate rejected: (.+)$/s);
|
|
253
|
+
if (gate) return `Can't publish this yet. ${plainGateReasons(gate[1])}`;
|
|
254
|
+
if (raw === 'Merge failed') return "Couldn't publish this change.";
|
|
255
|
+
const mergeFailed = raw.match(/^Merge failed: (.+)$/s);
|
|
256
|
+
if (mergeFailed) return `Couldn't publish this change: ${mergeFailed[1]}`;
|
|
257
|
+
if (raw === 'This pull request has already been merged.' || raw === 'This change request has already been merged.') {
|
|
258
|
+
return 'This change request is already published.';
|
|
259
|
+
}
|
|
260
|
+
if (raw === 'This pull request is closed.') return 'This change request is closed.';
|
|
261
|
+
if (raw === 'This pull request has no file changes to approve.') {
|
|
262
|
+
return 'This change request changes no files, so there is nothing to publish.';
|
|
263
|
+
}
|
|
264
|
+
if (raw === 'This draft conflicts with the target and needs resolving first.') {
|
|
265
|
+
return "Files changed after this was proposed, so it can't be published as it is.";
|
|
266
|
+
}
|
|
267
|
+
if (/^Only admins can merge with bypass\./.test(raw)) {
|
|
268
|
+
return 'Only an admin can publish a change before everyone has approved it.';
|
|
269
|
+
}
|
|
270
|
+
if (/ need to re-approve .+ after the latest push\.$/s.test(raw)) return plainGateReasons(raw);
|
|
271
|
+
if (raw === 'change request not found') return 'That change request no longer exists.';
|
|
272
|
+
|
|
273
|
+
// Nobody can approve a file whose folder grants no one edit access. The
|
|
274
|
+
// server names the rules file; the reader needs the folder's access.
|
|
275
|
+
if (/^No one is eligible to approve this file/.test(raw)) {
|
|
276
|
+
return "No one can approve this file yet: nobody has edit access to its folder. Ask an admin to change who has access.";
|
|
277
|
+
}
|
|
278
|
+
|
|
241
279
|
return raw;
|
|
242
280
|
}
|
|
243
281
|
|
|
282
|
+
/**
|
|
283
|
+
* The merge gate's reasons in plain words. The backend joins them with `; `,
|
|
284
|
+
* and a reason can carry that same separator inside it (a role and a named
|
|
285
|
+
* approver), so they are not split apart and rejoined: each phrase is
|
|
286
|
+
* replaced where it stands, and every separator stays exactly where it was.
|
|
287
|
+
* "must" rather than "need", which reads right for one approver and for many.
|
|
288
|
+
*/
|
|
289
|
+
function plainGateReasons(reasons: string): string {
|
|
290
|
+
return reasons
|
|
291
|
+
.replace(/This (?:pull|change) request has already been merged\./g, 'This change request is already published.')
|
|
292
|
+
.replace(/This pull request is closed\./g, 'This change request is closed.')
|
|
293
|
+
.replace(
|
|
294
|
+
/This pull request has no file changes to approve\./g,
|
|
295
|
+
'This change request changes no files, so there is nothing to publish.',
|
|
296
|
+
)
|
|
297
|
+
.replace(/ need to re-approve /g, ' must re-approve ')
|
|
298
|
+
.replace(/ after the latest push\./g, ' after the latest changes.');
|
|
299
|
+
}
|
|
300
|
+
|
|
244
301
|
function rawMessage(err: unknown): string {
|
|
245
302
|
if (err instanceof GitApiError) return err.message;
|
|
246
303
|
if (err instanceof Error) return err.message;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { sanitizeErrorText } from './error-messages';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What a failed pull was about, read off the sanitized error. git's words are
|
|
5
|
+
* sorted into the four things a person can do something about, and both
|
|
6
|
+
* readers of a failure take their text from here: the sentence the banner
|
|
7
|
+
* shows, and the phrase the change-request port hands the assistant. One
|
|
8
|
+
* sorting, so the two cannot drift apart.
|
|
9
|
+
*/
|
|
10
|
+
export type PullFailureKind = 'conflict' | 'local-changes' | 'connection' | 'unknown';
|
|
11
|
+
|
|
12
|
+
export function pullFailureKind(error: unknown): PullFailureKind {
|
|
13
|
+
const sanitized = sanitizeErrorText(error).toLowerCase();
|
|
14
|
+
if (/\b(conflict|conflicts|merge conflict|would be overwritten)\b/.test(sanitized)) return 'conflict';
|
|
15
|
+
if (/\b(uncommitted|local changes|working tree|dirty|stash)\b/.test(sanitized)) return 'local-changes';
|
|
16
|
+
if (
|
|
17
|
+
/\b(network|auth(?:entication|orization)?|credential|permission denied|unauthorized|forbidden|timeout|timed out|could not resolve host|failed to connect|401|403)\b/.test(
|
|
18
|
+
sanitized,
|
|
19
|
+
)
|
|
20
|
+
) {
|
|
21
|
+
return 'connection';
|
|
22
|
+
}
|
|
23
|
+
return 'unknown';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The phrase the change-request port is handed. The enterprise registry
|
|
28
|
+
* splices it into the chat composer, where the user sees it, so it carries no
|
|
29
|
+
* git vocabulary — no "merge conflict", "uncommitted", "working tree",
|
|
30
|
+
* "stash", "HEAD". The assistant's own prompt knows the mechanics.
|
|
31
|
+
*/
|
|
32
|
+
export function pullFailurePhrase(error: unknown): string {
|
|
33
|
+
switch (pullFailureKind(error)) {
|
|
34
|
+
case 'conflict':
|
|
35
|
+
return 'two versions of the same file need to be reconciled';
|
|
36
|
+
case 'local-changes':
|
|
37
|
+
return 'there are local changes that need to be sorted out first';
|
|
38
|
+
case 'connection':
|
|
39
|
+
return 'a connection or permission problem';
|
|
40
|
+
default:
|
|
41
|
+
return 'something unexpected went wrong';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Why getting the latest changes failed, as a sentence a person reads under
|
|
47
|
+
* the banner's heading; null when nothing more is known than that it failed.
|
|
48
|
+
* Never the sanitized error itself: scrubbed of secrets it still speaks git
|
|
49
|
+
* ("working tree has uncommitted changes").
|
|
50
|
+
*/
|
|
51
|
+
export function pullFailureDetail(error: unknown): string | null {
|
|
52
|
+
switch (pullFailureKind(error)) {
|
|
53
|
+
case 'conflict':
|
|
54
|
+
return 'A page was changed both here and by a teammate, and the two versions need combining first.';
|
|
55
|
+
case 'local-changes':
|
|
56
|
+
return 'There are changes here that haven’t been saved to the knowledge base yet.';
|
|
57
|
+
case 'connection':
|
|
58
|
+
return 'Your git host couldn’t be reached, or refused this deployment. Check the connection and the repository access.';
|
|
59
|
+
default:
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** The whole alert: that it failed, and why when that is known. */
|
|
65
|
+
export function describePullFailure(error: unknown): string {
|
|
66
|
+
const detail = pullFailureDetail(error);
|
|
67
|
+
return detail ? `Couldn’t get the latest changes. ${detail}` : 'Couldn’t get the latest changes.';
|
|
68
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* "Don't ask again" for deleting a shared branch: remembered in this browser,
|
|
3
|
+
* for the person who ticked it, until they turn the question back on from the
|
|
4
|
+
* profile menu.
|
|
5
|
+
*
|
|
6
|
+
* Keyed by email — the admin page's "last seen" marker does the same — so a
|
|
7
|
+
* colleague signing in on the same browser is still asked. Every read and
|
|
8
|
+
* write is guarded: a browser that refuses storage (strict privacy mode, a
|
|
9
|
+
* full quota) reads as "ask", so the question can never be skipped by
|
|
10
|
+
* accident, only by the person's own tick.
|
|
11
|
+
*/
|
|
12
|
+
const KEY_PREFIX = 'hexis.skipBranchDeleteConfirm:';
|
|
13
|
+
|
|
14
|
+
function keyFor(email: string): string {
|
|
15
|
+
return KEY_PREFIX + email.trim().toLowerCase();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Whether this person turned the branch-delete question off in this browser. */
|
|
19
|
+
export function isBranchDeleteConfirmSkipped(email: string | null | undefined): boolean {
|
|
20
|
+
if (!email) return false;
|
|
21
|
+
try {
|
|
22
|
+
return localStorage.getItem(keyFor(email)) === '1';
|
|
23
|
+
} catch {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Stop asking this person. A browser that cannot store it keeps asking. */
|
|
29
|
+
export function skipBranchDeleteConfirm(email: string | null | undefined): void {
|
|
30
|
+
if (!email) return;
|
|
31
|
+
try {
|
|
32
|
+
localStorage.setItem(keyFor(email), '1');
|
|
33
|
+
} catch {
|
|
34
|
+
// Nothing stored, so the next delete asks — the safe side.
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** Ask this person again before every shared-branch delete. */
|
|
39
|
+
export function askBeforeBranchDelete(email: string | null | undefined): void {
|
|
40
|
+
if (!email) return;
|
|
41
|
+
try {
|
|
42
|
+
localStorage.removeItem(keyFor(email));
|
|
43
|
+
} catch {
|
|
44
|
+
// Unreadable storage already reads as "ask".
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -2,7 +2,12 @@ import { readFileSync } from 'node:fs';
|
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
import { describe, expect, it } from 'vitest';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
NARROW_PX,
|
|
7
|
+
NARROW_QUERY,
|
|
8
|
+
SETUP_COLUMN_HIDDEN_QUERY,
|
|
9
|
+
TOOLBAR_STACK_QUERY,
|
|
10
|
+
} from '../breakpoints';
|
|
6
11
|
|
|
7
12
|
const SRC_DIR = join(dirname(fileURLToPath(import.meta.url)), '../../..');
|
|
8
13
|
|
|
@@ -23,6 +28,7 @@ describe('narrow-layout source parity', () => {
|
|
|
23
28
|
expect(NARROW_PX).toBe(900);
|
|
24
29
|
expect(NARROW_QUERY).toBe(`(max-width: ${NARROW_PX}px)`);
|
|
25
30
|
expect(TOOLBAR_STACK_QUERY).toBe('(max-width: 767px)');
|
|
31
|
+
expect(SETUP_COLUMN_HIDDEN_QUERY).toBe('(max-width: 900px)');
|
|
26
32
|
});
|
|
27
33
|
|
|
28
34
|
it('keeps the JS breakpoint aligned with the existing 900px Tailwind variants', () => {
|
|
@@ -4,3 +4,11 @@ export const NARROW_QUERY = `(max-width: ${NARROW_PX}px)`;
|
|
|
4
4
|
|
|
5
5
|
/** The toolbar's contributed item cluster needs its own row at this width. */
|
|
6
6
|
export const TOOLBAR_STACK_QUERY = '(max-width: 767px)';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The "Get set up" column (288px) is put away at the same width the sidebar
|
|
10
|
+
* turns into a drawer. It used to go at 1100px, which hid it in an ordinary
|
|
11
|
+
* laptop browser window, the screen it is most for; from 901px up the
|
|
12
|
+
* sidebar, the page and the column still fit side by side.
|
|
13
|
+
*/
|
|
14
|
+
export const SETUP_COLUMN_HIDDEN_QUERY = NARROW_QUERY;
|
|
@@ -73,7 +73,7 @@ describe('ManifestSection', () => {
|
|
|
73
73
|
<ManifestSection kbDirName="knowledge-base" folder="GTM" managed canWrite={false} />
|
|
74
74
|
</MemoryRouter>,
|
|
75
75
|
);
|
|
76
|
-
const header = screen.getByRole('button', { name:
|
|
76
|
+
const header = screen.getByRole('button', { name: 'Plugin settings' });
|
|
77
77
|
expect(header).toHaveAttribute('aria-expanded', 'false');
|
|
78
78
|
expect(apiMock.readFile).not.toHaveBeenCalled();
|
|
79
79
|
|
|
@@ -85,7 +85,7 @@ describe('ManifestSection', () => {
|
|
|
85
85
|
);
|
|
86
86
|
await waitFor(() => expect(screen.getByText(/"version": "1\.2\.0"/)).toBeInTheDocument());
|
|
87
87
|
// A reader gets no editor link.
|
|
88
|
-
expect(screen.queryByRole('button', { name: 'Edit
|
|
88
|
+
expect(screen.queryByRole('button', { name: 'Edit plugin settings' })).not.toBeInTheDocument();
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
it("reads the bundle dialect's file for an unmanaged plugin, and offers no editor even to a writer", async () => {
|
|
@@ -101,18 +101,18 @@ describe('ManifestSection', () => {
|
|
|
101
101
|
'knowledge-base/Plugins/functional/cluster/example/plugin.bundle.json',
|
|
102
102
|
);
|
|
103
103
|
await waitFor(() => expect(screen.getByText(/"name": "example"/)).toBeInTheDocument());
|
|
104
|
-
expect(screen.queryByRole('button', { name: 'Edit
|
|
104
|
+
expect(screen.queryByRole('button', { name: 'Edit plugin settings' })).not.toBeInTheDocument();
|
|
105
105
|
});
|
|
106
106
|
|
|
107
|
-
it('a writer gets "Edit
|
|
107
|
+
it('a writer gets "Edit plugin settings", which asks for the raw file by state', async () => {
|
|
108
108
|
apiMock.readFile.mockResolvedValue(MANIFEST);
|
|
109
109
|
render(
|
|
110
110
|
<MemoryRouter>
|
|
111
111
|
<ManifestSection kbDirName="knowledge-base" folder="GTM" managed canWrite />
|
|
112
112
|
</MemoryRouter>,
|
|
113
113
|
);
|
|
114
|
-
fireEvent.click(screen.getByRole('button', { name:
|
|
115
|
-
fireEvent.click(await screen.findByRole('button', { name: 'Edit
|
|
114
|
+
fireEvent.click(screen.getByRole('button', { name: 'Plugin settings' }));
|
|
115
|
+
fireEvent.click(await screen.findByRole('button', { name: 'Edit plugin settings' }));
|
|
116
116
|
expect(navigateMock).toHaveBeenLastCalledWith(
|
|
117
117
|
expect.stringContaining('Plugins/GTM/plugin.json'),
|
|
118
118
|
{ state: { rawFile: true } },
|
|
@@ -126,7 +126,7 @@ describe('ManifestSection', () => {
|
|
|
126
126
|
<ManifestSection kbDirName="knowledge-base" folder="GTM" managed canWrite={false} />
|
|
127
127
|
</MemoryRouter>,
|
|
128
128
|
);
|
|
129
|
-
fireEvent.click(screen.getByRole('button', { name:
|
|
129
|
+
fireEvent.click(screen.getByRole('button', { name: 'Plugin settings' }));
|
|
130
130
|
await waitFor(() => expect(screen.getByText('not json {')).toBeInTheDocument());
|
|
131
131
|
unmount();
|
|
132
132
|
|
|
@@ -136,8 +136,8 @@ describe('ManifestSection', () => {
|
|
|
136
136
|
<ManifestSection kbDirName="knowledge-base" folder="GTM" managed canWrite={false} />
|
|
137
137
|
</MemoryRouter>,
|
|
138
138
|
);
|
|
139
|
-
fireEvent.click(screen.getByRole('button', { name:
|
|
140
|
-
await waitFor(() => expect(screen.getByText("Couldn't read plugin.
|
|
139
|
+
fireEvent.click(screen.getByRole('button', { name: 'Plugin settings' }));
|
|
140
|
+
await waitFor(() => expect(screen.getByText("Couldn't read the plugin settings.")).toBeInTheDocument());
|
|
141
141
|
});
|
|
142
142
|
});
|
|
143
143
|
|
|
@@ -424,10 +424,17 @@ describe('PluginPage', () => {
|
|
|
424
424
|
expect(screen.queryByRole('menuitem', { name: 'Rename plugin' })).toBeNull();
|
|
425
425
|
});
|
|
426
426
|
|
|
427
|
+
it('offers no Edit plugin settings for a plugin read from the bundle format — its manifest is not editable here', async () => {
|
|
428
|
+
pluginsMock.listPlugins.mockResolvedValue([gtm({ name: 'gtm', canWrite: true, linksAreManaged: false })]);
|
|
429
|
+
renderPlugin('gtm');
|
|
430
|
+
await screen.findByRole('button', { name: 'More actions' });
|
|
431
|
+
expect(screen.queryByRole('button', { name: 'Edit plugin settings' })).toBeNull();
|
|
432
|
+
});
|
|
433
|
+
|
|
427
434
|
it('opens the manifest at the plugin FOLDER, which is not its identity', async () => {
|
|
428
435
|
pluginsMock.listPlugins.mockResolvedValue([gtm({ name: 'go-to-market', displayName: 'GTM', canWrite: true })]);
|
|
429
436
|
renderPlugin('go-to-market');
|
|
430
|
-
fireEvent.click(await screen.findByRole('button', { name: '
|
|
437
|
+
fireEvent.click(await screen.findByRole('button', { name: 'Edit plugin settings' }));
|
|
431
438
|
await waitFor(() =>
|
|
432
439
|
expect(href()).toBe(`/workspace/${DEFAULT_BRANCH}/knowledge-base/Plugins/GTM/plugin.json`),
|
|
433
440
|
);
|
|
@@ -257,18 +257,27 @@ describe('PluginsTree', () => {
|
|
|
257
257
|
expect(row('Plugins').closest('[draggable]')).toHaveAttribute('draggable', 'false');
|
|
258
258
|
expect(row('GTM')).toBeInTheDocument();
|
|
259
259
|
expect(row('personal-u1')).toBeInTheDocument();
|
|
260
|
-
expect(screen.queryByText('
|
|
260
|
+
expect(screen.queryByText('Plugin settings')).not.toBeInTheDocument();
|
|
261
261
|
});
|
|
262
262
|
|
|
263
263
|
it("opens a plugin's files at their canonical default-branch URL — the item route decides the page", () => {
|
|
264
264
|
renderPlugins('/skills-and-tools');
|
|
265
265
|
fireEvent.click(row('GTM'));
|
|
266
|
-
fireEvent.click(row('
|
|
266
|
+
fireEvent.click(row('Plugin settings'));
|
|
267
267
|
expect(screen.getByLabelText('pathname')).toHaveTextContent(
|
|
268
268
|
`/workspace/${DEFAULT_BRANCH}/${KB}/Plugins/GTM/plugin.json`,
|
|
269
269
|
);
|
|
270
270
|
});
|
|
271
271
|
|
|
272
|
+
it("names a plugin's plugin.json Plugin settings, with the real name on hover", () => {
|
|
273
|
+
renderPlugins('/skills-and-tools');
|
|
274
|
+
fireEvent.click(row('GTM'));
|
|
275
|
+
expect(row('Plugin settings')).toHaveAttribute('title', 'plugin.json');
|
|
276
|
+
expect(screen.queryByText('plugin.json')).not.toBeInTheDocument();
|
|
277
|
+
// Every other file keeps its own name and no extra tooltip.
|
|
278
|
+
expect(row('mcp.json')).not.toHaveAttribute('title');
|
|
279
|
+
});
|
|
280
|
+
|
|
272
281
|
it('draws the folder even when the knowledge base has none yet', () => {
|
|
273
282
|
const none = dir('.', [dir(KB, [dir(`${KB}/KnowledgeBase`, [])])]);
|
|
274
283
|
renderPlugins('/skills-and-tools', { fileTree: none });
|
|
@@ -299,8 +308,8 @@ describe('PluginsTree', () => {
|
|
|
299
308
|
expect(onCreatePlugin).toHaveBeenLastCalledWith('GTM');
|
|
300
309
|
|
|
301
310
|
fireEvent.click(row('GTM'));
|
|
302
|
-
fireEvent.contextMenu(row('
|
|
303
|
-
expect(within(screen.getByRole('menu', { name: 'Actions for
|
|
311
|
+
fireEvent.contextMenu(row('Plugin settings'));
|
|
312
|
+
expect(within(screen.getByRole('menu', { name: 'Actions for Plugin settings' })).queryByRole('menuitem', { name: 'New plugin' })).toBeNull();
|
|
304
313
|
});
|
|
305
314
|
|
|
306
315
|
it('offers New plugin only where a plugin may be made — the root and grouping folders, never a plugin or what is inside one', () => {
|
|
@@ -13,6 +13,8 @@ import { cn } from '../../../lib/utils';
|
|
|
13
13
|
import { HEADER_BAND, PAGE_HEADER_TESTID } from '../../../shared/theme/header';
|
|
14
14
|
import { ManageAccessDialog } from '../../access/components/ManageAccessDialog';
|
|
15
15
|
import { offersManageAccess } from '../../access/manage-access-affordance';
|
|
16
|
+
import { useAdmin } from '../../admin/state/admin.context';
|
|
17
|
+
import { CreatorWelcomePage } from '../../onboarding/components/CreatorWelcomePage';
|
|
16
18
|
import { PluginItemSections } from './plugin-page-parts';
|
|
17
19
|
import { PluginRows } from './PluginRows';
|
|
18
20
|
import { ManagedPluginRequests } from './ManagedPluginRequests';
|
|
@@ -62,6 +64,7 @@ function headingFor(filter: LibraryFilter): string {
|
|
|
62
64
|
|
|
63
65
|
export function LibraryPage({ filter }: { filter: LibraryFilter }) {
|
|
64
66
|
const data = useLibrary();
|
|
67
|
+
const { isAdmin, isAdminLoading = false } = useAdmin();
|
|
65
68
|
const navigate = useNavigate();
|
|
66
69
|
const { kbDirName } = useWorkspace();
|
|
67
70
|
const [query, setQuery] = useState('');
|
|
@@ -133,6 +136,25 @@ export function LibraryPage({ filter }: { filter: LibraryFilter }) {
|
|
|
133
136
|
if (kbDirName) navigate(urlForLibraryItem(kbDirName, item));
|
|
134
137
|
}
|
|
135
138
|
|
|
139
|
+
/**
|
|
140
|
+
* An admin's empty catalog is a beginning, not a "nothing here": the page
|
|
141
|
+
* the Library opens on offers the two smallest real starts — a plugin for a
|
|
142
|
+
* team, a skill in their own space — instead of an empty gallery. Only once
|
|
143
|
+
* both indexes have ANSWERED, and answered empty: a load still in flight,
|
|
144
|
+
* or one that failed, is not an empty library. Members keep the gallery;
|
|
145
|
+
* the shared structure is not theirs to make.
|
|
146
|
+
*/
|
|
147
|
+
const catalogIsEmpty =
|
|
148
|
+
!data.loading &&
|
|
149
|
+
!data.pluginsLoading &&
|
|
150
|
+
!data.error &&
|
|
151
|
+
!data.pluginsError &&
|
|
152
|
+
data.items.length === 0 &&
|
|
153
|
+
data.pluginSummaries.length === 0;
|
|
154
|
+
if (filter.kind === 'all' && isAdmin && !isAdminLoading && catalogIsEmpty) {
|
|
155
|
+
return <CreatorWelcomePage />;
|
|
156
|
+
}
|
|
157
|
+
|
|
136
158
|
return (
|
|
137
159
|
<>
|
|
138
160
|
{/* The title bar, on the band the sidebar's header row is also on. The
|
|
@@ -39,13 +39,20 @@ export function ManifestButton({
|
|
|
39
39
|
kbDirName,
|
|
40
40
|
folder,
|
|
41
41
|
canWrite,
|
|
42
|
+
managed,
|
|
42
43
|
}: {
|
|
43
44
|
kbDirName: string | null;
|
|
44
45
|
folder: string;
|
|
45
46
|
canWrite: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* False for a plugin read from the bundle format: its manifest is
|
|
49
|
+
* `plugin.bundle.json`, edited in its own repository and read-only here, so
|
|
50
|
+
* there are no settings this button could open.
|
|
51
|
+
*/
|
|
52
|
+
managed: boolean;
|
|
46
53
|
}) {
|
|
47
54
|
const navigate = useNavigate();
|
|
48
|
-
if (!canWrite || !kbDirName) return null;
|
|
55
|
+
if (!managed || !canWrite || !kbDirName) return null;
|
|
49
56
|
return (
|
|
50
57
|
<Button
|
|
51
58
|
variant="quiet"
|
|
@@ -55,8 +62,9 @@ export function ManifestButton({
|
|
|
55
62
|
state: { rawFile: true },
|
|
56
63
|
})
|
|
57
64
|
}
|
|
65
|
+
title={PLUGIN_MANIFEST_FILE}
|
|
58
66
|
>
|
|
59
|
-
|
|
67
|
+
Edit plugin settings
|
|
60
68
|
</Button>
|
|
61
69
|
);
|
|
62
70
|
}
|
|
@@ -126,8 +134,17 @@ export function ManifestSection({
|
|
|
126
134
|
<span className="flex w-3 flex-none items-center justify-center">
|
|
127
135
|
<ChevronRight size={11} className={cn('transition-transform duration-150', open && 'rotate-90')} />
|
|
128
136
|
</span>
|
|
129
|
-
|
|
130
|
-
|
|
137
|
+
{/* The native manifest is the plugin's settings, by the name the
|
|
138
|
+
rest of the app gives it; the bundle dialect's file is a format
|
|
139
|
+
from elsewhere and keeps its technical label. */}
|
|
140
|
+
{managed ? (
|
|
141
|
+
<span title={file}>Plugin settings</span>
|
|
142
|
+
) : (
|
|
143
|
+
<>
|
|
144
|
+
Manifest
|
|
145
|
+
<span className="font-mono normal-case tracking-normal text-ink-faint">{file}</span>
|
|
146
|
+
</>
|
|
147
|
+
)}
|
|
131
148
|
</button>
|
|
132
149
|
{/* The panel is always in the tree, so the button's `aria-controls`
|
|
133
150
|
names an element that exists; only its CONTENT waits for `open`
|
|
@@ -143,7 +160,7 @@ export function ManifestSection({
|
|
|
143
160
|
: 'Read from the bundle format; it is edited in its own repository.'}
|
|
144
161
|
</p>
|
|
145
162
|
{current?.failed ? (
|
|
146
|
-
<p className="text-detail text-ink-muted">Couldn't read {file}.</p>
|
|
163
|
+
<p className="text-detail text-ink-muted">Couldn't read {managed ? 'the plugin settings' : file}.</p>
|
|
147
164
|
) : current?.text == null ? (
|
|
148
165
|
<p className="text-detail text-ink-faint">Loading…</p>
|
|
149
166
|
) : (
|
|
@@ -158,7 +175,7 @@ export function ManifestSection({
|
|
|
158
175
|
className="mt-2"
|
|
159
176
|
onClick={() => navigate(kbFileUrl(DEFAULT_BRANCH, path), { state: { rawFile: true } })}
|
|
160
177
|
>
|
|
161
|
-
Edit
|
|
178
|
+
Edit plugin settings
|
|
162
179
|
</Button>
|
|
163
180
|
)}
|
|
164
181
|
</>
|
|
@@ -381,7 +381,12 @@ export function PluginPage() {
|
|
|
381
381
|
</h1>
|
|
382
382
|
</div>
|
|
383
383
|
<div className="flex flex-none items-center gap-1">
|
|
384
|
-
<ManifestButton
|
|
384
|
+
<ManifestButton
|
|
385
|
+
kbDirName={kbDirName}
|
|
386
|
+
folder={folderBelowRoot}
|
|
387
|
+
canWrite={summary?.canWrite === true}
|
|
388
|
+
managed={summary?.linksAreManaged !== false}
|
|
389
|
+
/>
|
|
385
390
|
<PageActions
|
|
386
391
|
onShare={primaryFolder ? () => setManageFolder(primaryFolder) : undefined}
|
|
387
392
|
// The dialog needs both to mount (`addOpen && summary &&
|