@friggframework/devtools 2.0.0--canary.398.7664c46.0 → 2.0.0--canary.400.bed3308.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/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 +15 -2
- package/frigg-cli/deploy-command/index.js +15 -2
- 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 +350 -0
- package/frigg-cli/generate-command/terraform-generator.js +555 -0
- package/frigg-cli/index.js +66 -4
- package/frigg-cli/install-command/index.js +15 -2
- package/frigg-cli/package.json +75 -0
- package/frigg-cli/start-command/index.js +17 -2
- package/frigg-cli/ui-command/index.js +167 -0
- package/frigg-cli/utils/app-resolver.js +319 -0
- package/frigg-cli/utils/backend-path.js +38 -0
- package/frigg-cli/utils/process-manager.js +199 -0
- package/frigg-cli/utils/repo-detection.js +405 -0
- package/infrastructure/AWS-IAM-CREDENTIAL-NEEDS.md +43 -19
- package/infrastructure/IAM-POLICY-TEMPLATES.md +1 -1
- package/infrastructure/frigg-deployment-iam-stack.yaml +16 -2
- package/infrastructure/iam-generator.js +129 -6
- package/infrastructure/iam-policy-basic.json +29 -5
- package/infrastructure/iam-policy-full.json +28 -5
- package/infrastructure/serverless-template.js +209 -3
- package/infrastructure/serverless-template.test.js +12 -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/{dist/index.html → index.html} +1 -2
- package/management-ui/merge-conflict-cleaner.py +371 -0
- package/management-ui/package-lock.json +10997 -0
- package/management-ui/package.json +76 -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 +479 -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 +553 -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 +428 -0
- package/management-ui/server/middleware/errorHandler.js +70 -0
- package/management-ui/server/middleware/security.js +32 -0
- package/management-ui/server/processManager.js +296 -0
- package/management-ui/server/server.js +188 -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 +51 -0
- package/management-ui/src/components/AppRouter.jsx +65 -0
- package/management-ui/src/components/Button.jsx +2 -0
- package/management-ui/src/components/Card.jsx +9 -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 +199 -0
- package/management-ui/src/components/IntegrationCardEnhanced.jsx +490 -0
- package/management-ui/src/components/IntegrationExplorer.jsx +379 -0
- package/management-ui/src/components/IntegrationStatus.jsx +235 -0
- package/management-ui/src/components/Layout.jsx +250 -0
- package/management-ui/src/components/LoadingSpinner.jsx +45 -0
- package/management-ui/src/components/RepositoryPicker.jsx +248 -0
- package/management-ui/src/components/SessionMonitor.jsx +255 -0
- package/management-ui/src/components/StatusBadge.jsx +70 -0
- package/management-ui/src/components/UserContextSwitcher.jsx +154 -0
- package/management-ui/src/components/UserSimulation.jsx +299 -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 +387 -0
- package/management-ui/src/hooks/useSocket.jsx +58 -0
- package/management-ui/src/index.css +194 -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 +427 -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 +544 -0
- package/management-ui/src/pages/IntegrationDiscovery.jsx +479 -0
- package/management-ui/src/pages/IntegrationTest.jsx +494 -0
- package/management-ui/src/pages/Integrations.jsx +254 -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 +5 -5
- package/management-ui/dist/assets/index-CbM64Oba.js +0 -1221
- package/management-ui/dist/assets/index-CkvseXTC.css +0 -1
- /package/management-ui/{dist/assets/FriggLogo-B7Xx8ZW1.svg → src/assets/FriggLogo.svg} +0 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import { useFrigg } from '../hooks/useFrigg'
|
|
3
|
+
|
|
4
|
+
const Connections = () => {
|
|
5
|
+
const { connections, users, integrations } = useFrigg()
|
|
6
|
+
const [selectedConnection, setSelectedConnection] = useState(null)
|
|
7
|
+
const [viewMode, setViewMode] = useState('list') // list or details
|
|
8
|
+
|
|
9
|
+
const getIntegrationName = (integrationId) => {
|
|
10
|
+
const integration = integrations.find(i => i.id === integrationId)
|
|
11
|
+
return integration?.displayName || integration?.name || integrationId
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const getUserName = (userId) => {
|
|
15
|
+
const user = users.find(u => u.id === userId)
|
|
16
|
+
return user ? `${user.firstName} ${user.lastName}` : userId
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<div>
|
|
21
|
+
<div className="mb-8">
|
|
22
|
+
<h2 className="text-3xl font-bold text-gray-900">Connection Management</h2>
|
|
23
|
+
<p className="mt-2 text-gray-600">View and manage integration connections and entities</p>
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
{/* View Toggle */}
|
|
27
|
+
<div className="mb-6 flex justify-between items-center">
|
|
28
|
+
<div className="flex space-x-2">
|
|
29
|
+
<button
|
|
30
|
+
onClick={() => setViewMode('list')}
|
|
31
|
+
className={`px-4 py-2 rounded-md transition-colors ${
|
|
32
|
+
viewMode === 'list'
|
|
33
|
+
? 'bg-frigg-blue text-white'
|
|
34
|
+
: 'bg-gray-200 text-gray-700 hover:bg-gray-300'
|
|
35
|
+
}`}
|
|
36
|
+
>
|
|
37
|
+
List View
|
|
38
|
+
</button>
|
|
39
|
+
<button
|
|
40
|
+
onClick={() => setViewMode('details')}
|
|
41
|
+
className={`px-4 py-2 rounded-md transition-colors ${
|
|
42
|
+
viewMode === 'details'
|
|
43
|
+
? 'bg-frigg-blue text-white'
|
|
44
|
+
: 'bg-gray-200 text-gray-700 hover:bg-gray-300'
|
|
45
|
+
}`}
|
|
46
|
+
>
|
|
47
|
+
Details View
|
|
48
|
+
</button>
|
|
49
|
+
</div>
|
|
50
|
+
<div className="text-sm text-gray-600">
|
|
51
|
+
Total Connections: <span className="font-medium">{connections.length}</span>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
{viewMode === 'list' ? (
|
|
56
|
+
/* List View */
|
|
57
|
+
<div className="bg-white shadow rounded-lg overflow-hidden">
|
|
58
|
+
<table className="min-w-full divide-y divide-gray-200">
|
|
59
|
+
<thead className="bg-gray-50">
|
|
60
|
+
<tr>
|
|
61
|
+
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
|
62
|
+
Connection
|
|
63
|
+
</th>
|
|
64
|
+
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
|
65
|
+
User
|
|
66
|
+
</th>
|
|
67
|
+
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
|
68
|
+
Status
|
|
69
|
+
</th>
|
|
70
|
+
<th className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
|
71
|
+
Entities
|
|
72
|
+
</th>
|
|
73
|
+
<th className="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">
|
|
74
|
+
Actions
|
|
75
|
+
</th>
|
|
76
|
+
</tr>
|
|
77
|
+
</thead>
|
|
78
|
+
<tbody className="bg-white divide-y divide-gray-200">
|
|
79
|
+
{connections.map((connection) => (
|
|
80
|
+
<tr key={connection.id}>
|
|
81
|
+
<td className="px-6 py-4 whitespace-nowrap">
|
|
82
|
+
<div className="text-sm font-medium text-gray-900">
|
|
83
|
+
{getIntegrationName(connection.integrationId)}
|
|
84
|
+
</div>
|
|
85
|
+
<div className="text-sm text-gray-500">
|
|
86
|
+
ID: {connection.id}
|
|
87
|
+
</div>
|
|
88
|
+
</td>
|
|
89
|
+
<td className="px-6 py-4 whitespace-nowrap">
|
|
90
|
+
<div className="text-sm text-gray-900">
|
|
91
|
+
{getUserName(connection.userId)}
|
|
92
|
+
</div>
|
|
93
|
+
</td>
|
|
94
|
+
<td className="px-6 py-4 whitespace-nowrap">
|
|
95
|
+
<span className={`px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${
|
|
96
|
+
connection.active
|
|
97
|
+
? 'bg-green-100 text-green-800'
|
|
98
|
+
: 'bg-red-100 text-red-800'
|
|
99
|
+
}`}>
|
|
100
|
+
{connection.active ? 'Active' : 'Inactive'}
|
|
101
|
+
</span>
|
|
102
|
+
</td>
|
|
103
|
+
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
|
104
|
+
{connection.entities?.length || 0} entities
|
|
105
|
+
</td>
|
|
106
|
+
<td className="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
|
|
107
|
+
<button
|
|
108
|
+
onClick={() => {
|
|
109
|
+
setSelectedConnection(connection)
|
|
110
|
+
setViewMode('details')
|
|
111
|
+
}}
|
|
112
|
+
className="text-frigg-blue hover:text-blue-700 mr-3"
|
|
113
|
+
>
|
|
114
|
+
View Details
|
|
115
|
+
</button>
|
|
116
|
+
<button className="text-red-600 hover:text-red-900">
|
|
117
|
+
Disconnect
|
|
118
|
+
</button>
|
|
119
|
+
</td>
|
|
120
|
+
</tr>
|
|
121
|
+
))}
|
|
122
|
+
</tbody>
|
|
123
|
+
</table>
|
|
124
|
+
</div>
|
|
125
|
+
) : (
|
|
126
|
+
/* Details View */
|
|
127
|
+
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
|
128
|
+
{/* Connection List */}
|
|
129
|
+
<div className="lg:col-span-1">
|
|
130
|
+
<div className="bg-white shadow rounded-lg p-4">
|
|
131
|
+
<h3 className="text-lg font-medium text-gray-900 mb-4">Connections</h3>
|
|
132
|
+
<div className="space-y-2">
|
|
133
|
+
{connections.map((connection) => (
|
|
134
|
+
<button
|
|
135
|
+
key={connection.id}
|
|
136
|
+
onClick={() => setSelectedConnection(connection)}
|
|
137
|
+
className={`w-full text-left px-3 py-2 rounded-md transition-colors ${
|
|
138
|
+
selectedConnection?.id === connection.id
|
|
139
|
+
? 'bg-frigg-blue text-white'
|
|
140
|
+
: 'hover:bg-gray-100'
|
|
141
|
+
}`}
|
|
142
|
+
>
|
|
143
|
+
<div className="font-medium">
|
|
144
|
+
{getIntegrationName(connection.integrationId)}
|
|
145
|
+
</div>
|
|
146
|
+
<div className={`text-sm ${
|
|
147
|
+
selectedConnection?.id === connection.id ? 'text-blue-100' : 'text-gray-500'
|
|
148
|
+
}`}>
|
|
149
|
+
{getUserName(connection.userId)}
|
|
150
|
+
</div>
|
|
151
|
+
</button>
|
|
152
|
+
))}
|
|
153
|
+
</div>
|
|
154
|
+
</div>
|
|
155
|
+
</div>
|
|
156
|
+
|
|
157
|
+
{/* Connection Details */}
|
|
158
|
+
<div className="lg:col-span-2">
|
|
159
|
+
{selectedConnection ? (
|
|
160
|
+
<div className="bg-white shadow rounded-lg p-6">
|
|
161
|
+
<h3 className="text-lg font-medium text-gray-900 mb-4">Connection Details</h3>
|
|
162
|
+
|
|
163
|
+
{/* Basic Info */}
|
|
164
|
+
<div className="mb-6">
|
|
165
|
+
<dl className="grid grid-cols-2 gap-4">
|
|
166
|
+
<div>
|
|
167
|
+
<dt className="text-sm font-medium text-gray-500">Integration</dt>
|
|
168
|
+
<dd className="mt-1 text-sm text-gray-900">
|
|
169
|
+
{getIntegrationName(selectedConnection.integrationId)}
|
|
170
|
+
</dd>
|
|
171
|
+
</div>
|
|
172
|
+
<div>
|
|
173
|
+
<dt className="text-sm font-medium text-gray-500">User</dt>
|
|
174
|
+
<dd className="mt-1 text-sm text-gray-900">
|
|
175
|
+
{getUserName(selectedConnection.userId)}
|
|
176
|
+
</dd>
|
|
177
|
+
</div>
|
|
178
|
+
<div>
|
|
179
|
+
<dt className="text-sm font-medium text-gray-500">Status</dt>
|
|
180
|
+
<dd className="mt-1">
|
|
181
|
+
<span className={`px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${
|
|
182
|
+
selectedConnection.active
|
|
183
|
+
? 'bg-green-100 text-green-800'
|
|
184
|
+
: 'bg-red-100 text-red-800'
|
|
185
|
+
}`}>
|
|
186
|
+
{selectedConnection.active ? 'Active' : 'Inactive'}
|
|
187
|
+
</span>
|
|
188
|
+
</dd>
|
|
189
|
+
</div>
|
|
190
|
+
<div>
|
|
191
|
+
<dt className="text-sm font-medium text-gray-500">Created</dt>
|
|
192
|
+
<dd className="mt-1 text-sm text-gray-900">
|
|
193
|
+
{new Date(selectedConnection.createdAt).toLocaleDateString()}
|
|
194
|
+
</dd>
|
|
195
|
+
</div>
|
|
196
|
+
</dl>
|
|
197
|
+
</div>
|
|
198
|
+
|
|
199
|
+
{/* Entities */}
|
|
200
|
+
<div>
|
|
201
|
+
<h4 className="text-md font-medium text-gray-900 mb-3">Entities</h4>
|
|
202
|
+
{selectedConnection.entities?.length > 0 ? (
|
|
203
|
+
<div className="border border-gray-200 rounded-lg overflow-hidden">
|
|
204
|
+
<table className="min-w-full divide-y divide-gray-200">
|
|
205
|
+
<thead className="bg-gray-50">
|
|
206
|
+
<tr>
|
|
207
|
+
<th className="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">
|
|
208
|
+
Type
|
|
209
|
+
</th>
|
|
210
|
+
<th className="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">
|
|
211
|
+
ID
|
|
212
|
+
</th>
|
|
213
|
+
<th className="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">
|
|
214
|
+
Name
|
|
215
|
+
</th>
|
|
216
|
+
</tr>
|
|
217
|
+
</thead>
|
|
218
|
+
<tbody className="bg-white divide-y divide-gray-200">
|
|
219
|
+
{selectedConnection.entities.map((entity, index) => (
|
|
220
|
+
<tr key={index}>
|
|
221
|
+
<td className="px-4 py-2 whitespace-nowrap text-sm text-gray-900">
|
|
222
|
+
{entity.type}
|
|
223
|
+
</td>
|
|
224
|
+
<td className="px-4 py-2 whitespace-nowrap text-sm font-mono text-gray-600">
|
|
225
|
+
{entity.id}
|
|
226
|
+
</td>
|
|
227
|
+
<td className="px-4 py-2 whitespace-nowrap text-sm text-gray-900">
|
|
228
|
+
{entity.name}
|
|
229
|
+
</td>
|
|
230
|
+
</tr>
|
|
231
|
+
))}
|
|
232
|
+
</tbody>
|
|
233
|
+
</table>
|
|
234
|
+
</div>
|
|
235
|
+
) : (
|
|
236
|
+
<p className="text-sm text-gray-500">No entities found for this connection.</p>
|
|
237
|
+
)}
|
|
238
|
+
</div>
|
|
239
|
+
</div>
|
|
240
|
+
) : (
|
|
241
|
+
<div className="bg-white shadow rounded-lg p-6">
|
|
242
|
+
<p className="text-gray-500 text-center">Select a connection to view details</p>
|
|
243
|
+
</div>
|
|
244
|
+
)}
|
|
245
|
+
</div>
|
|
246
|
+
</div>
|
|
247
|
+
)}
|
|
248
|
+
</div>
|
|
249
|
+
)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export default Connections
|
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
|
2
|
+
import { useFrigg } from '../hooks/useFrigg'
|
|
3
|
+
import { useSocket } from '../hooks/useSocket'
|
|
4
|
+
import { Button } from '../components/Button'
|
|
5
|
+
import { Card } from '../components/Card'
|
|
6
|
+
import StatusBadge from '../components/StatusBadge'
|
|
7
|
+
import OAuthFlow from '../components/connections/OAuthFlow'
|
|
8
|
+
import ConnectionTester from '../components/connections/ConnectionTester'
|
|
9
|
+
import ConnectionHealthMonitor from '../components/connections/ConnectionHealthMonitor'
|
|
10
|
+
import EntityRelationshipMapper from '../components/connections/EntityRelationshipMapper'
|
|
11
|
+
import ConnectionConfigForm from '../components/connections/ConnectionConfigForm'
|
|
12
|
+
import api from '../services/api'
|
|
13
|
+
|
|
14
|
+
const ConnectionsEnhanced = () => {
|
|
15
|
+
const { connections, users, integrations, refreshConnections } = useFrigg()
|
|
16
|
+
const { socket, emit, on } = useSocket()
|
|
17
|
+
const [selectedConnection, setSelectedConnection] = useState(null)
|
|
18
|
+
const [activeView, setActiveView] = useState('overview') // overview, test, health, entities, config
|
|
19
|
+
const [showOAuthFlow, setShowOAuthFlow] = useState(false)
|
|
20
|
+
const [showConfigForm, setShowConfigForm] = useState(false)
|
|
21
|
+
const [selectedIntegration, setSelectedIntegration] = useState(null)
|
|
22
|
+
const [connectionStats, setConnectionStats] = useState(null)
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
fetchConnectionStats()
|
|
26
|
+
|
|
27
|
+
// Subscribe to real-time updates
|
|
28
|
+
const unsubscribeUpdate = on('connection-update', handleConnectionUpdate)
|
|
29
|
+
const unsubscribeTest = on('connection-test', handleTestUpdate)
|
|
30
|
+
emit('subscribe', { topics: ['connections'] })
|
|
31
|
+
|
|
32
|
+
return () => {
|
|
33
|
+
if (unsubscribeUpdate) unsubscribeUpdate()
|
|
34
|
+
if (unsubscribeTest) unsubscribeTest()
|
|
35
|
+
emit('unsubscribe', { topics: ['connections'] })
|
|
36
|
+
}
|
|
37
|
+
}, [socket])
|
|
38
|
+
|
|
39
|
+
const fetchConnectionStats = async () => {
|
|
40
|
+
try {
|
|
41
|
+
const response = await api.get('/api/connections/stats/summary')
|
|
42
|
+
setConnectionStats(response.data)
|
|
43
|
+
} catch (error) {
|
|
44
|
+
console.error('Failed to fetch connection stats:', error)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const handleConnectionUpdate = (data) => {
|
|
49
|
+
refreshConnections()
|
|
50
|
+
fetchConnectionStats()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const handleTestUpdate = (data) => {
|
|
54
|
+
if (selectedConnection?.id === data.connectionId) {
|
|
55
|
+
// Update selected connection with test results
|
|
56
|
+
setSelectedConnection(prev => ({
|
|
57
|
+
...prev,
|
|
58
|
+
lastTestResult: data.summary
|
|
59
|
+
}))
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const handleCreateConnection = (integration) => {
|
|
64
|
+
setSelectedIntegration(integration)
|
|
65
|
+
setShowOAuthFlow(true)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const handleOAuthSuccess = async (connection) => {
|
|
69
|
+
setShowOAuthFlow(false)
|
|
70
|
+
setSelectedIntegration(null)
|
|
71
|
+
await refreshConnections()
|
|
72
|
+
setSelectedConnection(connection)
|
|
73
|
+
setActiveView('config')
|
|
74
|
+
setShowConfigForm(true)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const handleConfigSave = async (config) => {
|
|
78
|
+
setShowConfigForm(false)
|
|
79
|
+
await refreshConnections()
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const handleDeleteConnection = async (connectionId) => {
|
|
83
|
+
if (confirm('Are you sure you want to delete this connection?')) {
|
|
84
|
+
try {
|
|
85
|
+
await api.delete(`/api/connections/${connectionId}`)
|
|
86
|
+
await refreshConnections()
|
|
87
|
+
if (selectedConnection?.id === connectionId) {
|
|
88
|
+
setSelectedConnection(null)
|
|
89
|
+
}
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error('Failed to delete connection:', error)
|
|
92
|
+
alert('Failed to delete connection')
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const getIntegrationDetails = (integrationId) => {
|
|
98
|
+
return integrations.find(i => i.id === integrationId) || { name: integrationId }
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const getUserDetails = (userId) => {
|
|
102
|
+
const user = users.find(u => u.id === userId)
|
|
103
|
+
return user ? `${user.firstName} ${user.lastName}` : userId
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return (
|
|
107
|
+
<div className="space-y-6">
|
|
108
|
+
{/* Header */}
|
|
109
|
+
<div className="flex items-center justify-between">
|
|
110
|
+
<div>
|
|
111
|
+
<h2 className="text-3xl font-bold text-gray-900">Connection Management</h2>
|
|
112
|
+
<p className="mt-2 text-gray-600">
|
|
113
|
+
Manage integration connections, test connectivity, and monitor health
|
|
114
|
+
</p>
|
|
115
|
+
</div>
|
|
116
|
+
<Button onClick={() => setShowOAuthFlow(true)} variant="primary">
|
|
117
|
+
New Connection
|
|
118
|
+
</Button>
|
|
119
|
+
</div>
|
|
120
|
+
|
|
121
|
+
{/* Stats Overview */}
|
|
122
|
+
{connectionStats && (
|
|
123
|
+
<div className="grid grid-cols-1 md:grid-cols-4 gap-4">
|
|
124
|
+
<Card>
|
|
125
|
+
<div className="p-4">
|
|
126
|
+
<p className="text-sm text-gray-500">Total Connections</p>
|
|
127
|
+
<p className="text-2xl font-bold text-gray-900">
|
|
128
|
+
{connectionStats.totalConnections}
|
|
129
|
+
</p>
|
|
130
|
+
</div>
|
|
131
|
+
</Card>
|
|
132
|
+
<Card>
|
|
133
|
+
<div className="p-4">
|
|
134
|
+
<p className="text-sm text-gray-500">Active</p>
|
|
135
|
+
<p className="text-2xl font-bold text-green-600">
|
|
136
|
+
{connectionStats.activeConnections}
|
|
137
|
+
</p>
|
|
138
|
+
</div>
|
|
139
|
+
</Card>
|
|
140
|
+
<Card>
|
|
141
|
+
<div className="p-4">
|
|
142
|
+
<p className="text-sm text-gray-500">Total Entities</p>
|
|
143
|
+
<p className="text-2xl font-bold text-gray-900">
|
|
144
|
+
{connectionStats.totalEntities}
|
|
145
|
+
</p>
|
|
146
|
+
</div>
|
|
147
|
+
</Card>
|
|
148
|
+
<Card>
|
|
149
|
+
<div className="p-4">
|
|
150
|
+
<p className="text-sm text-gray-500">Recently Used</p>
|
|
151
|
+
<p className="text-2xl font-bold text-blue-600">
|
|
152
|
+
{connectionStats.recentlyUsed}
|
|
153
|
+
</p>
|
|
154
|
+
</div>
|
|
155
|
+
</Card>
|
|
156
|
+
</div>
|
|
157
|
+
)}
|
|
158
|
+
|
|
159
|
+
{/* Main Content */}
|
|
160
|
+
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
|
161
|
+
{/* Connections List */}
|
|
162
|
+
<div className="lg:col-span-1">
|
|
163
|
+
<Card>
|
|
164
|
+
<div className="p-4">
|
|
165
|
+
<h3 className="text-lg font-semibold text-gray-900 mb-4">Connections</h3>
|
|
166
|
+
<div className="space-y-2">
|
|
167
|
+
{connections.map((connection) => {
|
|
168
|
+
const integration = getIntegrationDetails(connection.integration)
|
|
169
|
+
return (
|
|
170
|
+
<button
|
|
171
|
+
key={connection.id}
|
|
172
|
+
onClick={() => {
|
|
173
|
+
setSelectedConnection(connection)
|
|
174
|
+
setActiveView('overview')
|
|
175
|
+
}}
|
|
176
|
+
className={`w-full text-left p-3 rounded-lg transition-colors ${
|
|
177
|
+
selectedConnection?.id === connection.id
|
|
178
|
+
? 'bg-blue-50 border-blue-500 border'
|
|
179
|
+
: 'hover:bg-gray-50 border border-gray-200'
|
|
180
|
+
}`}
|
|
181
|
+
>
|
|
182
|
+
<div className="flex items-center justify-between">
|
|
183
|
+
<div className="flex-1">
|
|
184
|
+
<p className="font-medium text-gray-900">
|
|
185
|
+
{connection.name || integration.displayName || integration.name}
|
|
186
|
+
</p>
|
|
187
|
+
<p className="text-sm text-gray-500">
|
|
188
|
+
{getUserDetails(connection.userId)}
|
|
189
|
+
</p>
|
|
190
|
+
</div>
|
|
191
|
+
<ConnectionHealthMonitor
|
|
192
|
+
connectionId={connection.id}
|
|
193
|
+
compact={true}
|
|
194
|
+
/>
|
|
195
|
+
</div>
|
|
196
|
+
</button>
|
|
197
|
+
)
|
|
198
|
+
})}
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
{connections.length === 0 && (
|
|
202
|
+
<p className="text-center text-gray-500 py-8">
|
|
203
|
+
No connections yet. Create your first connection above.
|
|
204
|
+
</p>
|
|
205
|
+
)}
|
|
206
|
+
</div>
|
|
207
|
+
</Card>
|
|
208
|
+
</div>
|
|
209
|
+
|
|
210
|
+
{/* Detail View */}
|
|
211
|
+
<div className="lg:col-span-2">
|
|
212
|
+
{selectedConnection ? (
|
|
213
|
+
<div className="space-y-6">
|
|
214
|
+
{/* Connection Header */}
|
|
215
|
+
<Card>
|
|
216
|
+
<div className="p-6">
|
|
217
|
+
<div className="flex items-center justify-between mb-4">
|
|
218
|
+
<div>
|
|
219
|
+
<h3 className="text-xl font-semibold text-gray-900">
|
|
220
|
+
{selectedConnection.name ||
|
|
221
|
+
getIntegrationDetails(selectedConnection.integration).displayName}
|
|
222
|
+
</h3>
|
|
223
|
+
<p className="text-sm text-gray-500">
|
|
224
|
+
Connected by {getUserDetails(selectedConnection.userId)}
|
|
225
|
+
</p>
|
|
226
|
+
</div>
|
|
227
|
+
<div className="flex items-center space-x-2">
|
|
228
|
+
<StatusBadge
|
|
229
|
+
status={selectedConnection.status === 'active' ? 'success' : 'error'}
|
|
230
|
+
text={selectedConnection.status}
|
|
231
|
+
/>
|
|
232
|
+
<Button
|
|
233
|
+
onClick={() => handleDeleteConnection(selectedConnection.id)}
|
|
234
|
+
variant="secondary"
|
|
235
|
+
size="sm"
|
|
236
|
+
>
|
|
237
|
+
Delete
|
|
238
|
+
</Button>
|
|
239
|
+
</div>
|
|
240
|
+
</div>
|
|
241
|
+
|
|
242
|
+
{/* View Tabs */}
|
|
243
|
+
<div className="flex space-x-1 border-b border-gray-200">
|
|
244
|
+
{[
|
|
245
|
+
{ id: 'overview', label: 'Overview' },
|
|
246
|
+
{ id: 'test', label: 'Test' },
|
|
247
|
+
{ id: 'health', label: 'Health' },
|
|
248
|
+
{ id: 'entities', label: 'Entities' },
|
|
249
|
+
{ id: 'config', label: 'Configuration' }
|
|
250
|
+
].map(tab => (
|
|
251
|
+
<button
|
|
252
|
+
key={tab.id}
|
|
253
|
+
onClick={() => setActiveView(tab.id)}
|
|
254
|
+
className={`px-4 py-2 text-sm font-medium border-b-2 transition-colors ${
|
|
255
|
+
activeView === tab.id
|
|
256
|
+
? 'text-blue-600 border-blue-600'
|
|
257
|
+
: 'text-gray-500 border-transparent hover:text-gray-700'
|
|
258
|
+
}`}
|
|
259
|
+
>
|
|
260
|
+
{tab.label}
|
|
261
|
+
</button>
|
|
262
|
+
))}
|
|
263
|
+
</div>
|
|
264
|
+
</div>
|
|
265
|
+
</Card>
|
|
266
|
+
|
|
267
|
+
{/* Active View Content */}
|
|
268
|
+
{activeView === 'overview' && (
|
|
269
|
+
<Card>
|
|
270
|
+
<div className="p-6">
|
|
271
|
+
<h4 className="text-lg font-semibold text-gray-900 mb-4">
|
|
272
|
+
Connection Details
|
|
273
|
+
</h4>
|
|
274
|
+
<dl className="grid grid-cols-2 gap-4">
|
|
275
|
+
<div>
|
|
276
|
+
<dt className="text-sm font-medium text-gray-500">Connection ID</dt>
|
|
277
|
+
<dd className="mt-1 text-sm text-gray-900 font-mono">
|
|
278
|
+
{selectedConnection.id}
|
|
279
|
+
</dd>
|
|
280
|
+
</div>
|
|
281
|
+
<div>
|
|
282
|
+
<dt className="text-sm font-medium text-gray-500">Created</dt>
|
|
283
|
+
<dd className="mt-1 text-sm text-gray-900">
|
|
284
|
+
{new Date(selectedConnection.createdAt).toLocaleString()}
|
|
285
|
+
</dd>
|
|
286
|
+
</div>
|
|
287
|
+
<div>
|
|
288
|
+
<dt className="text-sm font-medium text-gray-500">Last Updated</dt>
|
|
289
|
+
<dd className="mt-1 text-sm text-gray-900">
|
|
290
|
+
{new Date(selectedConnection.updatedAt).toLocaleString()}
|
|
291
|
+
</dd>
|
|
292
|
+
</div>
|
|
293
|
+
<div>
|
|
294
|
+
<dt className="text-sm font-medium text-gray-500">Last Used</dt>
|
|
295
|
+
<dd className="mt-1 text-sm text-gray-900">
|
|
296
|
+
{selectedConnection.lastUsed
|
|
297
|
+
? new Date(selectedConnection.lastUsed).toLocaleString()
|
|
298
|
+
: 'Never'}
|
|
299
|
+
</dd>
|
|
300
|
+
</div>
|
|
301
|
+
</dl>
|
|
302
|
+
|
|
303
|
+
{selectedConnection.description && (
|
|
304
|
+
<div className="mt-4">
|
|
305
|
+
<h5 className="text-sm font-medium text-gray-500">Description</h5>
|
|
306
|
+
<p className="mt-1 text-sm text-gray-900">
|
|
307
|
+
{selectedConnection.description}
|
|
308
|
+
</p>
|
|
309
|
+
</div>
|
|
310
|
+
)}
|
|
311
|
+
</div>
|
|
312
|
+
</Card>
|
|
313
|
+
)}
|
|
314
|
+
|
|
315
|
+
{activeView === 'test' && (
|
|
316
|
+
<ConnectionTester
|
|
317
|
+
connection={selectedConnection}
|
|
318
|
+
onTestComplete={(result) => {
|
|
319
|
+
// Handle test completion
|
|
320
|
+
console.log('Test completed:', result)
|
|
321
|
+
}}
|
|
322
|
+
/>
|
|
323
|
+
)}
|
|
324
|
+
|
|
325
|
+
{activeView === 'health' && (
|
|
326
|
+
<ConnectionHealthMonitor
|
|
327
|
+
connectionId={selectedConnection.id}
|
|
328
|
+
compact={false}
|
|
329
|
+
/>
|
|
330
|
+
)}
|
|
331
|
+
|
|
332
|
+
{activeView === 'entities' && (
|
|
333
|
+
<EntityRelationshipMapper
|
|
334
|
+
connectionId={selectedConnection.id}
|
|
335
|
+
/>
|
|
336
|
+
)}
|
|
337
|
+
|
|
338
|
+
{activeView === 'config' && (
|
|
339
|
+
<Card>
|
|
340
|
+
<div className="p-6">
|
|
341
|
+
{showConfigForm ? (
|
|
342
|
+
<ConnectionConfigForm
|
|
343
|
+
connection={selectedConnection}
|
|
344
|
+
integration={getIntegrationDetails(selectedConnection.integration)}
|
|
345
|
+
onSave={handleConfigSave}
|
|
346
|
+
onCancel={() => setShowConfigForm(false)}
|
|
347
|
+
/>
|
|
348
|
+
) : (
|
|
349
|
+
<div>
|
|
350
|
+
<h4 className="text-lg font-semibold text-gray-900 mb-4">
|
|
351
|
+
Configuration
|
|
352
|
+
</h4>
|
|
353
|
+
<Button
|
|
354
|
+
onClick={() => setShowConfigForm(true)}
|
|
355
|
+
variant="primary"
|
|
356
|
+
>
|
|
357
|
+
Edit Configuration
|
|
358
|
+
</Button>
|
|
359
|
+
</div>
|
|
360
|
+
)}
|
|
361
|
+
</div>
|
|
362
|
+
</Card>
|
|
363
|
+
)}
|
|
364
|
+
</div>
|
|
365
|
+
) : (
|
|
366
|
+
<Card>
|
|
367
|
+
<div className="p-8 text-center">
|
|
368
|
+
<p className="text-gray-500">
|
|
369
|
+
Select a connection to view details and manage settings
|
|
370
|
+
</p>
|
|
371
|
+
</div>
|
|
372
|
+
</Card>
|
|
373
|
+
)}
|
|
374
|
+
</div>
|
|
375
|
+
</div>
|
|
376
|
+
|
|
377
|
+
{/* OAuth Flow Modal */}
|
|
378
|
+
{showOAuthFlow && (
|
|
379
|
+
<div className="fixed inset-0 bg-gray-500 bg-opacity-75 flex items-center justify-center z-50">
|
|
380
|
+
<div className="bg-white rounded-lg p-6 max-w-lg w-full">
|
|
381
|
+
{selectedIntegration ? (
|
|
382
|
+
<OAuthFlow
|
|
383
|
+
integration={selectedIntegration}
|
|
384
|
+
onSuccess={handleOAuthSuccess}
|
|
385
|
+
onCancel={() => {
|
|
386
|
+
setShowOAuthFlow(false)
|
|
387
|
+
setSelectedIntegration(null)
|
|
388
|
+
}}
|
|
389
|
+
/>
|
|
390
|
+
) : (
|
|
391
|
+
<div>
|
|
392
|
+
<h3 className="text-lg font-semibold text-gray-900 mb-4">
|
|
393
|
+
Select Integration
|
|
394
|
+
</h3>
|
|
395
|
+
<div className="space-y-2">
|
|
396
|
+
{integrations.map((integration) => (
|
|
397
|
+
<button
|
|
398
|
+
key={integration.id}
|
|
399
|
+
onClick={() => setSelectedIntegration(integration)}
|
|
400
|
+
className="w-full text-left p-3 rounded-lg border border-gray-200 hover:bg-gray-50"
|
|
401
|
+
>
|
|
402
|
+
<p className="font-medium text-gray-900">
|
|
403
|
+
{integration.displayName || integration.name}
|
|
404
|
+
</p>
|
|
405
|
+
<p className="text-sm text-gray-500">
|
|
406
|
+
{integration.description}
|
|
407
|
+
</p>
|
|
408
|
+
</button>
|
|
409
|
+
))}
|
|
410
|
+
</div>
|
|
411
|
+
<Button
|
|
412
|
+
onClick={() => setShowOAuthFlow(false)}
|
|
413
|
+
variant="secondary"
|
|
414
|
+
className="mt-4 w-full"
|
|
415
|
+
>
|
|
416
|
+
Cancel
|
|
417
|
+
</Button>
|
|
418
|
+
</div>
|
|
419
|
+
)}
|
|
420
|
+
</div>
|
|
421
|
+
</div>
|
|
422
|
+
)}
|
|
423
|
+
</div>
|
|
424
|
+
)
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
export default ConnectionsEnhanced
|