@friggframework/devtools 2.0.0-next.4 → 2.0.0-next.40
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/frigg-cli/.eslintrc.js +141 -0
- package/frigg-cli/__tests__/jest.config.js +102 -0
- package/frigg-cli/__tests__/unit/commands/build.test.js +483 -0
- package/frigg-cli/__tests__/unit/commands/install.test.js +418 -0
- package/frigg-cli/__tests__/unit/commands/ui.test.js +592 -0
- package/frigg-cli/__tests__/utils/command-tester.js +170 -0
- package/frigg-cli/__tests__/utils/mock-factory.js +270 -0
- package/frigg-cli/__tests__/utils/test-fixtures.js +463 -0
- package/frigg-cli/__tests__/utils/test-setup.js +286 -0
- package/frigg-cli/build-command/index.js +54 -0
- package/frigg-cli/deploy-command/index.js +175 -0
- package/frigg-cli/generate-command/__tests__/generate-command.test.js +312 -0
- package/frigg-cli/generate-command/azure-generator.js +43 -0
- package/frigg-cli/generate-command/gcp-generator.js +47 -0
- package/frigg-cli/generate-command/index.js +332 -0
- package/frigg-cli/generate-command/terraform-generator.js +555 -0
- package/frigg-cli/generate-iam-command.js +115 -0
- package/frigg-cli/index.js +47 -1
- package/frigg-cli/index.test.js +1 -4
- package/frigg-cli/init-command/backend-first-handler.js +756 -0
- package/frigg-cli/init-command/index.js +93 -0
- package/frigg-cli/init-command/template-handler.js +143 -0
- package/frigg-cli/install-command/index.js +1 -4
- package/frigg-cli/package.json +51 -0
- package/frigg-cli/start-command/index.js +24 -4
- package/frigg-cli/test/init-command.test.js +180 -0
- package/frigg-cli/test/npm-registry.test.js +319 -0
- package/frigg-cli/ui-command/index.js +154 -0
- package/frigg-cli/utils/app-resolver.js +319 -0
- package/frigg-cli/utils/backend-path.js +16 -17
- package/frigg-cli/utils/npm-registry.js +167 -0
- package/frigg-cli/utils/process-manager.js +199 -0
- package/frigg-cli/utils/repo-detection.js +405 -0
- package/infrastructure/DEPLOYMENT-INSTRUCTIONS.md +268 -0
- package/infrastructure/GENERATE-IAM-DOCS.md +278 -0
- package/infrastructure/IAM-POLICY-TEMPLATES.md +176 -0
- package/infrastructure/README.md +443 -0
- package/infrastructure/WEBSOCKET-CONFIGURATION.md +105 -0
- package/infrastructure/__tests__/fixtures/mock-aws-resources.js +391 -0
- package/infrastructure/__tests__/helpers/test-utils.js +277 -0
- package/infrastructure/aws-discovery.js +1176 -0
- package/infrastructure/aws-discovery.test.js +1220 -0
- package/infrastructure/build-time-discovery.js +206 -0
- package/infrastructure/build-time-discovery.test.js +378 -0
- package/infrastructure/create-frigg-infrastructure.js +3 -5
- package/infrastructure/env-validator.js +77 -0
- package/infrastructure/frigg-deployment-iam-stack.yaml +401 -0
- package/infrastructure/iam-generator.js +836 -0
- package/infrastructure/iam-generator.test.js +172 -0
- package/infrastructure/iam-policy-basic.json +218 -0
- package/infrastructure/iam-policy-full.json +288 -0
- package/infrastructure/integration.test.js +383 -0
- package/infrastructure/run-discovery.js +110 -0
- package/infrastructure/serverless-template.js +1472 -138
- package/infrastructure/serverless-template.test.js +1759 -0
- package/management-ui/.eslintrc.js +22 -0
- package/management-ui/README.md +203 -0
- package/management-ui/components.json +21 -0
- package/management-ui/docs/phase2-integration-guide.md +320 -0
- package/management-ui/index.html +13 -0
- package/management-ui/package-lock.json +16517 -0
- package/management-ui/package.json +76 -0
- package/management-ui/packages/devtools/frigg-cli/ui-command/index.js +302 -0
- package/management-ui/postcss.config.js +6 -0
- package/management-ui/server/api/backend.js +256 -0
- package/management-ui/server/api/cli.js +315 -0
- package/management-ui/server/api/codegen.js +663 -0
- package/management-ui/server/api/connections.js +857 -0
- package/management-ui/server/api/discovery.js +185 -0
- package/management-ui/server/api/environment/index.js +1 -0
- package/management-ui/server/api/environment/router.js +378 -0
- package/management-ui/server/api/environment.js +328 -0
- package/management-ui/server/api/integrations.js +876 -0
- package/management-ui/server/api/logs.js +248 -0
- package/management-ui/server/api/monitoring.js +282 -0
- package/management-ui/server/api/open-ide.js +31 -0
- package/management-ui/server/api/project.js +1029 -0
- package/management-ui/server/api/users/sessions.js +371 -0
- package/management-ui/server/api/users/simulation.js +254 -0
- package/management-ui/server/api/users.js +362 -0
- package/management-ui/server/api-contract.md +275 -0
- package/management-ui/server/index.js +873 -0
- package/management-ui/server/middleware/errorHandler.js +93 -0
- package/management-ui/server/middleware/security.js +32 -0
- package/management-ui/server/processManager.js +296 -0
- package/management-ui/server/server.js +346 -0
- package/management-ui/server/services/aws-monitor.js +413 -0
- package/management-ui/server/services/npm-registry.js +347 -0
- package/management-ui/server/services/template-engine.js +538 -0
- package/management-ui/server/utils/cliIntegration.js +220 -0
- package/management-ui/server/utils/environment/auditLogger.js +471 -0
- package/management-ui/server/utils/environment/awsParameterStore.js +264 -0
- package/management-ui/server/utils/environment/encryption.js +278 -0
- package/management-ui/server/utils/environment/envFileManager.js +286 -0
- package/management-ui/server/utils/import-commonjs.js +28 -0
- package/management-ui/server/utils/response.js +83 -0
- package/management-ui/server/websocket/handler.js +325 -0
- package/management-ui/src/App.jsx +109 -0
- package/management-ui/src/assets/FriggLogo.svg +1 -0
- package/management-ui/src/components/AppRouter.jsx +65 -0
- package/management-ui/src/components/Button.jsx +70 -0
- package/management-ui/src/components/Card.jsx +97 -0
- package/management-ui/src/components/EnvironmentCompare.jsx +400 -0
- package/management-ui/src/components/EnvironmentEditor.jsx +372 -0
- package/management-ui/src/components/EnvironmentImportExport.jsx +469 -0
- package/management-ui/src/components/EnvironmentSchema.jsx +491 -0
- package/management-ui/src/components/EnvironmentSecurity.jsx +463 -0
- package/management-ui/src/components/ErrorBoundary.jsx +73 -0
- package/management-ui/src/components/IntegrationCard.jsx +481 -0
- package/management-ui/src/components/IntegrationCardEnhanced.jsx +770 -0
- package/management-ui/src/components/IntegrationExplorer.jsx +379 -0
- package/management-ui/src/components/IntegrationStatus.jsx +336 -0
- package/management-ui/src/components/Layout.jsx +716 -0
- package/management-ui/src/components/LoadingSpinner.jsx +113 -0
- package/management-ui/src/components/RepositoryPicker.jsx +248 -0
- package/management-ui/src/components/SessionMonitor.jsx +350 -0
- package/management-ui/src/components/StatusBadge.jsx +208 -0
- package/management-ui/src/components/UserContextSwitcher.jsx +212 -0
- package/management-ui/src/components/UserSimulation.jsx +327 -0
- package/management-ui/src/components/Welcome.jsx +434 -0
- package/management-ui/src/components/codegen/APIEndpointGenerator.jsx +637 -0
- package/management-ui/src/components/codegen/APIModuleSelector.jsx +227 -0
- package/management-ui/src/components/codegen/CodeGenerationWizard.jsx +247 -0
- package/management-ui/src/components/codegen/CodePreviewEditor.jsx +316 -0
- package/management-ui/src/components/codegen/DynamicModuleForm.jsx +271 -0
- package/management-ui/src/components/codegen/FormBuilder.jsx +737 -0
- package/management-ui/src/components/codegen/IntegrationGenerator.jsx +855 -0
- package/management-ui/src/components/codegen/ProjectScaffoldWizard.jsx +797 -0
- package/management-ui/src/components/codegen/SchemaBuilder.jsx +303 -0
- package/management-ui/src/components/codegen/TemplateSelector.jsx +586 -0
- package/management-ui/src/components/codegen/index.js +10 -0
- package/management-ui/src/components/connections/ConnectionConfigForm.jsx +362 -0
- package/management-ui/src/components/connections/ConnectionHealthMonitor.jsx +182 -0
- package/management-ui/src/components/connections/ConnectionTester.jsx +200 -0
- package/management-ui/src/components/connections/EntityRelationshipMapper.jsx +292 -0
- package/management-ui/src/components/connections/OAuthFlow.jsx +204 -0
- package/management-ui/src/components/connections/index.js +5 -0
- package/management-ui/src/components/index.js +21 -0
- package/management-ui/src/components/monitoring/APIGatewayMetrics.jsx +222 -0
- package/management-ui/src/components/monitoring/LambdaMetrics.jsx +169 -0
- package/management-ui/src/components/monitoring/MetricsChart.jsx +197 -0
- package/management-ui/src/components/monitoring/MonitoringDashboard.jsx +393 -0
- package/management-ui/src/components/monitoring/SQSMetrics.jsx +246 -0
- package/management-ui/src/components/monitoring/index.js +6 -0
- package/management-ui/src/components/monitoring/monitoring.css +218 -0
- package/management-ui/src/components/theme-provider.jsx +52 -0
- package/management-ui/src/components/theme-toggle.jsx +39 -0
- package/management-ui/src/components/ui/badge.tsx +36 -0
- package/management-ui/src/components/ui/button.test.jsx +56 -0
- package/management-ui/src/components/ui/button.tsx +57 -0
- package/management-ui/src/components/ui/card.tsx +76 -0
- package/management-ui/src/components/ui/dropdown-menu.tsx +199 -0
- package/management-ui/src/components/ui/select.tsx +157 -0
- package/management-ui/src/components/ui/skeleton.jsx +15 -0
- package/management-ui/src/hooks/useFrigg.jsx +601 -0
- package/management-ui/src/hooks/useSocket.jsx +58 -0
- package/management-ui/src/index.css +193 -0
- package/management-ui/src/lib/utils.ts +6 -0
- package/management-ui/src/main.jsx +10 -0
- package/management-ui/src/pages/CodeGeneration.jsx +14 -0
- package/management-ui/src/pages/Connections.jsx +252 -0
- package/management-ui/src/pages/ConnectionsEnhanced.jsx +633 -0
- package/management-ui/src/pages/Dashboard.jsx +311 -0
- package/management-ui/src/pages/Environment.jsx +314 -0
- package/management-ui/src/pages/IntegrationConfigure.jsx +669 -0
- package/management-ui/src/pages/IntegrationDiscovery.jsx +567 -0
- package/management-ui/src/pages/IntegrationTest.jsx +742 -0
- package/management-ui/src/pages/Integrations.jsx +253 -0
- package/management-ui/src/pages/Monitoring.jsx +17 -0
- package/management-ui/src/pages/Simulation.jsx +155 -0
- package/management-ui/src/pages/Users.jsx +492 -0
- package/management-ui/src/services/api.js +41 -0
- package/management-ui/src/services/apiModuleService.js +193 -0
- package/management-ui/src/services/websocket-handlers.js +120 -0
- package/management-ui/src/test/api/project.test.js +273 -0
- package/management-ui/src/test/components/Welcome.test.jsx +378 -0
- package/management-ui/src/test/mocks/server.js +178 -0
- package/management-ui/src/test/setup.js +61 -0
- package/management-ui/src/test/utils/test-utils.jsx +134 -0
- package/management-ui/src/utils/repository.js +98 -0
- package/management-ui/src/utils/repository.test.js +118 -0
- package/management-ui/src/workflows/phase2-integration-workflows.js +884 -0
- package/management-ui/tailwind.config.js +63 -0
- package/management-ui/tsconfig.json +37 -0
- package/management-ui/tsconfig.node.json +10 -0
- package/management-ui/vite.config.js +26 -0
- package/management-ui/vitest.config.js +38 -0
- package/package.json +20 -9
- package/infrastructure/app-handler-helpers.js +0 -57
- package/infrastructure/backend-utils.js +0 -90
- package/infrastructure/routers/auth.js +0 -26
- package/infrastructure/routers/integration-defined-routers.js +0 -37
- package/infrastructure/routers/middleware/loadUser.js +0 -15
- package/infrastructure/routers/middleware/requireLoggedInUser.js +0 -12
- package/infrastructure/routers/user.js +0 -41
- package/infrastructure/routers/websocket.js +0 -55
- package/infrastructure/workers/integration-defined-workers.js +0 -24
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import { useFrigg } from '../hooks/useFrigg'
|
|
3
|
+
import SessionMonitor from '../components/SessionMonitor'
|
|
4
|
+
|
|
5
|
+
const Users = () => {
|
|
6
|
+
const { users, createUser, updateUser, deleteUser, bulkCreateUsers, deleteAllUsers } = useFrigg()
|
|
7
|
+
const [showCreateForm, setShowCreateForm] = useState(false)
|
|
8
|
+
const [editingUser, setEditingUser] = useState(null)
|
|
9
|
+
const [showDeleteConfirm, setShowDeleteConfirm] = useState(null)
|
|
10
|
+
const [searchTerm, setSearchTerm] = useState('')
|
|
11
|
+
const [filterRole, setFilterRole] = useState('')
|
|
12
|
+
const [filterStatus, setFilterStatus] = useState('')
|
|
13
|
+
const [activeTab, setActiveTab] = useState('users')
|
|
14
|
+
const [formData, setFormData] = useState({
|
|
15
|
+
email: '',
|
|
16
|
+
firstName: '',
|
|
17
|
+
lastName: '',
|
|
18
|
+
role: 'user',
|
|
19
|
+
appUserId: '',
|
|
20
|
+
appOrgId: ''
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const handleInputChange = (e) => {
|
|
24
|
+
const { name, value } = e.target
|
|
25
|
+
setFormData(prev => ({ ...prev, [name]: value }))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const handleSubmit = async (e) => {
|
|
29
|
+
e.preventDefault()
|
|
30
|
+
try {
|
|
31
|
+
if (editingUser) {
|
|
32
|
+
await updateUser(editingUser.id, formData)
|
|
33
|
+
setEditingUser(null)
|
|
34
|
+
} else {
|
|
35
|
+
await createUser(formData)
|
|
36
|
+
}
|
|
37
|
+
setFormData({ email: '', firstName: '', lastName: '', role: 'user', appUserId: '', appOrgId: '' })
|
|
38
|
+
setShowCreateForm(false)
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.error(editingUser ? 'Error updating user:' : 'Error creating user:', error)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const handleEdit = (user) => {
|
|
45
|
+
setEditingUser(user)
|
|
46
|
+
setFormData({
|
|
47
|
+
email: user.email,
|
|
48
|
+
firstName: user.firstName,
|
|
49
|
+
lastName: user.lastName,
|
|
50
|
+
role: user.role,
|
|
51
|
+
appUserId: user.appUserId || '',
|
|
52
|
+
appOrgId: user.appOrgId || ''
|
|
53
|
+
})
|
|
54
|
+
setShowCreateForm(true)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const handleDelete = async (userId) => {
|
|
58
|
+
try {
|
|
59
|
+
await deleteUser(userId)
|
|
60
|
+
setShowDeleteConfirm(null)
|
|
61
|
+
} catch (error) {
|
|
62
|
+
console.error('Error deleting user:', error)
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const handleBulkCreate = async () => {
|
|
67
|
+
try {
|
|
68
|
+
await bulkCreateUsers(10)
|
|
69
|
+
} catch (error) {
|
|
70
|
+
console.error('Error creating bulk users:', error)
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const handleDeleteAll = async () => {
|
|
75
|
+
if (window.confirm('Are you sure you want to delete all users? This action cannot be undone.')) {
|
|
76
|
+
try {
|
|
77
|
+
await deleteAllUsers()
|
|
78
|
+
} catch (error) {
|
|
79
|
+
console.error('Error deleting all users:', error)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const generateTestId = (user) => {
|
|
85
|
+
return `test_user_${user.email.split('@')[0].replace(/\./g, '_')}`
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Filter users based on search and filters
|
|
89
|
+
const filteredUsers = users.filter(user => {
|
|
90
|
+
const matchesSearch = searchTerm === '' ||
|
|
91
|
+
user.email.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
|
92
|
+
user.firstName.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
|
93
|
+
user.lastName.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
|
94
|
+
(user.appUserId && user.appUserId.toLowerCase().includes(searchTerm.toLowerCase())) ||
|
|
95
|
+
(user.appOrgId && user.appOrgId.toLowerCase().includes(searchTerm.toLowerCase()))
|
|
96
|
+
|
|
97
|
+
const matchesRole = filterRole === '' || user.role === filterRole
|
|
98
|
+
const matchesStatus = filterStatus === '' || user.status === filterStatus
|
|
99
|
+
|
|
100
|
+
return matchesSearch && matchesRole && matchesStatus
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<div>
|
|
105
|
+
<div className="mb-8">
|
|
106
|
+
<h2 className="text-3xl font-bold text-gray-900">Test User Management</h2>
|
|
107
|
+
<p className="mt-2 text-gray-600">Create and manage dummy users for testing integrations</p>
|
|
108
|
+
</div>
|
|
109
|
+
|
|
110
|
+
{/* Tab Navigation */}
|
|
111
|
+
<div className="mb-6 border-b border-gray-200">
|
|
112
|
+
<nav className="-mb-px flex space-x-8">
|
|
113
|
+
<button
|
|
114
|
+
onClick={() => setActiveTab('users')}
|
|
115
|
+
className={`py-2 px-1 border-b-2 font-medium text-sm ${
|
|
116
|
+
activeTab === 'users'
|
|
117
|
+
? 'border-frigg-blue text-frigg-blue'
|
|
118
|
+
: 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'
|
|
119
|
+
}`}
|
|
120
|
+
>
|
|
121
|
+
Users ({users.length})
|
|
122
|
+
</button>
|
|
123
|
+
<button
|
|
124
|
+
onClick={() => setActiveTab('sessions')}
|
|
125
|
+
className={`py-2 px-1 border-b-2 font-medium text-sm ${
|
|
126
|
+
activeTab === 'sessions'
|
|
127
|
+
? 'border-frigg-blue text-frigg-blue'
|
|
128
|
+
: 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300'
|
|
129
|
+
}`}
|
|
130
|
+
>
|
|
131
|
+
Active Sessions
|
|
132
|
+
</button>
|
|
133
|
+
</nav>
|
|
134
|
+
</div>
|
|
135
|
+
|
|
136
|
+
{activeTab === 'users' ? (
|
|
137
|
+
<>
|
|
138
|
+
{/* Action Buttons */}
|
|
139
|
+
<div className="mb-6 flex space-x-4">
|
|
140
|
+
{!showCreateForm ? (
|
|
141
|
+
<>
|
|
142
|
+
<button
|
|
143
|
+
onClick={() => setShowCreateForm(true)}
|
|
144
|
+
className="px-4 py-2 bg-frigg-blue text-white rounded-md hover:bg-blue-700 transition-colors"
|
|
145
|
+
>
|
|
146
|
+
+ Create Test User
|
|
147
|
+
</button>
|
|
148
|
+
<button
|
|
149
|
+
onClick={handleBulkCreate}
|
|
150
|
+
className="px-4 py-2 bg-green-600 text-white rounded-md hover:bg-green-700 transition-colors"
|
|
151
|
+
>
|
|
152
|
+
Generate 10 Users
|
|
153
|
+
</button>
|
|
154
|
+
{users.length > 0 && (
|
|
155
|
+
<button
|
|
156
|
+
onClick={handleDeleteAll}
|
|
157
|
+
className="px-4 py-2 bg-red-600 text-white rounded-md hover:bg-red-700 transition-colors"
|
|
158
|
+
>
|
|
159
|
+
Delete All Users
|
|
160
|
+
</button>
|
|
161
|
+
)}
|
|
162
|
+
</>
|
|
163
|
+
) : (
|
|
164
|
+
<div className="bg-white shadow rounded-lg p-6">
|
|
165
|
+
<h3 className="text-lg font-medium text-gray-900 mb-4">
|
|
166
|
+
{editingUser ? 'Edit User' : 'Create New Test User'}
|
|
167
|
+
</h3>
|
|
168
|
+
<form onSubmit={handleSubmit}>
|
|
169
|
+
<div className="grid grid-cols-2 gap-4">
|
|
170
|
+
<div>
|
|
171
|
+
<label className="block text-sm font-medium text-gray-700 mb-1">
|
|
172
|
+
First Name
|
|
173
|
+
</label>
|
|
174
|
+
<input
|
|
175
|
+
type="text"
|
|
176
|
+
name="firstName"
|
|
177
|
+
required
|
|
178
|
+
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:border-frigg-blue"
|
|
179
|
+
value={formData.firstName}
|
|
180
|
+
onChange={handleInputChange}
|
|
181
|
+
/>
|
|
182
|
+
</div>
|
|
183
|
+
<div>
|
|
184
|
+
<label className="block text-sm font-medium text-gray-700 mb-1">
|
|
185
|
+
Last Name
|
|
186
|
+
</label>
|
|
187
|
+
<input
|
|
188
|
+
type="text"
|
|
189
|
+
name="lastName"
|
|
190
|
+
required
|
|
191
|
+
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:border-frigg-blue"
|
|
192
|
+
value={formData.lastName}
|
|
193
|
+
onChange={handleInputChange}
|
|
194
|
+
/>
|
|
195
|
+
</div>
|
|
196
|
+
<div>
|
|
197
|
+
<label className="block text-sm font-medium text-gray-700 mb-1">
|
|
198
|
+
Email
|
|
199
|
+
</label>
|
|
200
|
+
<input
|
|
201
|
+
type="email"
|
|
202
|
+
name="email"
|
|
203
|
+
required
|
|
204
|
+
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:border-frigg-blue"
|
|
205
|
+
value={formData.email}
|
|
206
|
+
onChange={handleInputChange}
|
|
207
|
+
/>
|
|
208
|
+
</div>
|
|
209
|
+
<div>
|
|
210
|
+
<label className="block text-sm font-medium text-gray-700 mb-1">
|
|
211
|
+
Role
|
|
212
|
+
</label>
|
|
213
|
+
<select
|
|
214
|
+
name="role"
|
|
215
|
+
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:border-frigg-blue"
|
|
216
|
+
value={formData.role}
|
|
217
|
+
onChange={handleInputChange}
|
|
218
|
+
>
|
|
219
|
+
<option value="user">User</option>
|
|
220
|
+
<option value="admin">Admin</option>
|
|
221
|
+
<option value="developer">Developer</option>
|
|
222
|
+
</select>
|
|
223
|
+
</div>
|
|
224
|
+
<div>
|
|
225
|
+
<label className="block text-sm font-medium text-gray-700 mb-1">
|
|
226
|
+
App User ID
|
|
227
|
+
</label>
|
|
228
|
+
<input
|
|
229
|
+
type="text"
|
|
230
|
+
name="appUserId"
|
|
231
|
+
placeholder="e.g., app_user_123"
|
|
232
|
+
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:border-frigg-blue"
|
|
233
|
+
value={formData.appUserId}
|
|
234
|
+
onChange={handleInputChange}
|
|
235
|
+
/>
|
|
236
|
+
<p className="text-xs text-gray-500 mt-1">Optional: External app user identifier</p>
|
|
237
|
+
</div>
|
|
238
|
+
<div>
|
|
239
|
+
<label className="block text-sm font-medium text-gray-700 mb-1">
|
|
240
|
+
App Org ID
|
|
241
|
+
</label>
|
|
242
|
+
<input
|
|
243
|
+
type="text"
|
|
244
|
+
name="appOrgId"
|
|
245
|
+
placeholder="e.g., app_org_456"
|
|
246
|
+
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:border-frigg-blue"
|
|
247
|
+
value={formData.appOrgId}
|
|
248
|
+
onChange={handleInputChange}
|
|
249
|
+
/>
|
|
250
|
+
<p className="text-xs text-gray-500 mt-1">Optional: External organization identifier</p>
|
|
251
|
+
</div>
|
|
252
|
+
</div>
|
|
253
|
+
<div className="mt-4 flex space-x-2">
|
|
254
|
+
<button
|
|
255
|
+
type="submit"
|
|
256
|
+
className="px-4 py-2 bg-green-600 text-white rounded-md hover:bg-green-700"
|
|
257
|
+
>
|
|
258
|
+
{editingUser ? 'Update User' : 'Create User'}
|
|
259
|
+
</button>
|
|
260
|
+
<button
|
|
261
|
+
type="button"
|
|
262
|
+
onClick={() => {
|
|
263
|
+
setShowCreateForm(false)
|
|
264
|
+
setEditingUser(null)
|
|
265
|
+
setFormData({ email: '', firstName: '', lastName: '', role: 'user', appUserId: '', appOrgId: '' })
|
|
266
|
+
}}
|
|
267
|
+
className="px-4 py-2 bg-gray-300 text-gray-700 rounded-md hover:bg-gray-400"
|
|
268
|
+
>
|
|
269
|
+
Cancel
|
|
270
|
+
</button>
|
|
271
|
+
</div>
|
|
272
|
+
</form>
|
|
273
|
+
</div>
|
|
274
|
+
)}
|
|
275
|
+
</div>
|
|
276
|
+
|
|
277
|
+
{/* Search and Filters */}
|
|
278
|
+
<div className="mb-6 bg-white shadow rounded-lg p-4">
|
|
279
|
+
<div className="grid grid-cols-1 md:grid-cols-4 gap-4">
|
|
280
|
+
<div className="md:col-span-2">
|
|
281
|
+
<label className="block text-sm font-medium text-gray-700 mb-1">Search</label>
|
|
282
|
+
<input
|
|
283
|
+
type="text"
|
|
284
|
+
placeholder="Search by name, email, or IDs..."
|
|
285
|
+
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:border-frigg-blue"
|
|
286
|
+
value={searchTerm}
|
|
287
|
+
onChange={(e) => setSearchTerm(e.target.value)}
|
|
288
|
+
/>
|
|
289
|
+
</div>
|
|
290
|
+
<div>
|
|
291
|
+
<label className="block text-sm font-medium text-gray-700 mb-1">Filter by Role</label>
|
|
292
|
+
<select
|
|
293
|
+
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:border-frigg-blue"
|
|
294
|
+
value={filterRole}
|
|
295
|
+
onChange={(e) => setFilterRole(e.target.value)}
|
|
296
|
+
>
|
|
297
|
+
<option value="">All Roles</option>
|
|
298
|
+
<option value="user">User</option>
|
|
299
|
+
<option value="admin">Admin</option>
|
|
300
|
+
<option value="developer">Developer</option>
|
|
301
|
+
</select>
|
|
302
|
+
</div>
|
|
303
|
+
<div>
|
|
304
|
+
<label className="block text-sm font-medium text-gray-700 mb-1">Filter by Status</label>
|
|
305
|
+
<select
|
|
306
|
+
className="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:border-frigg-blue"
|
|
307
|
+
value={filterStatus}
|
|
308
|
+
onChange={(e) => setFilterStatus(e.target.value)}
|
|
309
|
+
>
|
|
310
|
+
<option value="">All Statuses</option>
|
|
311
|
+
<option value="active">Active</option>
|
|
312
|
+
<option value="inactive">Inactive</option>
|
|
313
|
+
</select>
|
|
314
|
+
</div>
|
|
315
|
+
</div>
|
|
316
|
+
{(searchTerm || filterRole || filterStatus) && (
|
|
317
|
+
<div className="mt-3 flex items-center text-sm text-gray-600">
|
|
318
|
+
<span>Showing {filteredUsers.length} of {users.length} users</span>
|
|
319
|
+
<button
|
|
320
|
+
onClick={() => {
|
|
321
|
+
setSearchTerm('')
|
|
322
|
+
setFilterRole('')
|
|
323
|
+
setFilterStatus('')
|
|
324
|
+
}}
|
|
325
|
+
className="ml-4 text-frigg-blue hover:text-blue-700"
|
|
326
|
+
>
|
|
327
|
+
Clear filters
|
|
328
|
+
</button>
|
|
329
|
+
</div>
|
|
330
|
+
)}
|
|
331
|
+
</div>
|
|
332
|
+
|
|
333
|
+
{/* Users List */}
|
|
334
|
+
<div className="bg-white shadow rounded-lg overflow-hidden">
|
|
335
|
+
<table className="min-w-full divide-y divide-gray-200">
|
|
336
|
+
<thead className="bg-gray-50">
|
|
337
|
+
<tr>
|
|
338
|
+
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
|
339
|
+
User
|
|
340
|
+
</th>
|
|
341
|
+
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
|
342
|
+
App User ID
|
|
343
|
+
</th>
|
|
344
|
+
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
|
345
|
+
App Org ID
|
|
346
|
+
</th>
|
|
347
|
+
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
|
348
|
+
Role
|
|
349
|
+
</th>
|
|
350
|
+
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
|
351
|
+
Connections
|
|
352
|
+
</th>
|
|
353
|
+
<th className="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">
|
|
354
|
+
Actions
|
|
355
|
+
</th>
|
|
356
|
+
</tr>
|
|
357
|
+
</thead>
|
|
358
|
+
<tbody className="bg-white divide-y divide-gray-200">
|
|
359
|
+
{filteredUsers.length === 0 ? (
|
|
360
|
+
<tr>
|
|
361
|
+
<td colSpan="6" className="px-6 py-12 text-center text-gray-500">
|
|
362
|
+
{users.length === 0 ? 'No users created yet' : 'No users match your filters'}
|
|
363
|
+
</td>
|
|
364
|
+
</tr>
|
|
365
|
+
) : (
|
|
366
|
+
filteredUsers.map((user) => (
|
|
367
|
+
<tr key={user.id || user.email}>
|
|
368
|
+
<td className="px-6 py-4 whitespace-nowrap">
|
|
369
|
+
<div className="flex items-center">
|
|
370
|
+
<div className="flex-shrink-0 h-10 w-10">
|
|
371
|
+
<div className="h-10 w-10 rounded-full bg-gray-300 flex items-center justify-center">
|
|
372
|
+
<span className="text-gray-600 font-medium">
|
|
373
|
+
{user.firstName?.[0]}{user.lastName?.[0]}
|
|
374
|
+
</span>
|
|
375
|
+
</div>
|
|
376
|
+
</div>
|
|
377
|
+
<div className="ml-4">
|
|
378
|
+
<div className="text-sm font-medium text-gray-900">
|
|
379
|
+
{user.firstName} {user.lastName}
|
|
380
|
+
</div>
|
|
381
|
+
<div className="text-sm text-gray-500">
|
|
382
|
+
{user.email}
|
|
383
|
+
</div>
|
|
384
|
+
</div>
|
|
385
|
+
</div>
|
|
386
|
+
</td>
|
|
387
|
+
<td className="px-6 py-4 whitespace-nowrap">
|
|
388
|
+
<code className="text-sm font-mono text-gray-600">{user.appUserId || generateTestId(user)}</code>
|
|
389
|
+
</td>
|
|
390
|
+
<td className="px-6 py-4 whitespace-nowrap">
|
|
391
|
+
<code className="text-sm font-mono text-gray-600">{user.appOrgId || 'N/A'}</code>
|
|
392
|
+
</td>
|
|
393
|
+
<td className="px-6 py-4 whitespace-nowrap">
|
|
394
|
+
<span className="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">
|
|
395
|
+
{user.role}
|
|
396
|
+
</span>
|
|
397
|
+
</td>
|
|
398
|
+
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
|
399
|
+
{user.connections?.length || 0} active
|
|
400
|
+
</td>
|
|
401
|
+
<td className="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
|
402
|
+
<button
|
|
403
|
+
onClick={() => handleEdit(user)}
|
|
404
|
+
className="text-frigg-blue hover:text-blue-700 mr-3"
|
|
405
|
+
>
|
|
406
|
+
Edit
|
|
407
|
+
</button>
|
|
408
|
+
<button
|
|
409
|
+
onClick={() => setShowDeleteConfirm(user.id)}
|
|
410
|
+
className="text-red-600 hover:text-red-900"
|
|
411
|
+
>
|
|
412
|
+
Delete
|
|
413
|
+
</button>
|
|
414
|
+
</td>
|
|
415
|
+
</tr>
|
|
416
|
+
))
|
|
417
|
+
)}
|
|
418
|
+
</tbody>
|
|
419
|
+
</table>
|
|
420
|
+
</div>
|
|
421
|
+
|
|
422
|
+
{/* Delete Confirmation Modal */}
|
|
423
|
+
{showDeleteConfirm && (
|
|
424
|
+
<div className="fixed inset-0 bg-gray-500 bg-opacity-75 flex items-center justify-center z-50">
|
|
425
|
+
<div className="bg-white rounded-lg p-6 max-w-md w-full">
|
|
426
|
+
<h3 className="text-lg font-medium text-gray-900 mb-4">Confirm Delete</h3>
|
|
427
|
+
<p className="text-gray-600 mb-6">
|
|
428
|
+
Are you sure you want to delete this user? This action cannot be undone.
|
|
429
|
+
</p>
|
|
430
|
+
<div className="flex justify-end space-x-3">
|
|
431
|
+
<button
|
|
432
|
+
onClick={() => setShowDeleteConfirm(null)}
|
|
433
|
+
className="px-4 py-2 bg-gray-300 text-gray-700 rounded-md hover:bg-gray-400"
|
|
434
|
+
>
|
|
435
|
+
Cancel
|
|
436
|
+
</button>
|
|
437
|
+
<button
|
|
438
|
+
onClick={() => handleDelete(showDeleteConfirm)}
|
|
439
|
+
className="px-4 py-2 bg-red-600 text-white rounded-md hover:bg-red-700"
|
|
440
|
+
>
|
|
441
|
+
Delete User
|
|
442
|
+
</button>
|
|
443
|
+
</div>
|
|
444
|
+
</div>
|
|
445
|
+
</div>
|
|
446
|
+
)}
|
|
447
|
+
|
|
448
|
+
{/* Info Box */}
|
|
449
|
+
<div className="mt-6 bg-yellow-50 border border-yellow-200 rounded-lg p-4">
|
|
450
|
+
<div className="flex">
|
|
451
|
+
<div className="flex-shrink-0">
|
|
452
|
+
<svg className="h-5 w-5 text-yellow-400" fill="currentColor" viewBox="0 0 20 20">
|
|
453
|
+
<path fillRule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clipRule="evenodd" />
|
|
454
|
+
</svg>
|
|
455
|
+
</div>
|
|
456
|
+
<div className="ml-3">
|
|
457
|
+
<p className="text-sm text-yellow-700">
|
|
458
|
+
Test users are for local development only. They simulate real users for testing integration flows
|
|
459
|
+
without requiring actual authentication.
|
|
460
|
+
</p>
|
|
461
|
+
</div>
|
|
462
|
+
</div>
|
|
463
|
+
</div>
|
|
464
|
+
</>
|
|
465
|
+
) : (
|
|
466
|
+
<>
|
|
467
|
+
{/* Sessions Tab Content */}
|
|
468
|
+
<SessionMonitor />
|
|
469
|
+
|
|
470
|
+
{/* Sessions Info Box */}
|
|
471
|
+
<div className="mt-6 bg-blue-50 border border-blue-200 rounded-lg p-4">
|
|
472
|
+
<div className="flex">
|
|
473
|
+
<div className="flex-shrink-0">
|
|
474
|
+
<svg className="h-5 w-5 text-blue-400" fill="currentColor" viewBox="0 0 20 20">
|
|
475
|
+
<path fillRule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clipRule="evenodd" />
|
|
476
|
+
</svg>
|
|
477
|
+
</div>
|
|
478
|
+
<div className="ml-3">
|
|
479
|
+
<p className="text-sm text-blue-700">
|
|
480
|
+
Sessions track user activity during development testing. Each session expires after 1 hour of inactivity
|
|
481
|
+
and can be refreshed to extend the duration.
|
|
482
|
+
</p>
|
|
483
|
+
</div>
|
|
484
|
+
</div>
|
|
485
|
+
</div>
|
|
486
|
+
</>
|
|
487
|
+
)}
|
|
488
|
+
</div>
|
|
489
|
+
)
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
export default Users
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import axios from 'axios'
|
|
2
|
+
|
|
3
|
+
const api = axios.create({
|
|
4
|
+
baseURL: import.meta.env.DEV ? 'http://localhost:3001' : '',
|
|
5
|
+
headers: {
|
|
6
|
+
'Content-Type': 'application/json',
|
|
7
|
+
},
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
// Request interceptor
|
|
11
|
+
api.interceptors.request.use(
|
|
12
|
+
(config) => {
|
|
13
|
+
// Add any auth tokens here if needed
|
|
14
|
+
return config
|
|
15
|
+
},
|
|
16
|
+
(error) => {
|
|
17
|
+
return Promise.reject(error)
|
|
18
|
+
}
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
// Response interceptor
|
|
22
|
+
api.interceptors.response.use(
|
|
23
|
+
(response) => {
|
|
24
|
+
return response
|
|
25
|
+
},
|
|
26
|
+
(error) => {
|
|
27
|
+
if (error.response) {
|
|
28
|
+
// Server responded with error status
|
|
29
|
+
console.error('API Error:', error.response.data)
|
|
30
|
+
} else if (error.request) {
|
|
31
|
+
// Request made but no response
|
|
32
|
+
console.error('Network Error:', error.request)
|
|
33
|
+
} else {
|
|
34
|
+
// Something else happened
|
|
35
|
+
console.error('Error:', error.message)
|
|
36
|
+
}
|
|
37
|
+
return Promise.reject(error)
|
|
38
|
+
}
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
export default api
|