@assistkick/create 1.0.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/dist/bin/create.d.ts +2 -0
- package/dist/bin/create.js +25 -0
- package/dist/bin/create.js.map +1 -0
- package/dist/src/scaffolder.d.ts +22 -0
- package/dist/src/scaffolder.js +120 -0
- package/dist/src/scaffolder.js.map +1 -0
- package/package.json +24 -0
- package/templates/product-system/.env.example +8 -0
- package/templates/product-system/CLAUDE.md +45 -0
- package/templates/product-system/package.json +32 -0
- package/templates/product-system/packages/backend/package.json +37 -0
- package/templates/product-system/packages/backend/src/middleware/auth_middleware.test.ts +86 -0
- package/templates/product-system/packages/backend/src/middleware/auth_middleware.ts +35 -0
- package/templates/product-system/packages/backend/src/routes/auth.ts +463 -0
- package/templates/product-system/packages/backend/src/routes/coherence.ts +187 -0
- package/templates/product-system/packages/backend/src/routes/graph.ts +67 -0
- package/templates/product-system/packages/backend/src/routes/kanban.ts +201 -0
- package/templates/product-system/packages/backend/src/routes/pipeline.ts +41 -0
- package/templates/product-system/packages/backend/src/routes/projects.ts +122 -0
- package/templates/product-system/packages/backend/src/routes/users.ts +97 -0
- package/templates/product-system/packages/backend/src/server.ts +159 -0
- package/templates/product-system/packages/backend/src/services/auth_service.test.ts +115 -0
- package/templates/product-system/packages/backend/src/services/auth_service.ts +82 -0
- package/templates/product-system/packages/backend/src/services/coherence-review.ts +339 -0
- package/templates/product-system/packages/backend/src/services/email_service.ts +75 -0
- package/templates/product-system/packages/backend/src/services/init.ts +80 -0
- package/templates/product-system/packages/backend/src/services/invitation_service.test.ts +235 -0
- package/templates/product-system/packages/backend/src/services/invitation_service.ts +193 -0
- package/templates/product-system/packages/backend/src/services/password_reset_service.test.ts +151 -0
- package/templates/product-system/packages/backend/src/services/password_reset_service.ts +135 -0
- package/templates/product-system/packages/backend/src/services/project_service.test.ts +215 -0
- package/templates/product-system/packages/backend/src/services/project_service.ts +171 -0
- package/templates/product-system/packages/backend/src/services/pty_session_manager.test.ts +88 -0
- package/templates/product-system/packages/backend/src/services/pty_session_manager.ts +279 -0
- package/templates/product-system/packages/backend/src/services/terminal_ws_handler.ts +133 -0
- package/templates/product-system/packages/backend/src/services/user_management_service.test.ts +158 -0
- package/templates/product-system/packages/backend/src/services/user_management_service.ts +128 -0
- package/templates/product-system/packages/backend/tsconfig.json +22 -0
- package/templates/product-system/packages/frontend/index.html +13 -0
- package/templates/product-system/packages/frontend/package-lock.json +2666 -0
- package/templates/product-system/packages/frontend/package.json +30 -0
- package/templates/product-system/packages/frontend/public/favicon.svg +16 -0
- package/templates/product-system/packages/frontend/src/App.tsx +29 -0
- package/templates/product-system/packages/frontend/src/api/client.ts +386 -0
- package/templates/product-system/packages/frontend/src/api/client_projects.test.ts +104 -0
- package/templates/product-system/packages/frontend/src/api/client_refresh.test.ts +145 -0
- package/templates/product-system/packages/frontend/src/components/CoherenceView.tsx +414 -0
- package/templates/product-system/packages/frontend/src/components/GraphLegend.tsx +124 -0
- package/templates/product-system/packages/frontend/src/components/GraphSettings.tsx +112 -0
- package/templates/product-system/packages/frontend/src/components/GraphView.tsx +370 -0
- package/templates/product-system/packages/frontend/src/components/InviteUserDialog.tsx +85 -0
- package/templates/product-system/packages/frontend/src/components/KanbanView.tsx +470 -0
- package/templates/product-system/packages/frontend/src/components/LoginPage.tsx +116 -0
- package/templates/product-system/packages/frontend/src/components/ProjectSelector.tsx +187 -0
- package/templates/product-system/packages/frontend/src/components/QaIssueSheet.tsx +192 -0
- package/templates/product-system/packages/frontend/src/components/SidePanel.tsx +231 -0
- package/templates/product-system/packages/frontend/src/components/TerminalView.tsx +200 -0
- package/templates/product-system/packages/frontend/src/components/Toolbar.tsx +84 -0
- package/templates/product-system/packages/frontend/src/components/UsersView.tsx +249 -0
- package/templates/product-system/packages/frontend/src/constants/graph.ts +191 -0
- package/templates/product-system/packages/frontend/src/hooks/useAuth.tsx +54 -0
- package/templates/product-system/packages/frontend/src/hooks/useGraph.ts +27 -0
- package/templates/product-system/packages/frontend/src/hooks/useKanban.ts +21 -0
- package/templates/product-system/packages/frontend/src/hooks/useProjects.ts +86 -0
- package/templates/product-system/packages/frontend/src/hooks/useTheme.ts +26 -0
- package/templates/product-system/packages/frontend/src/hooks/useToast.tsx +62 -0
- package/templates/product-system/packages/frontend/src/hooks/use_projects_logic.test.ts +61 -0
- package/templates/product-system/packages/frontend/src/main.tsx +12 -0
- package/templates/product-system/packages/frontend/src/pages/accept_invitation_page.tsx +167 -0
- package/templates/product-system/packages/frontend/src/pages/forgot_password_page.tsx +100 -0
- package/templates/product-system/packages/frontend/src/pages/register_page.tsx +137 -0
- package/templates/product-system/packages/frontend/src/pages/reset_password_page.tsx +146 -0
- package/templates/product-system/packages/frontend/src/routes/ProtectedRoute.tsx +12 -0
- package/templates/product-system/packages/frontend/src/routes/accept_invitation.tsx +14 -0
- package/templates/product-system/packages/frontend/src/routes/dashboard.tsx +221 -0
- package/templates/product-system/packages/frontend/src/routes/forgot_password.tsx +13 -0
- package/templates/product-system/packages/frontend/src/routes/login.tsx +14 -0
- package/templates/product-system/packages/frontend/src/routes/register.tsx +14 -0
- package/templates/product-system/packages/frontend/src/routes/reset_password.tsx +13 -0
- package/templates/product-system/packages/frontend/src/styles/index.css +3358 -0
- package/templates/product-system/packages/frontend/src/utils/auth_validation.test.ts +51 -0
- package/templates/product-system/packages/frontend/src/utils/auth_validation.ts +19 -0
- package/templates/product-system/packages/frontend/src/utils/login_validation.test.ts +61 -0
- package/templates/product-system/packages/frontend/src/utils/login_validation.ts +24 -0
- package/templates/product-system/packages/frontend/src/utils/logout.test.ts +63 -0
- package/templates/product-system/packages/frontend/src/utils/node_sizing.test.ts +62 -0
- package/templates/product-system/packages/frontend/src/utils/node_sizing.ts +24 -0
- package/templates/product-system/packages/frontend/src/utils/task_status.test.ts +53 -0
- package/templates/product-system/packages/frontend/src/utils/task_status.ts +14 -0
- package/templates/product-system/packages/frontend/tsconfig.json +21 -0
- package/templates/product-system/packages/frontend/vite.config.ts +20 -0
- package/templates/product-system/packages/shared/.env.example +3 -0
- package/templates/product-system/packages/shared/README.md +1 -0
- package/templates/product-system/packages/shared/db/migrate.ts +32 -0
- package/templates/product-system/packages/shared/db/migrations/0000_dashing_gorgon.sql +128 -0
- package/templates/product-system/packages/shared/db/migrations/meta/0000_snapshot.json +819 -0
- package/templates/product-system/packages/shared/db/migrations/meta/_journal.json +13 -0
- package/templates/product-system/packages/shared/db/schema.ts +137 -0
- package/templates/product-system/packages/shared/drizzle.config.js +14 -0
- package/templates/product-system/packages/shared/lib/claude-service.ts +215 -0
- package/templates/product-system/packages/shared/lib/coherence.ts +278 -0
- package/templates/product-system/packages/shared/lib/completeness.ts +30 -0
- package/templates/product-system/packages/shared/lib/constants.ts +327 -0
- package/templates/product-system/packages/shared/lib/db.ts +81 -0
- package/templates/product-system/packages/shared/lib/git_workflow.ts +110 -0
- package/templates/product-system/packages/shared/lib/graph.ts +186 -0
- package/templates/product-system/packages/shared/lib/kanban.ts +161 -0
- package/templates/product-system/packages/shared/lib/markdown.ts +205 -0
- package/templates/product-system/packages/shared/lib/pipeline-state-store.ts +124 -0
- package/templates/product-system/packages/shared/lib/pipeline.ts +489 -0
- package/templates/product-system/packages/shared/lib/prompt_builder.ts +170 -0
- package/templates/product-system/packages/shared/lib/relevance_search.ts +159 -0
- package/templates/product-system/packages/shared/lib/session.ts +152 -0
- package/templates/product-system/packages/shared/lib/validator.ts +117 -0
- package/templates/product-system/packages/shared/lib/work_summary_parser.ts +130 -0
- package/templates/product-system/packages/shared/package.json +30 -0
- package/templates/product-system/packages/shared/scripts/assign-project.ts +52 -0
- package/templates/product-system/packages/shared/tools/add_edge.ts +61 -0
- package/templates/product-system/packages/shared/tools/add_node.ts +101 -0
- package/templates/product-system/packages/shared/tools/end_session.ts +87 -0
- package/templates/product-system/packages/shared/tools/get_gaps.ts +87 -0
- package/templates/product-system/packages/shared/tools/get_kanban.ts +125 -0
- package/templates/product-system/packages/shared/tools/get_node.ts +78 -0
- package/templates/product-system/packages/shared/tools/get_status.ts +98 -0
- package/templates/product-system/packages/shared/tools/migrate_to_turso.ts +385 -0
- package/templates/product-system/packages/shared/tools/move_card.ts +143 -0
- package/templates/product-system/packages/shared/tools/rebuild_index.ts +77 -0
- package/templates/product-system/packages/shared/tools/remove_edge.ts +59 -0
- package/templates/product-system/packages/shared/tools/remove_node.ts +96 -0
- package/templates/product-system/packages/shared/tools/resolve_question.ts +75 -0
- package/templates/product-system/packages/shared/tools/search_nodes.ts +106 -0
- package/templates/product-system/packages/shared/tools/start_session.ts +144 -0
- package/templates/product-system/packages/shared/tools/update_node.ts +133 -0
- package/templates/product-system/packages/shared/tsconfig.json +24 -0
- package/templates/product-system/pnpm-workspace.yaml +2 -0
- package/templates/product-system/smoke_test.ts +219 -0
- package/templates/product-system/tests/coherence_review.test.ts +562 -0
- package/templates/product-system/tests/db_sqlite_fallback.test.ts +75 -0
- package/templates/product-system/tests/edge_type_color_coding.test.ts +147 -0
- package/templates/product-system/tests/emit-tool-use-events.test.ts +85 -0
- package/templates/product-system/tests/feature_kind.test.ts +139 -0
- package/templates/product-system/tests/gap_indicators.test.ts +199 -0
- package/templates/product-system/tests/graceful_init.test.ts +142 -0
- package/templates/product-system/tests/graph_legend.test.ts +314 -0
- package/templates/product-system/tests/graph_settings_sheet.test.ts +804 -0
- package/templates/product-system/tests/hide_defined_filter.test.ts +205 -0
- package/templates/product-system/tests/kanban.test.ts +529 -0
- package/templates/product-system/tests/neighborhood_focus.test.ts +132 -0
- package/templates/product-system/tests/node_search.test.ts +340 -0
- package/templates/product-system/tests/node_sizing.test.ts +170 -0
- package/templates/product-system/tests/node_type_toggle_filters.test.ts +285 -0
- package/templates/product-system/tests/node_type_visual_encoding.test.ts +103 -0
- package/templates/product-system/tests/pipeline-state-store.test.ts +268 -0
- package/templates/product-system/tests/pipeline-unit.test.ts +593 -0
- package/templates/product-system/tests/pipeline.test.ts +195 -0
- package/templates/product-system/tests/pipeline_stats_all_cards.test.ts +193 -0
- package/templates/product-system/tests/play_all.test.ts +296 -0
- package/templates/product-system/tests/qa_issue_sheet.test.ts +464 -0
- package/templates/product-system/tests/relevance_search.test.ts +186 -0
- package/templates/product-system/tests/search_reorder.test.ts +88 -0
- package/templates/product-system/tests/serve_ui.test.ts +281 -0
- package/templates/product-system/tests/serve_ui_drizzle.test.ts +114 -0
- package/templates/product-system/tests/session_context_recall.test.ts +135 -0
- package/templates/product-system/tests/side_panel.test.ts +345 -0
- package/templates/product-system/tests/spec_completeness_label.test.ts +69 -0
- package/templates/product-system/tests/url_routing_test.ts +122 -0
- package/templates/product-system/tests/user_login.test.ts +150 -0
- package/templates/product-system/tests/user_registration.test.ts +205 -0
- package/templates/product-system/tests/web_terminal.test.ts +572 -0
- package/templates/product-system/tests/work_summary.test.ts +211 -0
- package/templates/product-system/tests/zoom_pan.test.ts +43 -0
- package/templates/product-system/tsconfig.json +24 -0
- package/templates/skills/product-bootstrap/SKILL.md +312 -0
- package/templates/skills/product-code-reviewer/SKILL.md +147 -0
- package/templates/skills/product-debugger/SKILL.md +206 -0
- package/templates/skills/product-debugger/references/agent-browser.md +1156 -0
- package/templates/skills/product-developer/SKILL.md +182 -0
- package/templates/skills/product-interview/SKILL.md +220 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal view component — embeds an xterm.js terminal connected
|
|
3
|
+
* to the backend PTY via WebSocket. Admin-only access.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React, { useEffect, useRef, useCallback, useState } from 'react';
|
|
7
|
+
import { Terminal } from '@xterm/xterm';
|
|
8
|
+
import { FitAddon } from '@xterm/addon-fit';
|
|
9
|
+
import { WebLinksAddon } from '@xterm/addon-web-links';
|
|
10
|
+
import '@xterm/xterm/css/xterm.css';
|
|
11
|
+
|
|
12
|
+
interface TerminalViewProps {
|
|
13
|
+
visible: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type ConnectionStatus = 'connecting' | 'connected' | 'disconnected' | 'error';
|
|
17
|
+
|
|
18
|
+
export function TerminalView({ visible }: TerminalViewProps) {
|
|
19
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
20
|
+
const terminalRef = useRef<Terminal | null>(null);
|
|
21
|
+
const fitAddonRef = useRef<FitAddon | null>(null);
|
|
22
|
+
const wsRef = useRef<WebSocket | null>(null);
|
|
23
|
+
const [status, setStatus] = useState<ConnectionStatus>('disconnected');
|
|
24
|
+
const [errorMsg, setErrorMsg] = useState('');
|
|
25
|
+
|
|
26
|
+
const connect = useCallback(() => {
|
|
27
|
+
if (wsRef.current?.readyState === WebSocket.OPEN) return;
|
|
28
|
+
|
|
29
|
+
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
30
|
+
const wsUrl = `${protocol}//${window.location.host}/api/terminal`;
|
|
31
|
+
|
|
32
|
+
setStatus('connecting');
|
|
33
|
+
setErrorMsg('');
|
|
34
|
+
|
|
35
|
+
const ws = new WebSocket(wsUrl);
|
|
36
|
+
wsRef.current = ws;
|
|
37
|
+
|
|
38
|
+
ws.onopen = () => {
|
|
39
|
+
setStatus('connected');
|
|
40
|
+
|
|
41
|
+
// Send initial resize
|
|
42
|
+
if (terminalRef.current && fitAddonRef.current) {
|
|
43
|
+
fitAddonRef.current.fit();
|
|
44
|
+
const { cols, rows } = terminalRef.current;
|
|
45
|
+
ws.send(JSON.stringify({ type: 'resize', cols, rows }));
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
ws.onmessage = (event) => {
|
|
50
|
+
try {
|
|
51
|
+
const msg = JSON.parse(event.data);
|
|
52
|
+
if (msg.type === 'output' && terminalRef.current) {
|
|
53
|
+
terminalRef.current.write(msg.data);
|
|
54
|
+
}
|
|
55
|
+
} catch {
|
|
56
|
+
// Ignore malformed messages
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
ws.onclose = (event) => {
|
|
61
|
+
wsRef.current = null;
|
|
62
|
+
if (event.code === 4001) {
|
|
63
|
+
setStatus('error');
|
|
64
|
+
setErrorMsg('Authentication required. Please log in.');
|
|
65
|
+
} else if (event.code === 4003) {
|
|
66
|
+
setStatus('error');
|
|
67
|
+
setErrorMsg('Access denied. Admin privileges required.');
|
|
68
|
+
} else {
|
|
69
|
+
setStatus('disconnected');
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
ws.onerror = () => {
|
|
74
|
+
setStatus('error');
|
|
75
|
+
setErrorMsg('Failed to connect to terminal.');
|
|
76
|
+
wsRef.current = null;
|
|
77
|
+
};
|
|
78
|
+
}, []);
|
|
79
|
+
|
|
80
|
+
// Initialize terminal
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
if (!containerRef.current || terminalRef.current) return;
|
|
83
|
+
|
|
84
|
+
const terminal = new Terminal({
|
|
85
|
+
cursorBlink: true,
|
|
86
|
+
fontSize: 14,
|
|
87
|
+
fontFamily: 'Menlo, Monaco, "Courier New", monospace',
|
|
88
|
+
theme: {
|
|
89
|
+
background: '#1e1e2e',
|
|
90
|
+
foreground: '#cdd6f4',
|
|
91
|
+
cursor: '#f5e0dc',
|
|
92
|
+
selectionBackground: '#585b7066',
|
|
93
|
+
black: '#45475a',
|
|
94
|
+
red: '#f38ba8',
|
|
95
|
+
green: '#a6e3a1',
|
|
96
|
+
yellow: '#f9e2af',
|
|
97
|
+
blue: '#89b4fa',
|
|
98
|
+
magenta: '#f5c2e7',
|
|
99
|
+
cyan: '#94e2d5',
|
|
100
|
+
white: '#bac2de',
|
|
101
|
+
brightBlack: '#585b70',
|
|
102
|
+
brightRed: '#f38ba8',
|
|
103
|
+
brightGreen: '#a6e3a1',
|
|
104
|
+
brightYellow: '#f9e2af',
|
|
105
|
+
brightBlue: '#89b4fa',
|
|
106
|
+
brightMagenta: '#f5c2e7',
|
|
107
|
+
brightCyan: '#94e2d5',
|
|
108
|
+
brightWhite: '#a6adc8',
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const fitAddon = new FitAddon();
|
|
113
|
+
const webLinksAddon = new WebLinksAddon();
|
|
114
|
+
|
|
115
|
+
terminal.loadAddon(fitAddon);
|
|
116
|
+
terminal.loadAddon(webLinksAddon);
|
|
117
|
+
terminal.open(containerRef.current);
|
|
118
|
+
|
|
119
|
+
fitAddon.fit();
|
|
120
|
+
terminalRef.current = terminal;
|
|
121
|
+
fitAddonRef.current = fitAddon;
|
|
122
|
+
|
|
123
|
+
// Forward user input to WebSocket
|
|
124
|
+
terminal.onData((data) => {
|
|
125
|
+
const ws = wsRef.current;
|
|
126
|
+
if (ws?.readyState === WebSocket.OPEN) {
|
|
127
|
+
ws.send(JSON.stringify({ type: 'input', data }));
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
return () => {
|
|
132
|
+
terminal.dispose();
|
|
133
|
+
terminalRef.current = null;
|
|
134
|
+
fitAddonRef.current = null;
|
|
135
|
+
};
|
|
136
|
+
}, []);
|
|
137
|
+
|
|
138
|
+
// Connect when visible
|
|
139
|
+
useEffect(() => {
|
|
140
|
+
if (visible && status === 'disconnected') {
|
|
141
|
+
connect();
|
|
142
|
+
}
|
|
143
|
+
}, [visible, status, connect]);
|
|
144
|
+
|
|
145
|
+
// Handle resize
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
if (!visible) return;
|
|
148
|
+
|
|
149
|
+
const handleResize = () => {
|
|
150
|
+
if (fitAddonRef.current && terminalRef.current) {
|
|
151
|
+
fitAddonRef.current.fit();
|
|
152
|
+
const { cols, rows } = terminalRef.current;
|
|
153
|
+
const ws = wsRef.current;
|
|
154
|
+
if (ws?.readyState === WebSocket.OPEN) {
|
|
155
|
+
ws.send(JSON.stringify({ type: 'resize', cols, rows }));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
// Fit on visibility change
|
|
161
|
+
handleResize();
|
|
162
|
+
|
|
163
|
+
window.addEventListener('resize', handleResize);
|
|
164
|
+
return () => window.removeEventListener('resize', handleResize);
|
|
165
|
+
}, [visible]);
|
|
166
|
+
|
|
167
|
+
// Clean up WebSocket on unmount
|
|
168
|
+
useEffect(() => {
|
|
169
|
+
return () => {
|
|
170
|
+
wsRef.current?.close();
|
|
171
|
+
wsRef.current = null;
|
|
172
|
+
};
|
|
173
|
+
}, []);
|
|
174
|
+
|
|
175
|
+
return (
|
|
176
|
+
<div className="terminal-view" style={{ display: visible ? 'flex' : 'none' }}>
|
|
177
|
+
{errorMsg && (
|
|
178
|
+
<div className="terminal-error">
|
|
179
|
+
<span>{errorMsg}</span>
|
|
180
|
+
{status !== 'connecting' && (
|
|
181
|
+
<button className="terminal-reconnect-btn" onClick={connect}>
|
|
182
|
+
Reconnect
|
|
183
|
+
</button>
|
|
184
|
+
)}
|
|
185
|
+
</div>
|
|
186
|
+
)}
|
|
187
|
+
{status === 'connecting' && (
|
|
188
|
+
<div className="terminal-status">Connecting...</div>
|
|
189
|
+
)}
|
|
190
|
+
<div ref={containerRef} className="terminal-container" />
|
|
191
|
+
{status === 'disconnected' && !errorMsg && (
|
|
192
|
+
<div className="terminal-overlay">
|
|
193
|
+
<button className="terminal-connect-btn" onClick={connect}>
|
|
194
|
+
Connect to Terminal
|
|
195
|
+
</button>
|
|
196
|
+
</div>
|
|
197
|
+
)}
|
|
198
|
+
</div>
|
|
199
|
+
);
|
|
200
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ProjectSelector } from './ProjectSelector';
|
|
3
|
+
import type { Project } from '../hooks/useProjects';
|
|
4
|
+
|
|
5
|
+
interface ToolbarProps {
|
|
6
|
+
activeTab: string;
|
|
7
|
+
onTabChange: (tab: string) => void;
|
|
8
|
+
completeness: number;
|
|
9
|
+
onFit: () => void;
|
|
10
|
+
onSettingsToggle: () => void;
|
|
11
|
+
settingsOpen: boolean;
|
|
12
|
+
theme: string;
|
|
13
|
+
onThemeToggle: () => void;
|
|
14
|
+
isAdmin?: boolean;
|
|
15
|
+
onLogout: () => void;
|
|
16
|
+
projects: Project[];
|
|
17
|
+
selectedProjectId: string | null;
|
|
18
|
+
onProjectSelect: (id: string) => void;
|
|
19
|
+
onProjectCreate: (name: string) => Promise<any>;
|
|
20
|
+
onProjectRename: (id: string, name: string) => Promise<void>;
|
|
21
|
+
onProjectArchive: (id: string) => Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function Toolbar({
|
|
25
|
+
activeTab, onTabChange, completeness, onFit,
|
|
26
|
+
onSettingsToggle, settingsOpen, theme, onThemeToggle, isAdmin, onLogout,
|
|
27
|
+
projects, selectedProjectId, onProjectSelect, onProjectCreate, onProjectRename, onProjectArchive,
|
|
28
|
+
}: ToolbarProps) {
|
|
29
|
+
const tabs = ['graph', 'kanban', 'coherence'];
|
|
30
|
+
if (isAdmin) {
|
|
31
|
+
tabs.push('users');
|
|
32
|
+
tabs.push('terminal');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<div className="toolbar">
|
|
37
|
+
<div className="tab-bar">
|
|
38
|
+
{tabs.map(tab => (
|
|
39
|
+
<button
|
|
40
|
+
key={tab}
|
|
41
|
+
className={`tab-btn${activeTab === tab ? ' active' : ''}`}
|
|
42
|
+
onClick={() => onTabChange(tab)}
|
|
43
|
+
>
|
|
44
|
+
{tab.charAt(0).toUpperCase() + tab.slice(1)}
|
|
45
|
+
</button>
|
|
46
|
+
))}
|
|
47
|
+
<div className="tab-bar-separator" />
|
|
48
|
+
<ProjectSelector
|
|
49
|
+
projects={projects}
|
|
50
|
+
selectedProjectId={selectedProjectId}
|
|
51
|
+
onSelect={onProjectSelect}
|
|
52
|
+
onCreate={onProjectCreate}
|
|
53
|
+
onRename={onProjectRename}
|
|
54
|
+
onArchive={onProjectArchive}
|
|
55
|
+
/>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<div className="toolbar-spacer" />
|
|
59
|
+
|
|
60
|
+
<div className="completeness-bar">
|
|
61
|
+
<span>Completeness</span>
|
|
62
|
+
<div className="completeness-track">
|
|
63
|
+
<div className="completeness-fill" style={{ width: `${completeness}%` }} />
|
|
64
|
+
</div>
|
|
65
|
+
<span>{completeness}%</span>
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
<button className="toolbar-btn" onClick={onFit} title="Fit graph to viewport">Fit</button>
|
|
69
|
+
<button
|
|
70
|
+
className={`toolbar-btn settings-gear-btn${settingsOpen ? ' active' : ''}`}
|
|
71
|
+
onClick={onSettingsToggle}
|
|
72
|
+
title="Graph settings"
|
|
73
|
+
>
|
|
74
|
+
⚙
|
|
75
|
+
</button>
|
|
76
|
+
<button className="theme-toggle" onClick={onThemeToggle} title="Toggle theme">
|
|
77
|
+
{theme === 'dark' ? '\u2600' : '\u263E'}
|
|
78
|
+
</button>
|
|
79
|
+
<button className="toolbar-btn logout-btn" onClick={onLogout} title="Logout">
|
|
80
|
+
Logout
|
|
81
|
+
</button>
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Users View — admin-only page showing registered users and pending invitations.
|
|
3
|
+
* Admins can delete users and cancel invitations. Includes inline invite form.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React, { useState, useEffect, useCallback } from 'react';
|
|
7
|
+
import { apiClient } from '../api/client';
|
|
8
|
+
import { useAuth } from '../hooks/useAuth';
|
|
9
|
+
import { InviteUserDialog } from './InviteUserDialog';
|
|
10
|
+
|
|
11
|
+
interface User {
|
|
12
|
+
id: string;
|
|
13
|
+
email: string;
|
|
14
|
+
role: string;
|
|
15
|
+
createdAt: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface Invitation {
|
|
19
|
+
id: string;
|
|
20
|
+
email: string;
|
|
21
|
+
invitedBy: string;
|
|
22
|
+
invitedByEmail: string;
|
|
23
|
+
createdAt: string;
|
|
24
|
+
expiresAt: string;
|
|
25
|
+
acceptedAt: string | null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface UsersViewProps {
|
|
29
|
+
visible: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function UsersView({ visible }: UsersViewProps) {
|
|
33
|
+
const { user: currentUser } = useAuth();
|
|
34
|
+
const [users, setUsers] = useState<User[]>([]);
|
|
35
|
+
const [invitations, setInvitations] = useState<Invitation[]>([]);
|
|
36
|
+
const [loading, setLoading] = useState(true);
|
|
37
|
+
const [error, setError] = useState('');
|
|
38
|
+
const [deletingId, setDeletingId] = useState<string | null>(null);
|
|
39
|
+
const [inviteOpen, setInviteOpen] = useState(false);
|
|
40
|
+
|
|
41
|
+
const fetchData = useCallback(async () => {
|
|
42
|
+
setLoading(true);
|
|
43
|
+
setError('');
|
|
44
|
+
try {
|
|
45
|
+
const [usersResp, invResp] = await Promise.all([
|
|
46
|
+
apiClient.listUsers(),
|
|
47
|
+
apiClient.listInvitations(),
|
|
48
|
+
]);
|
|
49
|
+
setUsers(usersResp.users);
|
|
50
|
+
setInvitations(invResp.invitations);
|
|
51
|
+
} catch (err: any) {
|
|
52
|
+
setError(err.message || 'Failed to load data');
|
|
53
|
+
} finally {
|
|
54
|
+
setLoading(false);
|
|
55
|
+
}
|
|
56
|
+
}, []);
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (visible) {
|
|
60
|
+
fetchData();
|
|
61
|
+
}
|
|
62
|
+
}, [visible, fetchData]);
|
|
63
|
+
|
|
64
|
+
const handleDeleteUser = useCallback(async (userId: string, email: string) => {
|
|
65
|
+
if (!confirm(`Delete user ${email}? This action cannot be undone.`)) return;
|
|
66
|
+
|
|
67
|
+
setDeletingId(userId);
|
|
68
|
+
try {
|
|
69
|
+
await apiClient.deleteUser(userId);
|
|
70
|
+
setUsers(prev => prev.filter(u => u.id !== userId));
|
|
71
|
+
} catch (err: any) {
|
|
72
|
+
setError(err.message || 'Failed to delete user');
|
|
73
|
+
} finally {
|
|
74
|
+
setDeletingId(null);
|
|
75
|
+
}
|
|
76
|
+
}, []);
|
|
77
|
+
|
|
78
|
+
const handleDeleteInvitation = useCallback(async (invitationId: string, email: string) => {
|
|
79
|
+
if (!confirm(`Delete invitation for ${email}?`)) return;
|
|
80
|
+
|
|
81
|
+
setDeletingId(invitationId);
|
|
82
|
+
try {
|
|
83
|
+
await apiClient.deleteInvitation(invitationId);
|
|
84
|
+
setInvitations(prev => prev.filter(i => i.id !== invitationId));
|
|
85
|
+
} catch (err: any) {
|
|
86
|
+
setError(err.message || 'Failed to delete invitation');
|
|
87
|
+
} finally {
|
|
88
|
+
setDeletingId(null);
|
|
89
|
+
}
|
|
90
|
+
}, []);
|
|
91
|
+
|
|
92
|
+
const handleInviteClose = useCallback(() => {
|
|
93
|
+
setInviteOpen(false);
|
|
94
|
+
fetchData();
|
|
95
|
+
}, [fetchData]);
|
|
96
|
+
|
|
97
|
+
const formatDate = (iso: string) => {
|
|
98
|
+
return new Date(iso).toLocaleDateString('en-US', {
|
|
99
|
+
year: 'numeric',
|
|
100
|
+
month: 'short',
|
|
101
|
+
day: 'numeric',
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const isExpired = (expiresAt: string) => new Date(expiresAt) < new Date();
|
|
106
|
+
|
|
107
|
+
const pendingInvitations = invitations.filter(i => !i.acceptedAt && !isExpired(i.expiresAt));
|
|
108
|
+
const pastInvitations = invitations.filter(i => i.acceptedAt || isExpired(i.expiresAt));
|
|
109
|
+
|
|
110
|
+
if (!visible) return null;
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<div className="users-view">
|
|
114
|
+
<div className="users-view-header">
|
|
115
|
+
<h2>User Management</h2>
|
|
116
|
+
<button className="users-invite-btn" onClick={() => setInviteOpen(true)}>
|
|
117
|
+
+ Invite User
|
|
118
|
+
</button>
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
{error && <div className="users-error">{error}<button className="users-error-dismiss" onClick={() => setError('')}>×</button></div>}
|
|
122
|
+
|
|
123
|
+
{loading ? (
|
|
124
|
+
<div className="users-loading">Loading...</div>
|
|
125
|
+
) : (
|
|
126
|
+
<>
|
|
127
|
+
<section className="users-section">
|
|
128
|
+
<h3>Registered Users ({users.length})</h3>
|
|
129
|
+
<table className="users-table">
|
|
130
|
+
<thead>
|
|
131
|
+
<tr>
|
|
132
|
+
<th>Email</th>
|
|
133
|
+
<th>Role</th>
|
|
134
|
+
<th>Created</th>
|
|
135
|
+
<th></th>
|
|
136
|
+
</tr>
|
|
137
|
+
</thead>
|
|
138
|
+
<tbody>
|
|
139
|
+
{users.map(u => (
|
|
140
|
+
<tr key={u.id} className={u.id === currentUser?.id ? 'users-current-row' : ''}>
|
|
141
|
+
<td>{u.email}</td>
|
|
142
|
+
<td><span className={`users-role-badge users-role-${u.role}`}>{u.role}</span></td>
|
|
143
|
+
<td>{formatDate(u.createdAt)}</td>
|
|
144
|
+
<td>
|
|
145
|
+
{u.id === currentUser?.id ? (
|
|
146
|
+
<span className="users-you-badge">you</span>
|
|
147
|
+
) : (
|
|
148
|
+
<button
|
|
149
|
+
className="users-delete-btn"
|
|
150
|
+
onClick={() => handleDeleteUser(u.id, u.email)}
|
|
151
|
+
disabled={deletingId === u.id}
|
|
152
|
+
title={`Delete ${u.email}`}
|
|
153
|
+
>
|
|
154
|
+
{deletingId === u.id ? '...' : 'Delete'}
|
|
155
|
+
</button>
|
|
156
|
+
)}
|
|
157
|
+
</td>
|
|
158
|
+
</tr>
|
|
159
|
+
))}
|
|
160
|
+
</tbody>
|
|
161
|
+
</table>
|
|
162
|
+
</section>
|
|
163
|
+
|
|
164
|
+
<section className="users-section">
|
|
165
|
+
<h3>Pending Invitations ({pendingInvitations.length})</h3>
|
|
166
|
+
{pendingInvitations.length === 0 ? (
|
|
167
|
+
<p className="users-empty">No pending invitations.</p>
|
|
168
|
+
) : (
|
|
169
|
+
<table className="users-table">
|
|
170
|
+
<thead>
|
|
171
|
+
<tr>
|
|
172
|
+
<th>Email</th>
|
|
173
|
+
<th>Invited By</th>
|
|
174
|
+
<th>Sent</th>
|
|
175
|
+
<th>Expires</th>
|
|
176
|
+
<th></th>
|
|
177
|
+
</tr>
|
|
178
|
+
</thead>
|
|
179
|
+
<tbody>
|
|
180
|
+
{pendingInvitations.map(inv => (
|
|
181
|
+
<tr key={inv.id}>
|
|
182
|
+
<td>{inv.email}</td>
|
|
183
|
+
<td>{inv.invitedByEmail}</td>
|
|
184
|
+
<td>{formatDate(inv.createdAt)}</td>
|
|
185
|
+
<td>{formatDate(inv.expiresAt)}</td>
|
|
186
|
+
<td>
|
|
187
|
+
<button
|
|
188
|
+
className="users-delete-btn"
|
|
189
|
+
onClick={() => handleDeleteInvitation(inv.id, inv.email)}
|
|
190
|
+
disabled={deletingId === inv.id}
|
|
191
|
+
title={`Cancel invitation for ${inv.email}`}
|
|
192
|
+
>
|
|
193
|
+
{deletingId === inv.id ? '...' : 'Cancel'}
|
|
194
|
+
</button>
|
|
195
|
+
</td>
|
|
196
|
+
</tr>
|
|
197
|
+
))}
|
|
198
|
+
</tbody>
|
|
199
|
+
</table>
|
|
200
|
+
)}
|
|
201
|
+
</section>
|
|
202
|
+
|
|
203
|
+
{pastInvitations.length > 0 && (
|
|
204
|
+
<section className="users-section">
|
|
205
|
+
<h3>Past Invitations ({pastInvitations.length})</h3>
|
|
206
|
+
<table className="users-table">
|
|
207
|
+
<thead>
|
|
208
|
+
<tr>
|
|
209
|
+
<th>Email</th>
|
|
210
|
+
<th>Invited By</th>
|
|
211
|
+
<th>Status</th>
|
|
212
|
+
<th>Date</th>
|
|
213
|
+
<th></th>
|
|
214
|
+
</tr>
|
|
215
|
+
</thead>
|
|
216
|
+
<tbody>
|
|
217
|
+
{pastInvitations.map(inv => (
|
|
218
|
+
<tr key={inv.id} className="users-past-row">
|
|
219
|
+
<td>{inv.email}</td>
|
|
220
|
+
<td>{inv.invitedByEmail}</td>
|
|
221
|
+
<td>
|
|
222
|
+
<span className={`users-status-badge ${inv.acceptedAt ? 'users-status-accepted' : 'users-status-expired'}`}>
|
|
223
|
+
{inv.acceptedAt ? 'Accepted' : 'Expired'}
|
|
224
|
+
</span>
|
|
225
|
+
</td>
|
|
226
|
+
<td>{formatDate(inv.acceptedAt || inv.expiresAt)}</td>
|
|
227
|
+
<td>
|
|
228
|
+
<button
|
|
229
|
+
className="users-delete-btn"
|
|
230
|
+
onClick={() => handleDeleteInvitation(inv.id, inv.email)}
|
|
231
|
+
disabled={deletingId === inv.id}
|
|
232
|
+
title={`Delete invitation record for ${inv.email}`}
|
|
233
|
+
>
|
|
234
|
+
{deletingId === inv.id ? '...' : 'Delete'}
|
|
235
|
+
</button>
|
|
236
|
+
</td>
|
|
237
|
+
</tr>
|
|
238
|
+
))}
|
|
239
|
+
</tbody>
|
|
240
|
+
</table>
|
|
241
|
+
</section>
|
|
242
|
+
)}
|
|
243
|
+
</>
|
|
244
|
+
)}
|
|
245
|
+
|
|
246
|
+
<InviteUserDialog isOpen={inviteOpen} onClose={handleInviteClose} />
|
|
247
|
+
</div>
|
|
248
|
+
);
|
|
249
|
+
}
|