@bevel-software/platform-core-frontend 0.12.0 → 0.13.1
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/modules/git/__tests__/GitSyncFailedBanner.test.tsx +181 -0
- package/src/modules/git/components/GitSyncFailedBanner.tsx +106 -0
- package/src/modules/library/__tests__/McpServerSection.test.tsx +95 -0
- package/src/modules/library/__tests__/ToolConnectionSection.test.tsx +31 -0
- package/src/modules/library/__tests__/ToolVarRow.test.tsx +18 -0
- package/src/modules/library/components/tool-page/McpServerSection.tsx +338 -65
- package/src/modules/library/components/tool-page/ToolConnectionSection.tsx +25 -9
- package/src/modules/library/components/tool-page/ToolVarRow.tsx +8 -0
- package/src/modules/library/services/tools.api.ts +23 -1
- package/src/modules/secrets-vault/components/SecretsPage.tsx +8 -0
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +20 -11
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +82 -82
- package/src/modules/secrets-vault/services/secrets.api.ts +2 -0
- package/src/modules/secrets-vault/services/tool-secrets.api.ts +6 -3
- package/src/modules/workspace/components/FileViewer.tsx +3 -0
|
@@ -31,7 +31,7 @@ export function ToolSecretsPanel({ tool, onChanged }: { tool: ToolSecrets; onCha
|
|
|
31
31
|
if (tool.variables.length === 0) {
|
|
32
32
|
return (
|
|
33
33
|
<div className="flex flex-col gap-3">
|
|
34
|
-
<SetupBanner setup={tool.setup} />
|
|
34
|
+
<SetupBanner setup={tool.setup} declared={tool.variables.some((v) => v.oauth)} />
|
|
35
35
|
{tool.setup?.kind !== 'oauth-manual' && (
|
|
36
36
|
<p className="text-detail text-ink-muted">
|
|
37
37
|
{tool.setup?.kind === 'open' ? (
|
|
@@ -51,7 +51,7 @@ export function ToolSecretsPanel({ tool, onChanged }: { tool: ToolSecrets; onCha
|
|
|
51
51
|
|
|
52
52
|
return (
|
|
53
53
|
<div className="flex flex-col gap-3.5">
|
|
54
|
-
<SetupBanner setup={tool.setup} />
|
|
54
|
+
<SetupBanner setup={tool.setup} declared={tool.variables.some((v) => v.oauth)} />
|
|
55
55
|
{adminVars.length > 0 && (
|
|
56
56
|
<VarPlugin
|
|
57
57
|
title="Set by the tool owner"
|
|
@@ -95,21 +95,30 @@ function Chip({ children }: { children: React.ReactNode }) {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
|
-
* When a `type: mcp` server needs sign-in
|
|
99
|
-
* (
|
|
100
|
-
* the tool would otherwise look like it needs
|
|
101
|
-
*
|
|
98
|
+
* When a `type: mcp` server needs a sign-in with an owner-registered OAuth app
|
|
99
|
+
* (auto-discovery couldn't register one — Google, HubSpot — or the declaration
|
|
100
|
+
* already names a client id), the tool would otherwise look like it needs
|
|
101
|
+
* nothing until the owner finishes. Make the remaining step explicit, and
|
|
102
|
+
* surface the discovery `reason` so the admin knows what still blocks it.
|
|
102
103
|
* The `open` / `oauth-auto` cases need no banner — they're either self-evident
|
|
103
104
|
* (a sign-in variable appears below) or nothing-to-do.
|
|
104
105
|
*/
|
|
105
|
-
function SetupBanner({ setup }: { setup: ToolSetup | null }) {
|
|
106
|
+
function SetupBanner({ setup, declared }: { setup: ToolSetup | null; declared: boolean }) {
|
|
106
107
|
if (setup?.kind !== 'oauth-manual') return null;
|
|
107
108
|
return (
|
|
108
109
|
<Banner tone="wait" role="status">
|
|
109
|
-
<span className="font-semibold">Sign-in setup needed.</span>
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
<span className="font-semibold">Sign-in setup needed.</span>{' '}
|
|
111
|
+
{declared ? (
|
|
112
|
+
<>The sign-in is declared — a tool writer sets its client secret here to finish.</>
|
|
113
|
+
) : (
|
|
114
|
+
<>
|
|
115
|
+
This server needs users to sign in, but Bevel couldn't set that up automatically. A
|
|
116
|
+
tool writer must register an OAuth app with the provider and declare its client id on a
|
|
117
|
+
user-scoped sign-in variable — under <Chip>Edit server</Chip> on the tool's page for
|
|
118
|
+
an MCP server, or in the <Chip>.tool</Chip> file's <Chip>variables</Chip> block —
|
|
119
|
+
then set its client secret here.
|
|
120
|
+
</>
|
|
121
|
+
)}
|
|
113
122
|
{setup.reason && <em className="mt-1 block text-detail">{setup.reason}</em>}
|
|
114
123
|
</Banner>
|
|
115
124
|
);
|
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { MemoryRouter } from 'react-router-dom';
|
|
4
|
-
import type { ToolSecrets } from '../../services/tool-secrets.api';
|
|
5
|
-
import { SecretsPage } from '../SecretsPage';
|
|
6
|
-
|
|
7
|
-
const toolSecretsMock = vi.hoisted(() => ({ listToolSecrets: vi.fn() }));
|
|
8
|
-
|
|
9
|
-
vi.mock('../../services/secrets.api', () => ({
|
|
10
|
-
listSecrets: vi.fn(async () => []),
|
|
11
|
-
createOAuthSecret: vi.fn(async () => {}),
|
|
12
|
-
deleteSecret: vi.fn(async () => {}),
|
|
13
|
-
startOAuth: vi.fn(async () => ''),
|
|
14
|
-
}));
|
|
15
|
-
vi.mock('../../services/tool-secrets.api', () => ({
|
|
16
|
-
listToolSecrets: toolSecretsMock.listToolSecrets,
|
|
17
|
-
setAdminVar: vi.fn(async () => {}),
|
|
18
|
-
setUserVar: vi.fn(async () => {}),
|
|
19
|
-
setOAuthClientSecret: vi.fn(async () => {}),
|
|
20
|
-
deleteAdminVar: vi.fn(async () => {}),
|
|
21
|
-
deleteUserVar: vi.fn(async () => {}),
|
|
22
|
-
}));
|
|
23
|
-
|
|
24
|
-
/** The page carries links now, so it needs a router around it. */
|
|
25
|
-
function renderPage() {
|
|
26
|
-
return render(
|
|
27
|
-
<MemoryRouter>
|
|
28
|
-
<SecretsPage />
|
|
29
|
-
</MemoryRouter>,
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
describe('SecretsPage', () => {
|
|
34
|
-
beforeEach(() => {
|
|
35
|
-
// Each test starts on a clean /secrets URL (no leftover fragment).
|
|
36
|
-
window.history.replaceState(null, '', '/secrets');
|
|
37
|
-
toolSecretsMock.listToolSecrets.mockReset().mockResolvedValue([]);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('renders as a full page (no dialog) and loads the secret lists', async () => {
|
|
41
|
-
renderPage();
|
|
42
|
-
expect(screen.getByRole('heading', { name: 'Secrets' })).toBeInTheDocument();
|
|
43
|
-
expect(
|
|
44
|
-
await screen.findByText('No tools you can access declare secrets yet.'),
|
|
45
|
-
).toBeInTheDocument();
|
|
46
|
-
// Converted from the old gear-menu dialog: nothing modal is mounted.
|
|
47
|
-
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('links each tool name at its own page', async () => {
|
|
51
|
-
const heyreach: ToolSecrets = {
|
|
52
|
-
slug: 'heyreach',
|
|
53
|
-
name: 'heyreach',
|
|
54
|
-
path: 'Plugins/GTM/heyreach.tool',
|
|
55
|
-
type: 'inline',
|
|
56
|
-
setup: null,
|
|
57
|
-
canWrite: false,
|
|
58
|
-
variables: [],
|
|
59
|
-
};
|
|
60
|
-
toolSecretsMock.listToolSecrets.mockResolvedValue([heyreach]);
|
|
61
|
-
|
|
62
|
-
renderPage();
|
|
63
|
-
const link = await screen.findByRole('link', { name: 'Open heyreach' });
|
|
64
|
-
expect(link).toHaveAttribute('href', '/skills-and-tools/tools/heyreach');
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('surfaces the OAuth-callback success carried in the #authorized fragment and strips it', async () => {
|
|
68
|
-
window.history.replaceState(null, '', '/secrets#authorized');
|
|
69
|
-
renderPage();
|
|
70
|
-
expect(await screen.findByText('Authorization complete.')).toBeInTheDocument();
|
|
71
|
-
// The fragment is consumed so a refresh doesn't re-announce it.
|
|
72
|
-
expect(window.location.hash).toBe('');
|
|
73
|
-
expect(window.location.pathname).toBe('/secrets');
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('surfaces the OAuth-callback error carried in the #error fragment and strips it', async () => {
|
|
77
|
-
window.history.replaceState(null, '', '/secrets#error=Access%20denied');
|
|
78
|
-
renderPage();
|
|
79
|
-
expect(await screen.findByText('Access denied')).toBeInTheDocument();
|
|
80
|
-
expect(window.location.hash).toBe('');
|
|
81
|
-
});
|
|
82
|
-
});
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
4
|
+
import type { ToolSecrets } from '../../services/tool-secrets.api';
|
|
5
|
+
import { SecretsPage } from '../SecretsPage';
|
|
6
|
+
|
|
7
|
+
const toolSecretsMock = vi.hoisted(() => ({ listToolSecrets: vi.fn() }));
|
|
8
|
+
|
|
9
|
+
vi.mock('../../services/secrets.api', () => ({
|
|
10
|
+
listSecrets: vi.fn(async () => []),
|
|
11
|
+
createOAuthSecret: vi.fn(async () => {}),
|
|
12
|
+
deleteSecret: vi.fn(async () => {}),
|
|
13
|
+
startOAuth: vi.fn(async () => ''),
|
|
14
|
+
}));
|
|
15
|
+
vi.mock('../../services/tool-secrets.api', () => ({
|
|
16
|
+
listToolSecrets: toolSecretsMock.listToolSecrets,
|
|
17
|
+
setAdminVar: vi.fn(async () => {}),
|
|
18
|
+
setUserVar: vi.fn(async () => {}),
|
|
19
|
+
setOAuthClientSecret: vi.fn(async () => {}),
|
|
20
|
+
deleteAdminVar: vi.fn(async () => {}),
|
|
21
|
+
deleteUserVar: vi.fn(async () => {}),
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
/** The page carries links now, so it needs a router around it. */
|
|
25
|
+
function renderPage() {
|
|
26
|
+
return render(
|
|
27
|
+
<MemoryRouter>
|
|
28
|
+
<SecretsPage />
|
|
29
|
+
</MemoryRouter>,
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
describe('SecretsPage', () => {
|
|
34
|
+
beforeEach(() => {
|
|
35
|
+
// Each test starts on a clean /secrets URL (no leftover fragment).
|
|
36
|
+
window.history.replaceState(null, '', '/secrets');
|
|
37
|
+
toolSecretsMock.listToolSecrets.mockReset().mockResolvedValue([]);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('renders as a full page (no dialog) and loads the secret lists', async () => {
|
|
41
|
+
renderPage();
|
|
42
|
+
expect(screen.getByRole('heading', { name: 'Secrets' })).toBeInTheDocument();
|
|
43
|
+
expect(
|
|
44
|
+
await screen.findByText('No tools you can access declare secrets yet.'),
|
|
45
|
+
).toBeInTheDocument();
|
|
46
|
+
// Converted from the old gear-menu dialog: nothing modal is mounted.
|
|
47
|
+
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('links each tool name at its own page', async () => {
|
|
51
|
+
const heyreach: ToolSecrets = {
|
|
52
|
+
slug: 'heyreach',
|
|
53
|
+
name: 'heyreach',
|
|
54
|
+
path: 'Plugins/GTM/heyreach.tool',
|
|
55
|
+
type: 'inline',
|
|
56
|
+
setup: null,
|
|
57
|
+
canWrite: false,
|
|
58
|
+
variables: [],
|
|
59
|
+
};
|
|
60
|
+
toolSecretsMock.listToolSecrets.mockResolvedValue([heyreach]);
|
|
61
|
+
|
|
62
|
+
renderPage();
|
|
63
|
+
const link = await screen.findByRole('link', { name: 'Open heyreach' });
|
|
64
|
+
expect(link).toHaveAttribute('href', '/skills-and-tools/tools/heyreach');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('surfaces the OAuth-callback success carried in the #authorized fragment and strips it', async () => {
|
|
68
|
+
window.history.replaceState(null, '', '/secrets#authorized');
|
|
69
|
+
renderPage();
|
|
70
|
+
expect(await screen.findByText('Authorization complete.')).toBeInTheDocument();
|
|
71
|
+
// The fragment is consumed so a refresh doesn't re-announce it.
|
|
72
|
+
expect(window.location.hash).toBe('');
|
|
73
|
+
expect(window.location.pathname).toBe('/secrets');
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('surfaces the OAuth-callback error carried in the #error fragment and strips it', async () => {
|
|
77
|
+
window.history.replaceState(null, '', '/secrets#error=Access%20denied');
|
|
78
|
+
renderPage();
|
|
79
|
+
expect(await screen.findByText('Access denied')).toBeInTheDocument();
|
|
80
|
+
expect(window.location.hash).toBe('');
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -22,6 +22,8 @@ export interface OAuthProviderConfig {
|
|
|
22
22
|
scopes?: string[];
|
|
23
23
|
/** Extra static params appended to the authorization request (e.g. `audience`). */
|
|
24
24
|
authParams?: Record<string, string>;
|
|
25
|
+
/** PKCE (S256) on the authorization-code flow — what MCP-spec providers require. */
|
|
26
|
+
pkce?: boolean;
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
async function unwrap(res: Response, fallback: string): Promise<never> {
|
|
@@ -33,9 +33,12 @@ export interface ToolVarStatus {
|
|
|
33
33
|
* For a `type: mcp` tool, the setup requirement auto-discovery found:
|
|
34
34
|
* - `open` — no auth; nothing to configure.
|
|
35
35
|
* - `oauth-auto` — sign-in was set up automatically (appears as a user var).
|
|
36
|
-
* - `oauth-manual` — the
|
|
37
|
-
*
|
|
38
|
-
*
|
|
36
|
+
* - `oauth-manual` — the sign-in needs an OAuth app the owner registers with
|
|
37
|
+
* the provider: a tool writer declares its client id on a
|
|
38
|
+
* user-scoped variable (the server editor for an mcp.json
|
|
39
|
+
* server; the `.tool` file otherwise) and sets its client
|
|
40
|
+
* secret. `reason` is present only while something still
|
|
41
|
+
* blocks the sign-in, and says what.
|
|
39
42
|
*/
|
|
40
43
|
export interface ToolSetup {
|
|
41
44
|
kind: 'open' | 'oauth-auto' | 'oauth-manual';
|
|
@@ -12,6 +12,7 @@ import { LayoutContext } from '../../layout/state/layout.context';
|
|
|
12
12
|
import { useParams } from 'react-router-dom';
|
|
13
13
|
import { useCanonicalFileUrl, useFileNav } from '../routing/kb-routes';
|
|
14
14
|
import { PullNeededBanner } from '../../git/components/PullNeededBanner';
|
|
15
|
+
import { GitSyncFailedBanner } from '../../git/components/GitSyncFailedBanner';
|
|
15
16
|
import { useFileAccess } from '../../access/hooks/useFileAccess';
|
|
16
17
|
import { FileHistoryPanel } from '../../git/components/FileHistoryPanel';
|
|
17
18
|
import { FileComparisonPanel } from '../../git/components/FileComparisonPanel';
|
|
@@ -836,6 +837,7 @@ export function FileViewer() {
|
|
|
836
837
|
return (
|
|
837
838
|
<div className="h-full w-full flex flex-col bg-white min-w-0 relative">
|
|
838
839
|
<PullNeededBanner />
|
|
840
|
+
<GitSyncFailedBanner />
|
|
839
841
|
<EditorTabs />
|
|
840
842
|
<div className="flex-1 flex items-center justify-center px-6">
|
|
841
843
|
<div className="w-full max-w-md text-center">
|
|
@@ -1056,6 +1058,7 @@ export function FileViewer() {
|
|
|
1056
1058
|
return (
|
|
1057
1059
|
<div className="h-full w-full flex flex-col bg-white min-w-0 relative">
|
|
1058
1060
|
<PullNeededBanner />
|
|
1061
|
+
<GitSyncFailedBanner />
|
|
1059
1062
|
{/* No "you don't have permission to edit" banner, deliberately: for a
|
|
1060
1063
|
reader the restriction is not news worth a stripe across every page —
|
|
1061
1064
|
the Propose changes affordance already says what they CAN do, and the
|