@bevel-software/platform-core-frontend 0.3.2 → 0.4.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/core/__tests__/ShellRoutes.test.tsx +95 -95
- package/src/lib/utils.ts +138 -138
- package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +156 -156
- package/src/modules/admin/components/UserAccountsPage.tsx +353 -353
- package/src/modules/layout/components/MaintenanceOverlay.tsx +104 -104
- package/src/modules/library/__tests__/DetailDialog.test.tsx +200 -200
- package/src/modules/library/__tests__/loadout.test.tsx +72 -72
- package/src/modules/library/__tests__/status.test.ts +117 -117
- package/src/modules/library/components/ChangeRequestDock.tsx +47 -47
- package/src/modules/library/components/CompareView.tsx +357 -357
- package/src/modules/library/components/DetailDialog.tsx +566 -566
- package/src/modules/library/components/GearIcon.tsx +12 -12
- package/src/modules/library/components/LibraryCard.tsx +132 -132
- package/src/modules/library/components/LibraryPage.tsx +254 -254
- package/src/modules/library/components/LoadoutSidebar.tsx +156 -156
- package/src/modules/library/components/StatusGem.tsx +21 -21
- package/src/modules/library/components/SuggestChange.tsx +171 -171
- package/src/modules/library/components/particles.ts +50 -50
- package/src/modules/library/library.css +320 -320
- package/src/modules/library/state/loadout.tsx +129 -129
- package/src/modules/library/utils/status.ts +116 -116
- package/src/modules/secrets-vault/components/SecretsPage.tsx +276 -276
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +51 -51
- package/src/modules/toolbar/components/AppSwitcher.tsx +108 -108
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +548 -548
- package/src/modules/workspace/components/FileExplorer.tsx +1068 -1068
- package/src/modules/workspace/components/FileViewer.tsx +906 -906
- package/src/modules/workspace/utils/fileTree.ts +179 -179
- package/src/shared/components/PageShell.tsx +51 -51
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { SecretsPage } from '../SecretsPage';
|
|
4
|
-
|
|
5
|
-
vi.mock('../../services/secrets.api', () => ({
|
|
6
|
-
listSecrets: vi.fn(async () => []),
|
|
7
|
-
createOAuthSecret: vi.fn(async () => {}),
|
|
8
|
-
deleteSecret: vi.fn(async () => {}),
|
|
9
|
-
startOAuth: vi.fn(async () => ''),
|
|
10
|
-
}));
|
|
11
|
-
vi.mock('../../services/tool-secrets.api', () => ({
|
|
12
|
-
listToolSecrets: vi.fn(async () => []),
|
|
13
|
-
setAdminVar: vi.fn(async () => {}),
|
|
14
|
-
setUserVar: vi.fn(async () => {}),
|
|
15
|
-
setOAuthClientSecret: vi.fn(async () => {}),
|
|
16
|
-
deleteAdminVar: vi.fn(async () => {}),
|
|
17
|
-
deleteUserVar: vi.fn(async () => {}),
|
|
18
|
-
}));
|
|
19
|
-
|
|
20
|
-
describe('SecretsPage', () => {
|
|
21
|
-
beforeEach(() => {
|
|
22
|
-
// Each test starts on a clean /secrets URL (no leftover fragment).
|
|
23
|
-
window.history.replaceState(null, '', '/secrets');
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('renders as a full page (no dialog) and loads the secret lists', async () => {
|
|
27
|
-
render(<SecretsPage />);
|
|
28
|
-
expect(screen.getByRole('heading', { name: 'Secrets' })).toBeInTheDocument();
|
|
29
|
-
expect(
|
|
30
|
-
await screen.findByText('No tools you can access declare secrets yet.'),
|
|
31
|
-
).toBeInTheDocument();
|
|
32
|
-
// Converted from the old gear-menu dialog: nothing modal is mounted.
|
|
33
|
-
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('surfaces the OAuth-callback success carried in the #authorized fragment and strips it', async () => {
|
|
37
|
-
window.history.replaceState(null, '', '/secrets#authorized');
|
|
38
|
-
render(<SecretsPage />);
|
|
39
|
-
expect(await screen.findByText('Authorization complete.')).toBeInTheDocument();
|
|
40
|
-
// The fragment is consumed so a refresh doesn't re-announce it.
|
|
41
|
-
expect(window.location.hash).toBe('');
|
|
42
|
-
expect(window.location.pathname).toBe('/secrets');
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('surfaces the OAuth-callback error carried in the #error fragment and strips it', async () => {
|
|
46
|
-
window.history.replaceState(null, '', '/secrets#error=Access%20denied');
|
|
47
|
-
render(<SecretsPage />);
|
|
48
|
-
expect(await screen.findByText('Access denied')).toBeInTheDocument();
|
|
49
|
-
expect(window.location.hash).toBe('');
|
|
50
|
-
});
|
|
51
|
-
});
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { SecretsPage } from '../SecretsPage';
|
|
4
|
+
|
|
5
|
+
vi.mock('../../services/secrets.api', () => ({
|
|
6
|
+
listSecrets: vi.fn(async () => []),
|
|
7
|
+
createOAuthSecret: vi.fn(async () => {}),
|
|
8
|
+
deleteSecret: vi.fn(async () => {}),
|
|
9
|
+
startOAuth: vi.fn(async () => ''),
|
|
10
|
+
}));
|
|
11
|
+
vi.mock('../../services/tool-secrets.api', () => ({
|
|
12
|
+
listToolSecrets: vi.fn(async () => []),
|
|
13
|
+
setAdminVar: vi.fn(async () => {}),
|
|
14
|
+
setUserVar: vi.fn(async () => {}),
|
|
15
|
+
setOAuthClientSecret: vi.fn(async () => {}),
|
|
16
|
+
deleteAdminVar: vi.fn(async () => {}),
|
|
17
|
+
deleteUserVar: vi.fn(async () => {}),
|
|
18
|
+
}));
|
|
19
|
+
|
|
20
|
+
describe('SecretsPage', () => {
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
// Each test starts on a clean /secrets URL (no leftover fragment).
|
|
23
|
+
window.history.replaceState(null, '', '/secrets');
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('renders as a full page (no dialog) and loads the secret lists', async () => {
|
|
27
|
+
render(<SecretsPage />);
|
|
28
|
+
expect(screen.getByRole('heading', { name: 'Secrets' })).toBeInTheDocument();
|
|
29
|
+
expect(
|
|
30
|
+
await screen.findByText('No tools you can access declare secrets yet.'),
|
|
31
|
+
).toBeInTheDocument();
|
|
32
|
+
// Converted from the old gear-menu dialog: nothing modal is mounted.
|
|
33
|
+
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('surfaces the OAuth-callback success carried in the #authorized fragment and strips it', async () => {
|
|
37
|
+
window.history.replaceState(null, '', '/secrets#authorized');
|
|
38
|
+
render(<SecretsPage />);
|
|
39
|
+
expect(await screen.findByText('Authorization complete.')).toBeInTheDocument();
|
|
40
|
+
// The fragment is consumed so a refresh doesn't re-announce it.
|
|
41
|
+
expect(window.location.hash).toBe('');
|
|
42
|
+
expect(window.location.pathname).toBe('/secrets');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('surfaces the OAuth-callback error carried in the #error fragment and strips it', async () => {
|
|
46
|
+
window.history.replaceState(null, '', '/secrets#error=Access%20denied');
|
|
47
|
+
render(<SecretsPage />);
|
|
48
|
+
expect(await screen.findByText('Access denied')).toBeInTheDocument();
|
|
49
|
+
expect(window.location.hash).toBe('');
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
-
import { Check, ChevronDown } from 'lucide-react';
|
|
3
|
-
import { useLocation, useNavigate } from 'react-router-dom';
|
|
4
|
-
import { activeAppId, useAppRegistry, type AppDef } from '../../../core/registry';
|
|
5
|
-
|
|
6
|
-
const MENU_ID = 'app-switcher-menu';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* The clickable brand in the toolbar's top-left: shows the product name and
|
|
10
|
-
* opens the app switcher — the list of top-level surfaces (core apps +
|
|
11
|
-
* registry-contributed ones) the user can move between.
|
|
12
|
-
*
|
|
13
|
-
* Open/close mechanics mirror AdminMenu: click toggles, an outside mousedown
|
|
14
|
-
* or Escape closes, and closing hands focus back to the trigger.
|
|
15
|
-
*/
|
|
16
|
-
export function AppSwitcher() {
|
|
17
|
-
const navigate = useNavigate();
|
|
18
|
-
const location = useLocation();
|
|
19
|
-
const registry = useAppRegistry();
|
|
20
|
-
const [open, setOpen] = useState(false);
|
|
21
|
-
const ref = useRef<HTMLDivElement>(null);
|
|
22
|
-
const buttonRef = useRef<HTMLButtonElement>(null);
|
|
23
|
-
|
|
24
|
-
// The shell merges the core apps into the registry (see CoreAppShell), so
|
|
25
|
-
// this list is complete — core Knowledge / Skills & Tools plus extensions.
|
|
26
|
-
const apps = useMemo(
|
|
27
|
-
() => [...registry.apps].sort((a, b) => (a.order ?? 100) - (b.order ?? 100)),
|
|
28
|
-
[registry],
|
|
29
|
-
);
|
|
30
|
-
const activeId = activeAppId(apps, location.pathname);
|
|
31
|
-
|
|
32
|
-
const close = () => {
|
|
33
|
-
setOpen(false);
|
|
34
|
-
buttonRef.current?.focus();
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
if (!open) return;
|
|
39
|
-
const onMouseDown = (e: MouseEvent) => {
|
|
40
|
-
if (ref.current && !ref.current.contains(e.target as Node)) {
|
|
41
|
-
close();
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const onKey = (e: KeyboardEvent) => {
|
|
45
|
-
if (e.key === 'Escape') close();
|
|
46
|
-
};
|
|
47
|
-
document.addEventListener('mousedown', onMouseDown);
|
|
48
|
-
document.addEventListener('keydown', onKey);
|
|
49
|
-
return () => {
|
|
50
|
-
document.removeEventListener('mousedown', onMouseDown);
|
|
51
|
-
document.removeEventListener('keydown', onKey);
|
|
52
|
-
};
|
|
53
|
-
}, [open]);
|
|
54
|
-
|
|
55
|
-
const select = (app: AppDef) => {
|
|
56
|
-
close();
|
|
57
|
-
if (app.id !== activeId) navigate(app.path);
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
return (
|
|
61
|
-
<div ref={ref} className="relative">
|
|
62
|
-
<button
|
|
63
|
-
ref={buttonRef}
|
|
64
|
-
type="button"
|
|
65
|
-
onClick={() => setOpen((v) => !v)}
|
|
66
|
-
className="flex items-center gap-1 px-1.5 py-1 rounded hover:bg-slate-100 text-slate-900"
|
|
67
|
-
title="Switch app"
|
|
68
|
-
aria-label="Switch app"
|
|
69
|
-
aria-haspopup="menu"
|
|
70
|
-
aria-expanded={open}
|
|
71
|
-
aria-controls={open ? MENU_ID : undefined}
|
|
72
|
-
>
|
|
73
|
-
<span className="text-sm font-semibold tracking-wide">Bevel</span>
|
|
74
|
-
<ChevronDown size={14} className="text-slate-500" />
|
|
75
|
-
</button>
|
|
76
|
-
{open && (
|
|
77
|
-
<div
|
|
78
|
-
id={MENU_ID}
|
|
79
|
-
role="menu"
|
|
80
|
-
className="absolute left-0 top-full mt-1 w-64 rounded-md border border-slate-200 bg-white py-1 shadow-lg z-50"
|
|
81
|
-
>
|
|
82
|
-
<div className="px-3 pt-1 pb-1.5 text-[10px] font-semibold uppercase tracking-wider text-slate-400">
|
|
83
|
-
Apps
|
|
84
|
-
</div>
|
|
85
|
-
{apps.map((app) => (
|
|
86
|
-
<button
|
|
87
|
-
key={app.id}
|
|
88
|
-
type="button"
|
|
89
|
-
role="menuitem"
|
|
90
|
-
onClick={() => select(app)}
|
|
91
|
-
className="flex w-full items-start gap-2 px-3 py-2 text-left hover:bg-slate-100"
|
|
92
|
-
>
|
|
93
|
-
<span className="w-4 pt-0.5 shrink-0 text-slate-700">
|
|
94
|
-
{app.id === activeId && <Check size={14} aria-label="Current app" />}
|
|
95
|
-
</span>
|
|
96
|
-
<span className="min-w-0">
|
|
97
|
-
<span className="block text-sm text-slate-800">{app.label}</span>
|
|
98
|
-
{app.description && (
|
|
99
|
-
<span className="block text-xs text-slate-500">{app.description}</span>
|
|
100
|
-
)}
|
|
101
|
-
</span>
|
|
102
|
-
</button>
|
|
103
|
-
))}
|
|
104
|
-
</div>
|
|
105
|
-
)}
|
|
106
|
-
</div>
|
|
107
|
-
);
|
|
108
|
-
}
|
|
1
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { Check, ChevronDown } from 'lucide-react';
|
|
3
|
+
import { useLocation, useNavigate } from 'react-router-dom';
|
|
4
|
+
import { activeAppId, useAppRegistry, type AppDef } from '../../../core/registry';
|
|
5
|
+
|
|
6
|
+
const MENU_ID = 'app-switcher-menu';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The clickable brand in the toolbar's top-left: shows the product name and
|
|
10
|
+
* opens the app switcher — the list of top-level surfaces (core apps +
|
|
11
|
+
* registry-contributed ones) the user can move between.
|
|
12
|
+
*
|
|
13
|
+
* Open/close mechanics mirror AdminMenu: click toggles, an outside mousedown
|
|
14
|
+
* or Escape closes, and closing hands focus back to the trigger.
|
|
15
|
+
*/
|
|
16
|
+
export function AppSwitcher() {
|
|
17
|
+
const navigate = useNavigate();
|
|
18
|
+
const location = useLocation();
|
|
19
|
+
const registry = useAppRegistry();
|
|
20
|
+
const [open, setOpen] = useState(false);
|
|
21
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
22
|
+
const buttonRef = useRef<HTMLButtonElement>(null);
|
|
23
|
+
|
|
24
|
+
// The shell merges the core apps into the registry (see CoreAppShell), so
|
|
25
|
+
// this list is complete — core Knowledge / Skills & Tools plus extensions.
|
|
26
|
+
const apps = useMemo(
|
|
27
|
+
() => [...registry.apps].sort((a, b) => (a.order ?? 100) - (b.order ?? 100)),
|
|
28
|
+
[registry],
|
|
29
|
+
);
|
|
30
|
+
const activeId = activeAppId(apps, location.pathname);
|
|
31
|
+
|
|
32
|
+
const close = () => {
|
|
33
|
+
setOpen(false);
|
|
34
|
+
buttonRef.current?.focus();
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (!open) return;
|
|
39
|
+
const onMouseDown = (e: MouseEvent) => {
|
|
40
|
+
if (ref.current && !ref.current.contains(e.target as Node)) {
|
|
41
|
+
close();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const onKey = (e: KeyboardEvent) => {
|
|
45
|
+
if (e.key === 'Escape') close();
|
|
46
|
+
};
|
|
47
|
+
document.addEventListener('mousedown', onMouseDown);
|
|
48
|
+
document.addEventListener('keydown', onKey);
|
|
49
|
+
return () => {
|
|
50
|
+
document.removeEventListener('mousedown', onMouseDown);
|
|
51
|
+
document.removeEventListener('keydown', onKey);
|
|
52
|
+
};
|
|
53
|
+
}, [open]);
|
|
54
|
+
|
|
55
|
+
const select = (app: AppDef) => {
|
|
56
|
+
close();
|
|
57
|
+
if (app.id !== activeId) navigate(app.path);
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<div ref={ref} className="relative">
|
|
62
|
+
<button
|
|
63
|
+
ref={buttonRef}
|
|
64
|
+
type="button"
|
|
65
|
+
onClick={() => setOpen((v) => !v)}
|
|
66
|
+
className="flex items-center gap-1 px-1.5 py-1 rounded hover:bg-slate-100 text-slate-900"
|
|
67
|
+
title="Switch app"
|
|
68
|
+
aria-label="Switch app"
|
|
69
|
+
aria-haspopup="menu"
|
|
70
|
+
aria-expanded={open}
|
|
71
|
+
aria-controls={open ? MENU_ID : undefined}
|
|
72
|
+
>
|
|
73
|
+
<span className="text-sm font-semibold tracking-wide">Bevel</span>
|
|
74
|
+
<ChevronDown size={14} className="text-slate-500" />
|
|
75
|
+
</button>
|
|
76
|
+
{open && (
|
|
77
|
+
<div
|
|
78
|
+
id={MENU_ID}
|
|
79
|
+
role="menu"
|
|
80
|
+
className="absolute left-0 top-full mt-1 w-64 rounded-md border border-slate-200 bg-white py-1 shadow-lg z-50"
|
|
81
|
+
>
|
|
82
|
+
<div className="px-3 pt-1 pb-1.5 text-[10px] font-semibold uppercase tracking-wider text-slate-400">
|
|
83
|
+
Apps
|
|
84
|
+
</div>
|
|
85
|
+
{apps.map((app) => (
|
|
86
|
+
<button
|
|
87
|
+
key={app.id}
|
|
88
|
+
type="button"
|
|
89
|
+
role="menuitem"
|
|
90
|
+
onClick={() => select(app)}
|
|
91
|
+
className="flex w-full items-start gap-2 px-3 py-2 text-left hover:bg-slate-100"
|
|
92
|
+
>
|
|
93
|
+
<span className="w-4 pt-0.5 shrink-0 text-slate-700">
|
|
94
|
+
{app.id === activeId && <Check size={14} aria-label="Current app" />}
|
|
95
|
+
</span>
|
|
96
|
+
<span className="min-w-0">
|
|
97
|
+
<span className="block text-sm text-slate-800">{app.label}</span>
|
|
98
|
+
{app.description && (
|
|
99
|
+
<span className="block text-xs text-slate-500">{app.description}</span>
|
|
100
|
+
)}
|
|
101
|
+
</span>
|
|
102
|
+
</button>
|
|
103
|
+
))}
|
|
104
|
+
</div>
|
|
105
|
+
)}
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
}
|