@bevel-software/platform-core-frontend 0.4.0 → 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.
Files changed (30) hide show
  1. package/package.json +2 -2
  2. package/src/core/__tests__/ShellRoutes.test.tsx +95 -95
  3. package/src/lib/utils.ts +138 -138
  4. package/src/modules/admin/__tests__/UserAccountsPage.test.tsx +156 -156
  5. package/src/modules/admin/components/UserAccountsPage.tsx +353 -353
  6. package/src/modules/layout/components/MaintenanceOverlay.tsx +104 -104
  7. package/src/modules/library/__tests__/DetailDialog.test.tsx +200 -200
  8. package/src/modules/library/__tests__/loadout.test.tsx +72 -72
  9. package/src/modules/library/__tests__/status.test.ts +117 -117
  10. package/src/modules/library/components/ChangeRequestDock.tsx +47 -47
  11. package/src/modules/library/components/CompareView.tsx +357 -357
  12. package/src/modules/library/components/DetailDialog.tsx +566 -566
  13. package/src/modules/library/components/GearIcon.tsx +12 -12
  14. package/src/modules/library/components/LibraryCard.tsx +132 -132
  15. package/src/modules/library/components/LibraryPage.tsx +254 -254
  16. package/src/modules/library/components/LoadoutSidebar.tsx +156 -156
  17. package/src/modules/library/components/StatusGem.tsx +21 -21
  18. package/src/modules/library/components/SuggestChange.tsx +171 -171
  19. package/src/modules/library/components/particles.ts +50 -50
  20. package/src/modules/library/library.css +320 -320
  21. package/src/modules/library/state/loadout.tsx +129 -129
  22. package/src/modules/library/utils/status.ts +116 -116
  23. package/src/modules/secrets-vault/components/SecretsPage.tsx +276 -276
  24. package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +51 -51
  25. package/src/modules/toolbar/components/AppSwitcher.tsx +108 -108
  26. package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +548 -548
  27. package/src/modules/workspace/components/FileExplorer.tsx +1068 -1068
  28. package/src/modules/workspace/components/FileViewer.tsx +906 -906
  29. package/src/modules/workspace/utils/fileTree.ts +179 -179
  30. package/src/shared/components/PageShell.tsx +51 -51
