@bevel-software/platform-core-frontend 0.32.0 → 0.33.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 +1 -1
- package/src/modules/access/api.ts +1 -1
- package/src/modules/access/components/ManageAccessDialog.tsx +4 -5
- package/src/modules/access/hooks/useAccessRequests.ts +1 -1
- package/src/modules/access/hooks/useFileAccess.ts +1 -1
- package/src/modules/access/index.ts +11 -0
- package/src/modules/access/requests.api.ts +1 -1
- package/src/modules/admin/components/AddMemberInput.tsx +1 -1
- package/src/modules/admin/components/UserAccountsPage.tsx +3 -3
- package/src/modules/admin/index.ts +7 -0
- package/src/modules/admin/state/admin.context.tsx +1 -1
- package/src/modules/audit/components/AuditEventsPanel.tsx +1 -1
- package/src/modules/audit/components/AuditLogPage.tsx +2 -2
- package/src/modules/auth/index.ts +12 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.access-rules.test.tsx +0 -1
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.binary.test.tsx +0 -1
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.brings-itself-up-to-date.test.tsx +0 -1
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.edit.test.tsx +166 -0
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.fork-point.test.tsx +0 -1
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.initial-file.test.tsx +0 -1
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.moved.test.tsx +0 -1
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.sync-banner.test.tsx +0 -1
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.test.tsx +0 -2
- package/src/modules/change-requests/__tests__/ChangeRequestDialog.unreadable.test.tsx +0 -1
- package/src/modules/change-requests/__tests__/apply-outcome-for-every-viewer.test.tsx +0 -1
- package/src/modules/change-requests/components/BranchFilePreview.tsx +4 -12
- package/src/modules/change-requests/components/ChangeRequestDialog.tsx +138 -30
- package/src/modules/change-requests/components/ChangeRequestLink.tsx +2 -3
- package/src/modules/change-requests/components/CrFileTree.tsx +1 -1
- package/src/modules/change-requests/components/FileChangeBoxes.tsx +2 -3
- package/src/modules/change-requests/hooks/useApplyChangeRequest.ts +3 -5
- package/src/modules/change-requests/hooks/useCrFileDiffs.ts +1 -1
- package/src/modules/change-requests/index.ts +14 -0
- package/src/modules/change-requests/services/change-requests.api.ts +2 -2
- package/src/modules/change-requests/services/denied-file.api.ts +2 -2
- package/src/modules/change-requests/services/propose.api.ts +3 -4
- package/src/modules/change-requests/utils/diff.ts +1 -1
- package/src/modules/change-requests/utils/readFailure.ts +1 -1
- package/src/modules/embed/__tests__/EmbedView.test.tsx +19 -2
- package/src/modules/embed/components/EmbedLinkPage.tsx +1 -2
- package/src/modules/git/components/BranchSwitcher.tsx +3 -4
- package/src/modules/git/components/FileHistoryPanel.tsx +2 -2
- package/src/modules/git/components/GitSyncFailedBanner.tsx +2 -4
- package/src/modules/git/components/HistoryVersionPreview.tsx +4 -15
- package/src/modules/git/components/PullNeededBanner.tsx +1 -1
- package/src/modules/git/hooks/useAutoPullUpdates.ts +1 -1
- package/src/modules/git/index.ts +11 -0
- package/src/modules/layout/components/MobileChatLayout.tsx +1 -1
- package/src/modules/layout/index.ts +9 -0
- package/src/modules/library/__tests__/SkillPage.test.tsx +39 -0
- package/src/modules/library/__tests__/propose-change.test.ts +75 -0
- package/src/modules/library/components/AddToPluginDialog.tsx +1 -1
- package/src/modules/library/components/ChangeRequestDock.tsx +1 -1
- package/src/modules/library/components/LibraryLayout.tsx +2 -2
- package/src/modules/library/components/LibraryPage.tsx +3 -3
- package/src/modules/library/components/ManagedPluginRequests.tsx +1 -1
- package/src/modules/library/components/NewSkillPanel.tsx +2 -2
- package/src/modules/library/components/PersonalAddDialog.tsx +1 -1
- package/src/modules/library/components/PersonalPluginPage.tsx +1 -1
- package/src/modules/library/components/PluginExtras.tsx +1 -4
- package/src/modules/library/components/PluginPage.tsx +1 -1
- package/src/modules/library/components/PluginRows.tsx +1 -1
- package/src/modules/library/components/SkillsTree.tsx +1 -4
- package/src/modules/library/components/plugin-page-parts.tsx +1 -1
- package/src/modules/library/components/skill-page/SkillFilePane.tsx +19 -7
- package/src/modules/library/components/skill-page/SkillPage.tsx +19 -26
- package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +2 -4
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +2 -2
- package/src/modules/library/hooks/useJoinRequests.ts +1 -1
- package/src/modules/library/hooks/useLibraryData.ts +3 -3
- package/src/modules/library/hooks/useToolPage.ts +1 -1
- package/src/modules/library/hooks/useToolSource.ts +1 -1
- package/src/modules/library/index.ts +12 -0
- package/src/modules/library/routes/LibraryRoutes.tsx +1 -1
- package/src/modules/library/routes/WorkspaceItemRoute.tsx +1 -3
- package/src/modules/library/routes/library-paths.ts +1 -1
- package/src/modules/library/services/library.api.ts +10 -8
- package/src/modules/library/services/plugins.api.ts +1 -1
- package/src/modules/library/services/teams.api.ts +1 -1
- package/src/modules/library/utils/status.ts +2 -2
- package/src/modules/onboarding/components/ConnectAgentPill.tsx +1 -1
- package/src/modules/onboarding/components/CreatorWelcomePage.tsx +2 -3
- package/src/modules/onboarding/components/GetStartedColumn.tsx +6 -13
- package/src/modules/onboarding/components/InviteButton.tsx +2 -2
- package/src/modules/onboarding/components/InviteDialog.tsx +4 -6
- package/src/modules/onboarding/components/RootLanding.tsx +2 -2
- package/src/modules/onboarding/components/StarterPackCard.tsx +1 -1
- package/src/modules/onboarding/components/WelcomePage.tsx +2 -5
- package/src/modules/onboarding/index.ts +10 -0
- package/src/modules/onboarding/paths.ts +1 -1
- package/src/modules/onboarding/state/agent-connection.ts +2 -2
- package/src/modules/onboarding/state/onboarding.ts +1 -1
- package/src/modules/onboarding/state/starter-packs.ts +1 -1
- package/src/modules/pr/components/OpenChangeRequestDialog.tsx +1 -1
- package/src/modules/pr/index.ts +14 -0
- package/src/modules/pr/services/pr-approvals.api.ts +1 -1
- package/src/modules/pr/services/pr-cancel.api.ts +1 -1
- package/src/modules/pr/services/pr-detail.api.ts +2 -2
- package/src/modules/pr/services/pr-edit.api.ts +22 -0
- package/src/modules/pr/services/pr-merge.api.ts +1 -1
- package/src/modules/pr/services/pr-open.api.ts +1 -1
- package/src/modules/review/components/DiffViewer.tsx +1 -1
- package/src/modules/review/components/MarkdownDiffViewer.tsx +1 -2
- package/src/modules/review/components/ReviewPanel.tsx +2 -3
- package/src/modules/review/state/ReviewProvider.tsx +2 -2
- package/src/modules/secrets-vault/index.ts +6 -0
- package/src/modules/settings/components/DeploymentPage.tsx +2 -2
- package/src/modules/settings/components/SettingsLayout.tsx +2 -2
- package/src/modules/settings/index.ts +8 -0
- package/src/modules/setup/components/FirstRunStorage.tsx +1 -1
- package/src/modules/setup/index.ts +6 -0
- package/src/modules/toolbar/commands/actions.tsx +3 -3
- package/src/modules/toolbar/commands/useCommandActions.ts +5 -9
- package/src/modules/toolbar/components/AgentInstructionsCard.tsx +2 -2
- package/src/modules/toolbar/components/AppSwitcher.tsx +1 -2
- package/src/modules/toolbar/components/CoworkSetupSteps.tsx +1 -1
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +1 -1
- package/src/modules/toolbar/components/ProfileMenu.tsx +3 -3
- package/src/modules/toolbar/components/SearchPalette.tsx +4 -8
- package/src/modules/toolbar/components/Toolbar.tsx +2 -5
- package/src/modules/toolbar/index.ts +6 -0
- package/src/modules/toolbar/search/sources.ts +4 -7
- package/src/modules/toolbar/services/agent-instructions.api.ts +1 -1
- package/src/modules/tools/ToolsExplorerPage.tsx +217 -18
- package/src/modules/tools/__tests__/ToolsExplorerPage.read-only.test.tsx +220 -0
- package/src/modules/tools/tool-hints.api.ts +44 -0
- package/src/modules/workflow/index.ts +7 -0
- package/src/modules/workflow/state/ChangeRequestStaleBinder.tsx +1 -0
- package/src/modules/workflow/state/EventBusFocusBinder.tsx +1 -1
- package/src/modules/workspace/components/FileExplorer.tsx +35 -8
- package/src/modules/workspace/components/FilePaneCard.tsx +37 -12
- package/src/modules/workspace/components/FileRoute.tsx +10 -3
- package/src/modules/workspace/components/FileViewer.tsx +169 -25
- package/src/modules/workspace/components/FullScreenView.tsx +93 -0
- package/src/modules/workspace/components/KbFileRail.tsx +1 -1
- package/src/modules/workspace/components/KbPageHeader.tsx +9 -0
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +137 -0
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +11 -0
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +487 -3
- package/src/modules/workspace/components/readingCarry.ts +59 -0
- package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +36 -175
- package/src/modules/workspace/components/renderers/ToolRenderer.tsx +1 -1
- package/src/modules/workspace/components/renderers/__tests__/HtmlRenderer.tools.test.tsx +168 -42
- package/src/modules/workspace/components/renderers/__tests__/bridgeHarness.ts +20 -3
- package/src/modules/workspace/components/renderers/__tests__/htmlSandbox.test.ts +63 -4
- package/src/modules/workspace/components/renderers/__tests__/htmlToolBridge.test.ts +235 -1
- package/src/modules/workspace/components/renderers/__tests__/htmlViewsGuide.test.ts +14 -3
- package/src/modules/workspace/components/renderers/__tests__/pageToolsHarness.ts +79 -0
- package/src/modules/workspace/components/renderers/__tests__/useHtmlToolBridge.test.tsx +316 -0
- package/src/modules/workspace/components/renderers/htmlSandbox.ts +75 -13
- package/src/modules/workspace/components/renderers/htmlToolBridge.ts +196 -25
- package/src/modules/workspace/components/renderers/index.ts +10 -0
- package/src/modules/workspace/components/renderers/useHtmlToolBridge.tsx +253 -0
- package/src/modules/workspace/hooks/useFullScreenView.ts +52 -0
- package/src/modules/workspace/hooks/useImageRevision.ts +1 -1
- package/src/modules/workspace/hooks/useKnowledgeWriteTarget.ts +1 -1
- package/src/modules/workspace/hooks/useLastCommit.ts +1 -1
- package/src/modules/workspace/hooks/useWorkspaceState.ts +4 -4
- package/src/modules/workspace/index.ts +30 -1
- package/src/modules/workspace/routing/kb-routes.ts +1 -1
- package/src/modules/workspace/state/__tests__/applied-request-clears-pending.test.tsx +0 -1
- package/src/modules/workspace/state/open-change-requests.tsx +1 -1
- package/src/modules/workspace/utils/frameEscape.ts +15 -0
- package/src/modules/workspace/utils/treeConfirm.ts +1 -1
- package/src/shared/theme/measure.ts +7 -0
- package/src/modules/pr/services/pr-comments.api.ts +0 -45
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bevel-software/platform-core-frontend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.0",
|
|
4
4
|
"description": "Open-source core UI of the Bevel platform (raw TS/TSX source): workspace explorer/viewer, branches & change requests, Library, secrets, tools, access control.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"tailwind-merge": "^3.5.0",
|
|
46
46
|
"xlsx": "https://cdn.sheetjs.com/xlsx-0.20.3/xlsx-0.20.3.tgz",
|
|
47
47
|
"yaml": "^2.9.0",
|
|
48
|
-
"@bevel-software/platform-shared": "0.
|
|
48
|
+
"@bevel-software/platform-shared": "0.33.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@modelcontextprotocol/client": "^2.3.1",
|
|
@@ -18,7 +18,7 @@ import { GitContext } from '../modules/git/state/git.context';
|
|
|
18
18
|
import { AutoUpdateContext } from '../modules/git/state/auto-update.context';
|
|
19
19
|
import { useGitState } from '../modules/git/hooks/useGitState';
|
|
20
20
|
import { useAutoPullUpdates } from '../modules/git/hooks/useAutoPullUpdates';
|
|
21
|
-
import { EventBusProvider } from '../modules/workflow
|
|
21
|
+
import { EventBusProvider } from '../modules/workflow';
|
|
22
22
|
import { EventBusFocusBinder } from '../modules/workflow/state/EventBusFocusBinder';
|
|
23
23
|
import { ChangeRequestStaleBinder } from '../modules/workflow/state/ChangeRequestStaleBinder';
|
|
24
24
|
import { Toolbar } from '../modules/toolbar/components/Toolbar';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Verb } from '@bevel-software/platform-shared';
|
|
2
2
|
import { authFetch } from '../../lib/api';
|
|
3
|
-
import { GitApiError, handleApiResponse } from '../git
|
|
3
|
+
import { GitApiError, handleApiResponse } from '../git';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* A collective grantee with WHAT it is — role (capability), group (audience),
|
|
@@ -33,11 +33,10 @@ import {
|
|
|
33
33
|
MenuPanel,
|
|
34
34
|
useDismissableMenu,
|
|
35
35
|
} from '../../../shared/components';
|
|
36
|
-
import { useWorkspace } from '../../workspace
|
|
37
|
-
import { useAuth } from '../../auth
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import { useInviteDialog } from '../../onboarding/state/invite-dialog.context';
|
|
36
|
+
import { useWorkspace } from '../../workspace';
|
|
37
|
+
import { useAuth, useSignInMethods } from '../../auth';
|
|
38
|
+
import { AdminContext } from '../../admin';
|
|
39
|
+
import { useInviteDialog } from '../../onboarding';
|
|
41
40
|
import {
|
|
42
41
|
fetchFileAccess,
|
|
43
42
|
grantAccess,
|
|
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useState } from 'react';
|
|
|
2
2
|
import { DEFAULT_BRANCH } from '@bevel-software/platform-shared';
|
|
3
3
|
import { useLatestRef } from '../../../shared/components';
|
|
4
4
|
import { grantAccess } from '../api';
|
|
5
|
-
import { cancelPullRequest } from '../../pr
|
|
5
|
+
import { cancelPullRequest } from '../../pr';
|
|
6
6
|
import type { AccessProposal, AccessRequestRow } from '../requests.api';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
2
|
import { currentBranchModel, isProtectedBranch } from '@bevel-software/platform-shared';
|
|
3
|
-
import { useWorkspace } from '../../workspace
|
|
3
|
+
import { useWorkspace } from '../../workspace';
|
|
4
4
|
import { fetchFileAccess, type AccessEligible } from '../api';
|
|
5
5
|
|
|
6
6
|
export interface FileAccessState {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the access module offers the other modules. A consumer outside the
|
|
3
|
+
* module imports from here, never from the files: they are the module's own
|
|
4
|
+
* layout and free to move. Export what another module needs; nothing more.
|
|
5
|
+
*/
|
|
6
|
+
export { fetchAdmins, fetchFileAccess, fetchFileAccessBatch, fetchProspectiveAccess, parsePluginPrincipalToken, pluginPrincipalLabel, suggestPrincipals } from './api';
|
|
7
|
+
export type { AccessEligible, AccessPrincipalRef, AccessResponse, AdminContact, GrantSources, PathPrincipals, ProspectiveAccess } from './api';
|
|
8
|
+
export { useAccessRequests } from './hooks/useAccessRequests';
|
|
9
|
+
export type { AccessRequestsState } from './hooks/useAccessRequests';
|
|
10
|
+
export { formatEligible, useFileAccess } from './hooks/useFileAccess';
|
|
11
|
+
export { offersManageAccess } from './manage-access-affordance';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { authFetch } from '../../lib/api';
|
|
2
|
-
import { handleApiResponse } from '../git
|
|
2
|
+
import { handleApiResponse } from '../git';
|
|
3
3
|
|
|
4
4
|
/** The two levels the Manage access dialog can ask for. Owner covers Can edit. */
|
|
5
5
|
export type RequestLevel = 'write' | 'owner';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect, useId, useRef, useState, type Ref } from 'react';
|
|
2
2
|
import { Loader2 } from 'lucide-react';
|
|
3
3
|
import { DEFAULT_BRANCH } from '@bevel-software/platform-shared';
|
|
4
|
-
import { suggestPrincipals } from '../../access
|
|
4
|
+
import { suggestPrincipals } from '../../access';
|
|
5
5
|
import { initials } from '../../../lib/email';
|
|
6
6
|
|
|
7
7
|
/** A person offered by the suggest endpoint — name and email, nothing more. */
|
|
@@ -3,8 +3,8 @@ import { Users } from 'lucide-react';
|
|
|
3
3
|
import { PageShell } from '../../../shared/components/PageShell';
|
|
4
4
|
import { Dialog } from '../../../shared/components/Dialog';
|
|
5
5
|
import { useAdmin } from '../state/admin.context';
|
|
6
|
-
import { useAuth } from '../../auth
|
|
7
|
-
import { useInviteDialog } from '../../onboarding
|
|
6
|
+
import { useAuth } from '../../auth';
|
|
7
|
+
import { useInviteDialog } from '../../onboarding';
|
|
8
8
|
import { useLatestRequest } from '../../../lib/latest-request';
|
|
9
9
|
import {
|
|
10
10
|
createAccount,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
reactivateAccount,
|
|
16
16
|
type AccountReferences,
|
|
17
17
|
type AccountSummary,
|
|
18
|
-
} from '../../auth
|
|
18
|
+
} from '../../auth';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* How an account signs in, in the words this page uses everywhere (the row and
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the admin module offers the other modules. A consumer outside the
|
|
3
|
+
* module imports from here, never from the files: they are the module's own
|
|
4
|
+
* layout and free to move. Export what another module needs; nothing more.
|
|
5
|
+
*/
|
|
6
|
+
export { addMember, fetchRoles } from './services/roles.api';
|
|
7
|
+
export { AdminContext, useAdmin } from './state/admin.context';
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
useState,
|
|
9
9
|
type ReactNode,
|
|
10
10
|
} from 'react';
|
|
11
|
-
import { useAuth } from '../../auth
|
|
11
|
+
import { useAuth } from '../../auth';
|
|
12
12
|
import { fetchAdminAccess } from '../services/admin.api';
|
|
13
13
|
import { useAppRegistry } from '../../../core/registry';
|
|
14
14
|
import { getRolesHealth, recoverRoles } from '../services/roles.api';
|
|
@@ -2,7 +2,7 @@ import { Fragment, useCallback, useEffect, useId, useMemo, useRef, useState } fr
|
|
|
2
2
|
import { Link } from 'react-router-dom';
|
|
3
3
|
import { Badge, Banner, Button } from '../../../shared/components';
|
|
4
4
|
import { cn } from '../../../lib/utils';
|
|
5
|
-
import {
|
|
5
|
+
import { pathForTool, pathForSkill } from '../../library';
|
|
6
6
|
import {
|
|
7
7
|
listEvents,
|
|
8
8
|
type AgentEvent,
|
|
@@ -5,8 +5,8 @@ import { Dialog } from '../../../shared/components/Dialog';
|
|
|
5
5
|
import { Badge, Banner, Button } from '../../../shared/components';
|
|
6
6
|
import { cn, formatRelativeTime } from '../../../lib/utils';
|
|
7
7
|
import { GITHUB_LINK_KIND } from '../../../shared/marketplace-url';
|
|
8
|
-
import { useAdmin } from '../../admin
|
|
9
|
-
import { useAuth } from '../../auth
|
|
8
|
+
import { useAdmin } from '../../admin';
|
|
9
|
+
import { useAuth } from '../../auth';
|
|
10
10
|
import { listPrincipals, revokeAgent, revokeKey, type AuditPrincipal } from '../services/audit.api';
|
|
11
11
|
import { groupByAccount, principalKey } from './principal-grouping';
|
|
12
12
|
import { AuditEventsPanel } from './AuditEventsPanel';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the auth module offers the other modules. A consumer outside the
|
|
3
|
+
* module imports from here, never from the files: they are the module's own
|
|
4
|
+
* layout and free to move. Export what another module needs; nothing more.
|
|
5
|
+
*/
|
|
6
|
+
export { useAuthState } from './hooks/useAuthState';
|
|
7
|
+
export { createAccount, deactivateAccount, deleteAccount, getAccountReferences, listAccounts, reactivateAccount } from './services/account.api';
|
|
8
|
+
export type { AccountReferences, AccountSummary } from './services/account.api';
|
|
9
|
+
export { takePostLoginRedirect } from './services/sso';
|
|
10
|
+
export type { LoginProviders } from './services/sso';
|
|
11
|
+
export { AuthContext, useAuth } from './state/auth.context';
|
|
12
|
+
export { useSignInMethods } from './state/use-sign-in-methods';
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
|
3
|
+
import type { PullRequestSummary } from '@bevel-software/platform-shared';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Editing a request's title and description from its dialog: offered to the
|
|
7
|
+
* people the server says may (`viewerCanEdit` — the author, or anyone who may
|
|
8
|
+
* merge it), saved through the PATCH route, and shown at once — in the dialog
|
|
9
|
+
* from a fresh read, and in every list through the stale signal.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const detailMock = vi.hoisted(() => ({ fetchPrDetail: vi.fn() }));
|
|
13
|
+
vi.mock('../../pr/services/pr-detail.api', () => ({ fetchPrDetail: detailMock.fetchPrDetail }));
|
|
14
|
+
vi.mock('../services/change-requests.api', () => ({
|
|
15
|
+
readFileOnBranch: vi.fn(async () => 'branch copy'),
|
|
16
|
+
}));
|
|
17
|
+
vi.mock('../../pr/services/pr-approvals.api', () => ({
|
|
18
|
+
approvePrFile: vi.fn(),
|
|
19
|
+
revertPrFile: vi.fn(),
|
|
20
|
+
unapprovePrFile: vi.fn(),
|
|
21
|
+
}));
|
|
22
|
+
vi.mock('../../pr/services/pr-merge.api', () => ({
|
|
23
|
+
mergePullRequest: vi.fn(),
|
|
24
|
+
refreshChangeRequestFromTarget: vi.fn(),
|
|
25
|
+
}));
|
|
26
|
+
vi.mock('../../pr/services/pr-cancel.api', () => ({
|
|
27
|
+
cancelPullRequest: vi.fn(),
|
|
28
|
+
deleteChangeRequest: vi.fn(),
|
|
29
|
+
}));
|
|
30
|
+
const editApi = vi.hoisted(() => ({ updateChangeRequest: vi.fn() }));
|
|
31
|
+
vi.mock('../../pr/services/pr-edit.api', async (importOriginal) => ({
|
|
32
|
+
...(await importOriginal<typeof import('../../pr/services/pr-edit.api')>()),
|
|
33
|
+
updateChangeRequest: editApi.updateChangeRequest,
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
import { ChangeRequestDialog } from '../components/ChangeRequestDialog';
|
|
37
|
+
import { PR_STALE_EVENT } from '../../../core/events';
|
|
38
|
+
import { GitApiError } from '../../git/services/git.api';
|
|
39
|
+
|
|
40
|
+
const CR: PullRequestSummary = {
|
|
41
|
+
number: 12,
|
|
42
|
+
title: 'Old title',
|
|
43
|
+
authorId: 'abc',
|
|
44
|
+
author: { login: 'user-abc', name: 'Ali' },
|
|
45
|
+
appAuthor: { name: 'Ali' },
|
|
46
|
+
branch: 'ali.raza/draft',
|
|
47
|
+
base: 'main',
|
|
48
|
+
state: 'open',
|
|
49
|
+
createdAt: '2026-08-07T00:00:00.000Z',
|
|
50
|
+
touchedNodePaths: [],
|
|
51
|
+
review: { approvals: 0, changesRequested: 0, pendingLogins: [] },
|
|
52
|
+
url: '/change-requests/12',
|
|
53
|
+
} as unknown as PullRequestSummary;
|
|
54
|
+
|
|
55
|
+
function detail(over: Record<string, unknown> = {}) {
|
|
56
|
+
return {
|
|
57
|
+
...CR,
|
|
58
|
+
body: 'Old reason.\n\n## My own section\n\nDetails.',
|
|
59
|
+
headSha: 'h',
|
|
60
|
+
baseSha: 'b',
|
|
61
|
+
files: [],
|
|
62
|
+
approvals: [],
|
|
63
|
+
mergeableInBevel: false,
|
|
64
|
+
mergeBlockedReasons: [],
|
|
65
|
+
mergeWarnings: [],
|
|
66
|
+
viewerCanBypassMerge: false,
|
|
67
|
+
viewerCanCancel: true,
|
|
68
|
+
viewerCanDelete: false,
|
|
69
|
+
viewerCanEdit: true,
|
|
70
|
+
...over,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
beforeEach(() => {
|
|
75
|
+
detailMock.fetchPrDetail.mockReset();
|
|
76
|
+
editApi.updateChangeRequest.mockReset();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('ChangeRequestDialog: editing the title and description', () => {
|
|
80
|
+
it('offers no Edit control to someone who may not edit', async () => {
|
|
81
|
+
detailMock.fetchPrDetail.mockResolvedValue(detail({ viewerCanEdit: false }));
|
|
82
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
83
|
+
expect(await screen.findByText(/Old reason./)).toBeInTheDocument();
|
|
84
|
+
expect(screen.queryByRole('button', { name: 'Edit' })).not.toBeInTheDocument();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('offers the body whole — own headings included; it is the description and nothing else', async () => {
|
|
88
|
+
detailMock.fetchPrDetail.mockResolvedValue(detail());
|
|
89
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
90
|
+
fireEvent.click(await screen.findByRole('button', { name: 'Edit' }));
|
|
91
|
+
expect(screen.getByRole('textbox', { name: 'Title' })).toHaveValue('Old title');
|
|
92
|
+
expect(screen.getByRole('textbox', { name: 'Description' })).toHaveValue(
|
|
93
|
+
'Old reason.\n\n## My own section\n\nDetails.',
|
|
94
|
+
);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('saves only what changed, then shows the new text and refreshes every list', async () => {
|
|
98
|
+
detailMock.fetchPrDetail.mockResolvedValueOnce(detail());
|
|
99
|
+
editApi.updateChangeRequest.mockResolvedValue({ ...CR, title: 'New title' });
|
|
100
|
+
detailMock.fetchPrDetail.mockResolvedValueOnce(
|
|
101
|
+
detail({
|
|
102
|
+
title: 'New title',
|
|
103
|
+
body: 'P2 - Planned\n\nNew reason.',
|
|
104
|
+
}),
|
|
105
|
+
);
|
|
106
|
+
const stale = vi.fn();
|
|
107
|
+
window.addEventListener(PR_STALE_EVENT, stale);
|
|
108
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
109
|
+
|
|
110
|
+
fireEvent.click(await screen.findByRole('button', { name: 'Edit' }));
|
|
111
|
+
fireEvent.change(screen.getByRole('textbox', { name: 'Description' }), {
|
|
112
|
+
target: { value: 'P2 - Planned\n\nNew reason.' },
|
|
113
|
+
});
|
|
114
|
+
fireEvent.click(screen.getByRole('button', { name: 'Save' }));
|
|
115
|
+
|
|
116
|
+
await waitFor(() =>
|
|
117
|
+
expect(editApi.updateChangeRequest).toHaveBeenCalledWith(12, { description: 'P2 - Planned\n\nNew reason.' }),
|
|
118
|
+
);
|
|
119
|
+
expect(await screen.findByRole('heading', { name: 'New title' })).toBeInTheDocument();
|
|
120
|
+
expect(screen.getByText(/New reason\./)).toBeInTheDocument();
|
|
121
|
+
expect(screen.queryByRole('textbox', { name: 'Description' })).not.toBeInTheDocument();
|
|
122
|
+
expect(detailMock.fetchPrDetail).toHaveBeenLastCalledWith(12, { fresh: true });
|
|
123
|
+
expect(stale).toHaveBeenCalled();
|
|
124
|
+
window.removeEventListener(PR_STALE_EVENT, stale);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('a saved edit stays saved when the follow-up read fails — no error, and every list still refreshes', async () => {
|
|
128
|
+
detailMock.fetchPrDetail.mockResolvedValueOnce(detail());
|
|
129
|
+
editApi.updateChangeRequest.mockResolvedValue({ ...CR, title: 'New title' });
|
|
130
|
+
detailMock.fetchPrDetail.mockRejectedValueOnce(new Error('network down'));
|
|
131
|
+
const stale = vi.fn();
|
|
132
|
+
window.addEventListener(PR_STALE_EVENT, stale);
|
|
133
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
134
|
+
|
|
135
|
+
fireEvent.click(await screen.findByRole('button', { name: 'Edit' }));
|
|
136
|
+
fireEvent.change(screen.getByRole('textbox', { name: 'Title' }), { target: { value: 'New title' } });
|
|
137
|
+
fireEvent.click(screen.getByRole('button', { name: 'Save' }));
|
|
138
|
+
|
|
139
|
+
await waitFor(() => expect(screen.queryByRole('textbox', { name: 'Title' })).not.toBeInTheDocument());
|
|
140
|
+
expect(stale).toHaveBeenCalled();
|
|
141
|
+
expect(screen.queryByText(/Couldn't save/)).not.toBeInTheDocument();
|
|
142
|
+
expect(screen.queryByText(/network down/)).not.toBeInTheDocument();
|
|
143
|
+
window.removeEventListener(PR_STALE_EVENT, stale);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it("shows the server's refusal in its words and keeps the draft", async () => {
|
|
147
|
+
detailMock.fetchPrDetail.mockResolvedValue(detail());
|
|
148
|
+
editApi.updateChangeRequest.mockRejectedValue(
|
|
149
|
+
new GitApiError(409, 'This change request has already been applied; its title and description can no longer be changed.', {}),
|
|
150
|
+
);
|
|
151
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
152
|
+
fireEvent.click(await screen.findByRole('button', { name: 'Edit' }));
|
|
153
|
+
fireEvent.change(screen.getByRole('textbox', { name: 'Title' }), { target: { value: 'Newer' } });
|
|
154
|
+
fireEvent.click(screen.getByRole('button', { name: 'Save' }));
|
|
155
|
+
expect(await screen.findByRole('alert')).toHaveTextContent('already been applied');
|
|
156
|
+
expect(screen.getByRole('textbox', { name: 'Title' })).toHaveValue('Newer');
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it('will not save an empty title', async () => {
|
|
160
|
+
detailMock.fetchPrDetail.mockResolvedValue(detail());
|
|
161
|
+
render(<ChangeRequestDialog cr={CR} onClose={() => {}} onResolved={() => {}} />);
|
|
162
|
+
fireEvent.click(await screen.findByRole('button', { name: 'Edit' }));
|
|
163
|
+
fireEvent.change(screen.getByRole('textbox', { name: 'Title' }), { target: { value: ' ' } });
|
|
164
|
+
expect(screen.getByRole('button', { name: 'Save' })).toBeDisabled();
|
|
165
|
+
});
|
|
166
|
+
});
|
|
@@ -65,7 +65,6 @@ const DETAIL = {
|
|
|
65
65
|
headSha: 'h',
|
|
66
66
|
baseSha: 'b',
|
|
67
67
|
files: [{ path: 'Docs/a.md', status: 'modified', additions: 1, deletions: 0, isBinary: false, sha: '', rawUrl: '' }],
|
|
68
|
-
comments: [],
|
|
69
68
|
approvals: [APPROVAL],
|
|
70
69
|
mergeableInBevel: true,
|
|
71
70
|
mergeBlockedReasons: [],
|
|
@@ -70,7 +70,6 @@ describe('ChangeRequestDialog: a request with no remaining changes', () => {
|
|
|
70
70
|
headSha: 'h',
|
|
71
71
|
baseSha: 'b',
|
|
72
72
|
files: [],
|
|
73
|
-
comments: [],
|
|
74
73
|
approvals: [],
|
|
75
74
|
mergeableInBevel: true,
|
|
76
75
|
mergeBlockedReasons: [],
|
|
@@ -121,7 +120,6 @@ function detailWith(approvals: FileApprovalState[]) {
|
|
|
121
120
|
sha: '',
|
|
122
121
|
rawUrl: '',
|
|
123
122
|
})),
|
|
124
|
-
comments: [],
|
|
125
123
|
approvals,
|
|
126
124
|
mergeableInBevel: true,
|
|
127
125
|
mergeBlockedReasons: [],
|
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
2
|
import { ExternalLink } from 'lucide-react';
|
|
3
3
|
import { Banner } from '../../../shared/components';
|
|
4
|
-
import { fetchFileAccess } from '../../access
|
|
4
|
+
import { fetchFileAccess } from '../../access';
|
|
5
5
|
import { FilePaneCard } from '../../workspace/components/FilePaneCard';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
DownloadFileButton,
|
|
9
|
-
} from '../../workspace/components/renderers/DownloadFileButton';
|
|
6
|
+
import { CanDownloadContext, RendererWorkspaceContext, kbFileUrl, getOrCreateWorkspace } from '../../workspace';
|
|
7
|
+
import { DownloadFileButton } from '../../workspace/components/renderers/DownloadFileButton';
|
|
10
8
|
import { READ_PANE } from '../../workspace/components/renderers/readPane';
|
|
11
|
-
import {
|
|
12
|
-
RendererWorkspaceContext,
|
|
13
|
-
getFileRenderer,
|
|
14
|
-
getRendererLayout,
|
|
15
|
-
} from '../../workspace/components/renderers';
|
|
16
|
-
import { kbFileUrl } from '../../workspace/routing/kb-routes';
|
|
17
|
-
import { getOrCreateWorkspace } from '../../workspace/services/workspace.api';
|
|
9
|
+
import { getFileRenderer, getRendererLayout } from '../../workspace/components/renderers';
|
|
18
10
|
|
|
19
11
|
/**
|
|
20
12
|
* A document or image shown with the FILE PAGE's viewer, read from a named
|