@@ -1,254 +1,254 @@
1
- import { useMemo, useState } from 'react';
2
- import { useNavigate } from 'react-router-dom';
3
- import '../library.css';
4
- import { LoadoutProvider, useLoadout, type LoadoutKind } from '../state/loadout';
5
- import { LibraryToastProvider, useLibraryToast } from '../state/toast';
6
- import { useLibraryData } from '../hooks/useLibraryData';
7
- import {
8
- filterLibraryItems,
9
- neededToolsFor,
10
- skillStatus,
11
- toolStatus,
12
- type AttentionStatus,
13
- type LibraryCategory,
14
- } from '../utils/status';
15
- import { LibraryCard } from './LibraryCard';
16
- import { LoadoutSidebar, type LoadoutRow } from './LoadoutSidebar';
17
- import { DetailDialog, type DetailTarget } from './DetailDialog';
18
- import { flyParticles } from './particles';
19
-
20
- /**
21
- * The Library — the core skills / integrations / loadout view (the Skills &
22
- * Tools app surface at `/skills-and-tools`, registered in the core shell).
23
- * Game-style visual direction from
24
- * the approved mock `mocks/mock-a2-game-library.html`: teal accent, status
25
- * gems, tilting cards, loadout sidebar with particle flight. All data is real
26
- * (skills catalog, secrets-vault connection status, workflow change
27
- * requests); only the loadout itself is a documented client-side stub.
28
- */
29
- export function LibraryPage() {
30
- return (
31
- <LoadoutProvider>
32
- <LibraryToastProvider>
33
- <LibraryPageInner />
34
- </LibraryToastProvider>
35
- </LoadoutProvider>
36
- );
37
- }
38
-
39
- interface GalleryItem {
40
- kind: 'skill' | 'integration';
41
- id: string;
42
- name: string;
43
- description: string;
44
- owned: boolean;
45
- status: AttentionStatus;
46
- }
47
-
48
- function LibraryPageInner() {
49
- const data = useLibraryData();
50
- const loadout = useLoadout();
51
- const toast = useLibraryToast();
52
- const navigate = useNavigate();
53
- const [category, setCategory] = useState<LibraryCategory>('skills');
54
- const [query, setQuery] = useState('');
55
- const [detail, setDetail] = useState<DetailTarget | null>(null);
56
-
57
- const items: GalleryItem[] = useMemo(() => {
58
- const skillItems: GalleryItem[] = data.skills.map((s) => ({
59
- kind: 'skill',
60
- id: s.name,
61
- name: s.name,
62
- description: s.description,
63
- owned: data.ownedSkills.has(s.name),
64
- status: skillStatus(
65
- neededToolsFor({ allowedTools: data.allowedToolsBySkill.get(s.name) }, data.tools),
66
- ),
67
- }));
68
- const toolItems: GalleryItem[] = data.tools.map((t) => ({
69
- kind: 'integration',
70
- id: t.slug,
71
- name: t.name,
72
- // The browser tool surface exposes no human description for a `.tool`
73
- // manual yet (see report) — the card stays clean, detail lives in ⓘ.
74
- description: '',
75
- owned: t.canWrite,
76
- status: toolStatus(t),
77
- }));
78
- return [...skillItems, ...toolItems];
79
- }, [data.skills, data.tools, data.ownedSkills, data.allowedToolsBySkill]);
80
-
81
- const visible = useMemo(
82
- () => filterLibraryItems(items, category, query),
83
- [items, category, query],
84
- );
85
-
86
- const counts = useMemo(
87
- () => ({
88
- skills: items.filter((i) => i.kind === 'skill').length,
89
- integrations: items.filter((i) => i.kind === 'integration').length,
90
- owned: items.filter((i) => i.owned).length,
91
- }),
92
- [items],
93
- );
94
-
95
- const rows: LoadoutRow[] = useMemo(() => {
96
- const byKey = new Map(items.map((i) => [`${i.kind}:${i.id}`, i]));
97
- const pick = (kind: LoadoutKind, ids: string[]) =>
98
- ids
99
- .map((id) => byKey.get(`${kind}:${id}`))
100
- .filter((i): i is GalleryItem => i !== undefined)
101
- .map((i) => ({ kind, id: i.id, name: i.name, status: i.status }));
102
- return [...pick('skill', loadout.skills), ...pick('integration', loadout.integrations)];
103
- }, [items, loadout.skills, loadout.integrations]);
104
-
105
- const attentionCount = rows.filter((r) => r.status.state !== 'ok').length;
106
-
107
- function toggleItem(item: GalleryItem, fromRect?: DOMRect) {
108
- const added = loadout.toggle(item.kind, item.id);
109
- if (added) {
110
- toast(
111
- item.status.state === 'ok'
112
- ? `${item.name} added — ready to go`
113
- : `${item.name} added — needs a quick sign-in`,
114
- );
115
- if (fromRect) flyParticles(fromRect, item.kind, item.id);
116
- }
117
- }
118
-
119
- function openDetail(item: GalleryItem) {
120
- if (item.kind === 'skill') {
121
- const skill = data.skills.find((s) => s.name === item.id);
122
- if (skill) setDetail({ kind: 'skill', skill, owned: item.owned });
123
- } else {
124
- const tool = data.tools.find((t) => t.slug === item.id);
125
- if (tool) setDetail({ kind: 'integration', tool });
126
- }
127
- }
128
-
129
- const chip = (cat: LibraryCategory, label: string, count: number) => (
130
- <button
131
- key={cat}
132
- type="button"
133
- aria-pressed={category === cat}
134
- className={`flex items-center gap-1.5 rounded-full border px-4 py-1.5 text-[12.5px] font-semibold transition-all ${
135
- category === cat
136
- ? 'border-[#7fd0c4] bg-gradient-to-br from-[#e6f7f4] to-[#d5f1ec] text-[#0f766e] shadow-[0_2px_10px_rgba(13,148,136,0.22)]'
137
- : 'border-slate-200 bg-white text-slate-500 hover:border-[#7fd0c4] hover:text-slate-800'
138
- }`}
139
- onClick={() => setCategory(cat)}
140
- >
141
- {label}
142
- <span
143
- className={`rounded-full px-1.5 text-[10.5px] font-bold ${
144
- category === cat ? 'bg-[#0d948826]' : 'bg-slate-900/5'
145
- }`}
146
- >
147
- {count}
148
- </span>
149
- </button>
150
- );
151
-
152
- return (
153
- <div className="flex h-full min-h-0 bg-[#eef1f6] text-slate-800">
154
- <LoadoutSidebar
155
- rows={rows}
156
- onOpen={(row) => {
157
- const item = items.find((i) => i.kind === row.kind && i.id === row.id);
158
- if (item) openDetail(item);
159
- }}
160
- onRemove={(row) => loadout.remove(row.kind, row.id)}
161
- attentionCount={attentionCount}
162
- onFinishSetup={() => navigate('/connect')}
163
- />
164
-
165
- <main
166
- className="min-w-0 flex-1 overflow-y-auto px-8 py-6"
167
- style={{
168
- background:
169
- 'radial-gradient(900px 500px at 85% -10%, rgba(13,148,136,.08), transparent 60%), radial-gradient(700px 500px at -10% 110%, rgba(59,130,246,.06), transparent 55%)',
170
- }}
171
- >
172
- <div className="mb-1 flex items-center gap-4">
173
- <div>
174
- <h1 className="text-[26px] font-bold tracking-tight">Library</h1>
175
- <div className="text-[13px] text-slate-500">
176
- Click a card to add it to your loadout · open a card's details for more.
177
- </div>
178
- </div>
179
- <div className="ml-auto flex w-64 items-center gap-2 rounded-[11px] border border-slate-200 bg-white px-3.5 py-2 shadow-[0_1px_4px_rgba(22,35,58,0.05)]">
180
- <input
181
- className="w-full bg-transparent text-[13px] outline-none placeholder:text-slate-400"
182
- placeholder="Search the library…"
183
- aria-label="Search the library"
184
- value={query}
185
- onChange={(e) => setQuery(e.target.value)}
186
- />
187
- </div>
188
- </div>
189
-
190
- <div className="mb-5 mt-4 flex gap-2">
191
- {chip('skills', 'Skills', counts.skills)}
192
- {chip('integrations', 'Integrations', counts.integrations)}
193
- {chip('owned', 'Owned by me', counts.owned)}
194
- </div>
195
-
196
- {data.error ? (
197
- <div className="rounded-xl border border-[#f3c4c4] bg-[#fdecec] px-4 py-3 text-sm text-[#c53030]">
198
- {data.error}
199
- <button type="button" className="ml-3 font-bold underline" onClick={data.reload}>
200
- Try again
201
- </button>
202
- </div>
203
- ) : data.loading ? (
204
- <div className="py-16 text-center text-sm text-slate-400">Loading the library…</div>
205
- ) : visible.length === 0 ? (
206
- <div className="py-16 text-center text-sm text-slate-400">Nothing here matches yet.</div>
207
- ) : (
208
- <div className="lib-grid grid grid-cols-[repeat(auto-fill,minmax(228px,1fr))] gap-5 pb-14">
209
- {visible.map((item) => (
210
- <LibraryCard
211
- key={`${item.kind}:${item.id}`}
212
- kind={item.kind}
213
- id={item.id}
214
- name={item.name}
215
- description={item.description}
216
- owned={item.owned}
217
- status={item.status}
218
- picked={loadout.isIn(item.kind, item.id)}
219
- onToggle={(rect) => toggleItem(item, rect)}
220
- onInfo={() => openDetail(item)}
221
- />
222
- ))}
223
- </div>
224
- )}
225
- </main>
226
-
227
- {detail && (
228
- <DetailDialog
229
- target={detail}
230
- tools={data.tools}
231
- skills={data.skills}
232
- allowedToolsBySkill={data.allowedToolsBySkill}
233
- crs={data.crs}
234
- myCrNumbers={data.myCrNumbers}
235
- inLoadout={
236
- detail.kind === 'skill'
237
- ? loadout.isIn('skill', detail.skill.name)
238
- : loadout.isIn('integration', detail.tool.slug)
239
- }
240
- onToggleLoadout={() => {
241
- const item = items.find(
242
- (i) =>
243
- i.kind === (detail.kind === 'skill' ? 'skill' : 'integration') &&
244
- i.id === (detail.kind === 'skill' ? detail.skill.name : detail.tool.slug),
245
- );
246
- if (item) toggleItem(item);
247
- }}
248
- onClose={() => setDetail(null)}
249
- onDataChanged={data.reload}
250
- />
251
- )}
252
- </div>
253
- );
254
- }
1
+ import { useMemo, useState } from 'react';
2
+ import { useNavigate } from 'react-router-dom';
3
+ import '../library.css';
4
+ import { LoadoutProvider, useLoadout, type LoadoutKind } from '../state/loadout';
5
+ import { LibraryToastProvider, useLibraryToast } from '../state/toast';
6
+ import { useLibraryData } from '../hooks/useLibraryData';
7
+ import {
8
+ filterLibraryItems,
9
+ neededToolsFor,
10
+ skillStatus,
11
+ toolStatus,
12
+ type AttentionStatus,
13
+ type LibraryCategory,
14
+ } from '../utils/status';
15
+ import { LibraryCard } from './LibraryCard';
16
+ import { LoadoutSidebar, type LoadoutRow } from './LoadoutSidebar';
17
+ import { DetailDialog, type DetailTarget } from './DetailDialog';
18
+ import { flyParticles } from './particles';
19
+
20
+ /**
21
+ * The Library — the core skills / integrations / loadout view (the Skills &
22
+ * Tools app surface at `/skills-and-tools`, registered in the core shell).
23
+ * Game-style visual direction from
24
+ * the approved mock `mocks/mock-a2-game-library.html`: teal accent, status
25
+ * gems, tilting cards, loadout sidebar with particle flight. All data is real
26
+ * (skills catalog, secrets-vault connection status, workflow change
27
+ * requests); only the loadout itself is a documented client-side stub.
28
+ */
29
+ export function LibraryPage() {
30
+ return (
31
+ <LoadoutProvider>
32
+ <LibraryToastProvider>
33
+ <LibraryPageInner />
34
+ </LibraryToastProvider>
35
+ </LoadoutProvider>
36
+ );
37
+ }
38
+
39
+ interface GalleryItem {
40
+ kind: 'skill' | 'integration';
41
+ id: string;
42
+ name: string;
43
+ description: string;
44
+ owned: boolean;
45
+ status: AttentionStatus;
46
+ }
47
+
48
+ function LibraryPageInner() {
49
+ const data = useLibraryData();
50
+ const loadout = useLoadout();
51
+ const toast = useLibraryToast();
52
+ const navigate = useNavigate();
53
+ const [category, setCategory] = useState<LibraryCategory>('skills');
54
+ const [query, setQuery] = useState('');
55
+ const [detail, setDetail] = useState<DetailTarget | null>(null);
56
+
57
+ const items: GalleryItem[] = useMemo(() => {
58
+ const skillItems: GalleryItem[] = data.skills.map((s) => ({
59
+ kind: 'skill',
60
+ id: s.name,
61
+ name: s.name,
62
+ description: s.description,
63
+ owned: data.ownedSkills.has(s.name),
64
+ status: skillStatus(
65
+ neededToolsFor({ allowedTools: data.allowedToolsBySkill.get(s.name) }, data.tools),
66
+ ),
67
+ }));
68
+ const toolItems: GalleryItem[] = data.tools.map((t) => ({
69
+ kind: 'integration',
70
+ id: t.slug,
71
+ name: t.name,
72
+ // The browser tool surface exposes no human description for a `.tool`
73
+ // manual yet (see report) — the card stays clean, detail lives in ⓘ.
74
+ description: '',
75
+ owned: t.canWrite,
76
+ status: toolStatus(t),
77
+ }));
78
+ return [...skillItems, ...toolItems];
79
+ }, [data.skills, data.tools, data.ownedSkills, data.allowedToolsBySkill]);
80
+
81
+ const visible = useMemo(
82
+ () => filterLibraryItems(items, category, query),
83
+ [items, category, query],
84
+ );
85
+
86
+ const counts = useMemo(
87
+ () => ({
88
+ skills: items.filter((i) => i.kind === 'skill').length,
89
+ integrations: items.filter((i) => i.kind === 'integration').length,
90
+ owned: items.filter((i) => i.owned).length,
91
+ }),
92
+ [items],
93
+ );
94
+
95
+ const rows: LoadoutRow[] = useMemo(() => {
96
+ const byKey = new Map(items.map((i) => [`${i.kind}:${i.id}`, i]));
97
+ const pick = (kind: LoadoutKind, ids: string[]) =>
98
+ ids
99
+ .map((id) => byKey.get(`${kind}:${id}`))
100
+ .filter((i): i is GalleryItem => i !== undefined)
101
+ .map((i) => ({ kind, id: i.id, name: i.name, status: i.status }));
102
+ return [...pick('skill', loadout.skills), ...pick('integration', loadout.integrations)];
103
+ }, [items, loadout.skills, loadout.integrations]);
104
+
105
+ const attentionCount = rows.filter((r) => r.status.state !== 'ok').length;
106
+
107
+ function toggleItem(item: GalleryItem, fromRect?: DOMRect) {
108
+ const added = loadout.toggle(item.kind, item.id);
109
+ if (added) {
110
+ toast(
111
+ item.status.state === 'ok'
112
+ ? `${item.name} added — ready to go`
113
+ : `${item.name} added — needs a quick sign-in`,
114
+ );
115
+ if (fromRect) flyParticles(fromRect, item.kind, item.id);
116
+ }
117
+ }
118
+
119
+ function openDetail(item: GalleryItem) {
120
+ if (item.kind === 'skill') {
121
+ const skill = data.skills.find((s) => s.name === item.id);
122
+ if (skill) setDetail({ kind: 'skill', skill, owned: item.owned });
123
+ } else {
124
+ const tool = data.tools.find((t) => t.slug === item.id);
125
+ if (tool) setDetail({ kind: 'integration', tool });
126
+ }
127
+ }
128
+
129
+ const chip = (cat: LibraryCategory, label: string, count: number) => (
130
+ <button
131
+ key={cat}
132
+ type="button"
133
+ aria-pressed={category === cat}
134
+ className={`flex items-center gap-1.5 rounded-full border px-4 py-1.5 text-[12.5px] font-semibold transition-all ${
135
+ category === cat
136
+ ? 'border-[#7fd0c4] bg-gradient-to-br from-[#e6f7f4] to-[#d5f1ec] text-[#0f766e] shadow-[0_2px_10px_rgba(13,148,136,0.22)]'
137
+ : 'border-slate-200 bg-white text-slate-500 hover:border-[#7fd0c4] hover:text-slate-800'
138
+ }`}
139
+ onClick={() => setCategory(cat)}
140
+ >
141
+ {label}
142
+ <span
143
+ className={`rounded-full px-1.5 text-[10.5px] font-bold ${
144
+ category === cat ? 'bg-[#0d948826]' : 'bg-slate-900/5'
145
+ }`}
146
+ >
147
+ {count}
148
+ </span>
149
+ </button>
150
+ );
151
+
152
+ return (
153
+ <div className="flex h-full min-h-0 bg-[#eef1f6] text-slate-800">
154
+ <LoadoutSidebar
155
+ rows={rows}
156
+ onOpen={(row) => {
157
+ const item = items.find((i) => i.kind === row.kind && i.id === row.id);
158
+ if (item) openDetail(item);
159
+ }}
160
+ onRemove={(row) => loadout.remove(row.kind, row.id)}
161
+ attentionCount={attentionCount}
162
+ onFinishSetup={() => navigate('/connect')}
163
+ />
164
+
165
+ <main
166
+ className="min-w-0 flex-1 overflow-y-auto px-8 py-6"
167
+ style={{
168
+ background:
169
+ 'radial-gradient(900px 500px at 85% -10%, rgba(13,148,136,.08), transparent 60%), radial-gradient(700px 500px at -10% 110%, rgba(59,130,246,.06), transparent 55%)',
170
+ }}
171
+ >
172
+ <div className="mb-1 flex items-center gap-4">
173
+ <div>
174
+ <h1 className="text-[26px] font-bold tracking-tight">Library</h1>
175
+ <div className="text-[13px] text-slate-500">
176
+ Click a card to add it to your loadout · open a card's details for more.
177
+ </div>
178
+ </div>
179
+ <div className="ml-auto flex w-64 items-center gap-2 rounded-[11px] border border-slate-200 bg-white px-3.5 py-2 shadow-[0_1px_4px_rgba(22,35,58,0.05)]">
180
+ <input
181
+ className="w-full bg-transparent text-[13px] outline-none placeholder:text-slate-400"
182
+ placeholder="Search the library…"
183
+ aria-label="Search the library"
184
+ value={query}
185
+ onChange={(e) => setQuery(e.target.value)}
186
+ />
187
+ </div>
188
+ </div>
189
+
190
+ <div className="mb-5 mt-4 flex gap-2">
191
+ {chip('skills', 'Skills', counts.skills)}
192
+ {chip('integrations', 'Integrations', counts.integrations)}
193
+ {chip('owned', 'Owned by me', counts.owned)}
194
+ </div>
195
+
196
+ {data.error ? (
197
+ <div className="rounded-xl border border-[#f3c4c4] bg-[#fdecec] px-4 py-3 text-sm text-[#c53030]">
198
+ {data.error}
199
+ <button type="button" className="ml-3 font-bold underline" onClick={data.reload}>
200
+ Try again
201
+ </button>
202
+ </div>
203
+ ) : data.loading ? (
204
+ <div className="py-16 text-center text-sm text-slate-400">Loading the library…</div>
205
+ ) : visible.length === 0 ? (
206
+ <div className="py-16 text-center text-sm text-slate-400">Nothing here matches yet.</div>
207
+ ) : (
208
+ <div className="lib-grid grid grid-cols-[repeat(auto-fill,minmax(228px,1fr))] gap-5 pb-14">
209
+ {visible.map((item) => (
210
+ <LibraryCard
211
+ key={`${item.kind}:${item.id}`}
212
+ kind={item.kind}
213
+ id={item.id}
214
+ name={item.name}
215
+ description={item.description}
216
+ owned={item.owned}
217
+ status={item.status}
218
+ picked={loadout.isIn(item.kind, item.id)}
219
+ onToggle={(rect) => toggleItem(item, rect)}
220
+ onInfo={() => openDetail(item)}
221
+ />
222
+ ))}
223
+ </div>
224
+ )}
225
+ </main>
226
+
227
+ {detail && (
228
+ <DetailDialog
229
+ target={detail}
230
+ tools={data.tools}
231
+ skills={data.skills}
232
+ allowedToolsBySkill={data.allowedToolsBySkill}
233
+ crs={data.crs}
234
+ myCrNumbers={data.myCrNumbers}
235
+ inLoadout={
236
+ detail.kind === 'skill'
237
+ ? loadout.isIn('skill', detail.skill.name)
238
+ : loadout.isIn('integration', detail.tool.slug)
239
+ }
240
+ onToggleLoadout={() => {
241
+ const item = items.find(
242
+ (i) =>
243
+ i.kind === (detail.kind === 'skill' ? 'skill' : 'integration') &&
244
+ i.id === (detail.kind === 'skill' ? detail.skill.name : detail.tool.slug),
245
+ );
246
+ if (item) toggleItem(item);
247
+ }}
248
+ onClose={() => setDetail(null)}
249
+ onDataChanged={data.reload}
250
+ />
251
+ )}
252
+ </div>
253
+ );
254
+ }