machinaos 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.template +71 -0
- package/LICENSE +21 -0
- package/README.md +87 -0
- package/bin/cli.js +159 -0
- package/client/.dockerignore +45 -0
- package/client/Dockerfile +68 -0
- package/client/eslint.config.js +29 -0
- package/client/index.html +13 -0
- package/client/nginx.conf +66 -0
- package/client/package.json +48 -0
- package/client/src/App.tsx +27 -0
- package/client/src/Dashboard.tsx +1173 -0
- package/client/src/ParameterPanel.tsx +301 -0
- package/client/src/components/AIAgentNode.tsx +321 -0
- package/client/src/components/APIKeyValidator.tsx +118 -0
- package/client/src/components/ClaudeChatModelNode.tsx +18 -0
- package/client/src/components/ConditionalEdge.tsx +189 -0
- package/client/src/components/CredentialsModal.tsx +306 -0
- package/client/src/components/EdgeConditionEditor.tsx +443 -0
- package/client/src/components/GeminiChatModelNode.tsx +18 -0
- package/client/src/components/GenericNode.tsx +357 -0
- package/client/src/components/LocationParameterPanel.tsx +154 -0
- package/client/src/components/ModelNode.tsx +286 -0
- package/client/src/components/OpenAIChatModelNode.tsx +18 -0
- package/client/src/components/OutputPanel.tsx +471 -0
- package/client/src/components/ParameterRenderer.tsx +1874 -0
- package/client/src/components/SkillEditorModal.tsx +417 -0
- package/client/src/components/SquareNode.tsx +797 -0
- package/client/src/components/StartNode.tsx +250 -0
- package/client/src/components/ToolkitNode.tsx +365 -0
- package/client/src/components/TriggerNode.tsx +463 -0
- package/client/src/components/auth/LoginPage.tsx +247 -0
- package/client/src/components/auth/ProtectedRoute.tsx +59 -0
- package/client/src/components/base/BaseChatModelNode.tsx +271 -0
- package/client/src/components/icons/AIProviderIcons.tsx +50 -0
- package/client/src/components/maps/GoogleMapsPicker.tsx +137 -0
- package/client/src/components/maps/MapsPreviewPanel.tsx +110 -0
- package/client/src/components/maps/index.ts +26 -0
- package/client/src/components/parameterPanel/InputSection.tsx +1094 -0
- package/client/src/components/parameterPanel/LocationPanelLayout.tsx +65 -0
- package/client/src/components/parameterPanel/MapsSection.tsx +92 -0
- package/client/src/components/parameterPanel/MiddleSection.tsx +571 -0
- package/client/src/components/parameterPanel/OutputSection.tsx +81 -0
- package/client/src/components/parameterPanel/ParameterPanelLayout.tsx +82 -0
- package/client/src/components/parameterPanel/ToolSchemaEditor.tsx +436 -0
- package/client/src/components/parameterPanel/index.ts +42 -0
- package/client/src/components/shared/DataPanel.tsx +142 -0
- package/client/src/components/shared/JSONTreeRenderer.tsx +106 -0
- package/client/src/components/ui/AIResultModal.tsx +204 -0
- package/client/src/components/ui/AndroidSettingsPanel.tsx +401 -0
- package/client/src/components/ui/CodeEditor.tsx +81 -0
- package/client/src/components/ui/CollapsibleSection.tsx +88 -0
- package/client/src/components/ui/ComponentItem.tsx +154 -0
- package/client/src/components/ui/ComponentPalette.tsx +321 -0
- package/client/src/components/ui/ConsolePanel.tsx +1074 -0
- package/client/src/components/ui/ErrorBoundary.tsx +196 -0
- package/client/src/components/ui/InputNodesPanel.tsx +204 -0
- package/client/src/components/ui/MapSelector.tsx +314 -0
- package/client/src/components/ui/Modal.tsx +149 -0
- package/client/src/components/ui/NodeContextMenu.tsx +192 -0
- package/client/src/components/ui/NodeOutputPanel.tsx +1150 -0
- package/client/src/components/ui/OutputDisplayPanel.tsx +381 -0
- package/client/src/components/ui/SettingsPanel.tsx +243 -0
- package/client/src/components/ui/TopToolbar.tsx +736 -0
- package/client/src/components/ui/WhatsAppSettingsPanel.tsx +345 -0
- package/client/src/components/ui/WorkflowSidebar.tsx +294 -0
- package/client/src/config/antdTheme.ts +186 -0
- package/client/src/config/api.ts +54 -0
- package/client/src/contexts/AuthContext.tsx +221 -0
- package/client/src/contexts/ThemeContext.tsx +42 -0
- package/client/src/contexts/WebSocketContext.tsx +1971 -0
- package/client/src/factories/baseChatModelFactory.ts +256 -0
- package/client/src/hooks/useAndroidOperations.ts +164 -0
- package/client/src/hooks/useApiKeyValidation.ts +107 -0
- package/client/src/hooks/useApiKeys.ts +238 -0
- package/client/src/hooks/useAppTheme.ts +17 -0
- package/client/src/hooks/useComponentPalette.ts +51 -0
- package/client/src/hooks/useCopyPaste.ts +155 -0
- package/client/src/hooks/useDragAndDrop.ts +124 -0
- package/client/src/hooks/useDragVariable.ts +88 -0
- package/client/src/hooks/useExecution.ts +313 -0
- package/client/src/hooks/useParameterPanel.ts +176 -0
- package/client/src/hooks/useReactFlowNodes.ts +189 -0
- package/client/src/hooks/useToolSchema.ts +209 -0
- package/client/src/hooks/useWhatsApp.ts +196 -0
- package/client/src/hooks/useWorkflowManagement.ts +46 -0
- package/client/src/index.css +315 -0
- package/client/src/main.tsx +19 -0
- package/client/src/nodeDefinitions/aiAgentNodes.ts +336 -0
- package/client/src/nodeDefinitions/aiModelNodes.ts +340 -0
- package/client/src/nodeDefinitions/androidDeviceNodes.ts +140 -0
- package/client/src/nodeDefinitions/androidServiceNodes.ts +383 -0
- package/client/src/nodeDefinitions/chatNodes.ts +135 -0
- package/client/src/nodeDefinitions/codeNodes.ts +54 -0
- package/client/src/nodeDefinitions/documentNodes.ts +379 -0
- package/client/src/nodeDefinitions/index.ts +15 -0
- package/client/src/nodeDefinitions/locationNodes.ts +463 -0
- package/client/src/nodeDefinitions/schedulerNodes.ts +220 -0
- package/client/src/nodeDefinitions/skillNodes.ts +211 -0
- package/client/src/nodeDefinitions/toolNodes.ts +198 -0
- package/client/src/nodeDefinitions/utilityNodes.ts +284 -0
- package/client/src/nodeDefinitions/whatsappNodes.ts +865 -0
- package/client/src/nodeDefinitions/workflowNodes.ts +41 -0
- package/client/src/nodeDefinitions.ts +104 -0
- package/client/src/schemas/workflowSchema.ts +264 -0
- package/client/src/services/dynamicParameterService.ts +96 -0
- package/client/src/services/execution/aiAgentExecutionService.ts +35 -0
- package/client/src/services/executionService.ts +232 -0
- package/client/src/services/workflowApi.ts +91 -0
- package/client/src/store/useAppStore.ts +582 -0
- package/client/src/styles/theme.ts +508 -0
- package/client/src/styles/zIndex.ts +17 -0
- package/client/src/types/ComponentTypes.ts +39 -0
- package/client/src/types/EdgeCondition.ts +231 -0
- package/client/src/types/INodeProperties.ts +288 -0
- package/client/src/types/NodeTypes.ts +28 -0
- package/client/src/utils/formatters.ts +33 -0
- package/client/src/utils/googleMapsLoader.ts +140 -0
- package/client/src/utils/locationUtils.ts +85 -0
- package/client/src/utils/nodeUtils.ts +31 -0
- package/client/src/utils/workflow.ts +30 -0
- package/client/src/utils/workflowExport.ts +120 -0
- package/client/src/vite-env.d.ts +12 -0
- package/client/tailwind.config.js +60 -0
- package/client/tsconfig.json +25 -0
- package/client/tsconfig.node.json +11 -0
- package/client/vite.config.js +35 -0
- package/docker-compose.prod.yml +107 -0
- package/docker-compose.yml +104 -0
- package/docs-MachinaOs/README.md +85 -0
- package/docs-MachinaOs/deployment/docker.mdx +228 -0
- package/docs-MachinaOs/deployment/production.mdx +345 -0
- package/docs-MachinaOs/docs.json +75 -0
- package/docs-MachinaOs/faq.mdx +309 -0
- package/docs-MachinaOs/favicon.svg +5 -0
- package/docs-MachinaOs/installation.mdx +160 -0
- package/docs-MachinaOs/introduction.mdx +114 -0
- package/docs-MachinaOs/logo/dark.svg +6 -0
- package/docs-MachinaOs/logo/light.svg +6 -0
- package/docs-MachinaOs/nodes/ai-agent.mdx +216 -0
- package/docs-MachinaOs/nodes/ai-models.mdx +240 -0
- package/docs-MachinaOs/nodes/android.mdx +411 -0
- package/docs-MachinaOs/nodes/overview.mdx +181 -0
- package/docs-MachinaOs/nodes/schedulers.mdx +316 -0
- package/docs-MachinaOs/nodes/webhooks.mdx +330 -0
- package/docs-MachinaOs/nodes/whatsapp.mdx +305 -0
- package/docs-MachinaOs/quickstart.mdx +119 -0
- package/docs-MachinaOs/tutorials/ai-agent-workflow.mdx +177 -0
- package/docs-MachinaOs/tutorials/android-automation.mdx +242 -0
- package/docs-MachinaOs/tutorials/first-workflow.mdx +134 -0
- package/docs-MachinaOs/tutorials/whatsapp-automation.mdx +185 -0
- package/nul +0 -0
- package/package.json +70 -0
- package/scripts/build.js +158 -0
- package/scripts/check-ports.ps1 +33 -0
- package/scripts/clean.js +40 -0
- package/scripts/docker.js +93 -0
- package/scripts/kill-port.ps1 +154 -0
- package/scripts/start.js +210 -0
- package/scripts/stop.js +325 -0
- package/server/.dockerignore +44 -0
- package/server/Dockerfile +45 -0
- package/server/constants.py +249 -0
- package/server/core/__init__.py +1 -0
- package/server/core/cache.py +461 -0
- package/server/core/config.py +128 -0
- package/server/core/container.py +99 -0
- package/server/core/database.py +1211 -0
- package/server/core/logging.py +314 -0
- package/server/main.py +289 -0
- package/server/middleware/__init__.py +5 -0
- package/server/middleware/auth.py +89 -0
- package/server/models/__init__.py +1 -0
- package/server/models/auth.py +52 -0
- package/server/models/cache.py +24 -0
- package/server/models/database.py +211 -0
- package/server/models/nodes.py +455 -0
- package/server/package.json +9 -0
- package/server/pyproject.toml +72 -0
- package/server/requirements.txt +83 -0
- package/server/routers/__init__.py +1 -0
- package/server/routers/android.py +294 -0
- package/server/routers/auth.py +203 -0
- package/server/routers/database.py +151 -0
- package/server/routers/maps.py +142 -0
- package/server/routers/nodejs_compat.py +289 -0
- package/server/routers/webhook.py +90 -0
- package/server/routers/websocket.py +2127 -0
- package/server/routers/whatsapp.py +761 -0
- package/server/routers/workflow.py +200 -0
- package/server/services/__init__.py +1 -0
- package/server/services/ai.py +2415 -0
- package/server/services/android/__init__.py +27 -0
- package/server/services/android/broadcaster.py +114 -0
- package/server/services/android/client.py +608 -0
- package/server/services/android/manager.py +78 -0
- package/server/services/android/protocol.py +165 -0
- package/server/services/android_service.py +588 -0
- package/server/services/auth.py +131 -0
- package/server/services/chat_client.py +160 -0
- package/server/services/deployment/__init__.py +12 -0
- package/server/services/deployment/manager.py +706 -0
- package/server/services/deployment/state.py +47 -0
- package/server/services/deployment/triggers.py +275 -0
- package/server/services/event_waiter.py +785 -0
- package/server/services/execution/__init__.py +77 -0
- package/server/services/execution/cache.py +769 -0
- package/server/services/execution/conditions.py +373 -0
- package/server/services/execution/dlq.py +132 -0
- package/server/services/execution/executor.py +1351 -0
- package/server/services/execution/models.py +531 -0
- package/server/services/execution/recovery.py +235 -0
- package/server/services/handlers/__init__.py +126 -0
- package/server/services/handlers/ai.py +355 -0
- package/server/services/handlers/android.py +260 -0
- package/server/services/handlers/code.py +278 -0
- package/server/services/handlers/document.py +598 -0
- package/server/services/handlers/http.py +193 -0
- package/server/services/handlers/polyglot.py +105 -0
- package/server/services/handlers/tools.py +845 -0
- package/server/services/handlers/triggers.py +107 -0
- package/server/services/handlers/utility.py +822 -0
- package/server/services/handlers/whatsapp.py +476 -0
- package/server/services/maps.py +289 -0
- package/server/services/memory_store.py +103 -0
- package/server/services/node_executor.py +375 -0
- package/server/services/parameter_resolver.py +218 -0
- package/server/services/polyglot_client.py +169 -0
- package/server/services/scheduler.py +155 -0
- package/server/services/skill_loader.py +417 -0
- package/server/services/status_broadcaster.py +826 -0
- package/server/services/temporal/__init__.py +23 -0
- package/server/services/temporal/activities.py +344 -0
- package/server/services/temporal/client.py +76 -0
- package/server/services/temporal/executor.py +147 -0
- package/server/services/temporal/worker.py +251 -0
- package/server/services/temporal/workflow.py +355 -0
- package/server/services/temporal/ws_client.py +236 -0
- package/server/services/text.py +111 -0
- package/server/services/user_auth.py +172 -0
- package/server/services/websocket_client.py +29 -0
- package/server/services/workflow.py +597 -0
- package/server/skills/android-skill/SKILL.md +82 -0
- package/server/skills/assistant-personality/SKILL.md +45 -0
- package/server/skills/code-skill/SKILL.md +140 -0
- package/server/skills/http-skill/SKILL.md +161 -0
- package/server/skills/maps-skill/SKILL.md +170 -0
- package/server/skills/memory-skill/SKILL.md +154 -0
- package/server/skills/scheduler-skill/SKILL.md +84 -0
- package/server/skills/whatsapp-skill/SKILL.md +283 -0
- package/server/uv.lock +2916 -0
- package/server/whatsapp-rpc/.dockerignore +30 -0
- package/server/whatsapp-rpc/Dockerfile +44 -0
- package/server/whatsapp-rpc/Dockerfile.web +17 -0
- package/server/whatsapp-rpc/README.md +139 -0
- package/server/whatsapp-rpc/cli.js +95 -0
- package/server/whatsapp-rpc/configs/config.yaml +7 -0
- package/server/whatsapp-rpc/docker-compose.yml +35 -0
- package/server/whatsapp-rpc/docs/API.md +410 -0
- package/server/whatsapp-rpc/go.mod +67 -0
- package/server/whatsapp-rpc/go.sum +203 -0
- package/server/whatsapp-rpc/package.json +30 -0
- package/server/whatsapp-rpc/schema.json +1294 -0
- package/server/whatsapp-rpc/scripts/clean.cjs +66 -0
- package/server/whatsapp-rpc/scripts/cli.js +162 -0
- package/server/whatsapp-rpc/src/go/cmd/server/main.go +91 -0
- package/server/whatsapp-rpc/src/go/config/config.go +49 -0
- package/server/whatsapp-rpc/src/go/rpc/rpc.go +446 -0
- package/server/whatsapp-rpc/src/go/rpc/server.go +112 -0
- package/server/whatsapp-rpc/src/go/whatsapp/history.go +166 -0
- package/server/whatsapp-rpc/src/go/whatsapp/messages.go +390 -0
- package/server/whatsapp-rpc/src/go/whatsapp/service.go +2130 -0
- package/server/whatsapp-rpc/src/go/whatsapp/types.go +261 -0
- package/server/whatsapp-rpc/src/python/pyproject.toml +15 -0
- package/server/whatsapp-rpc/src/python/whatsapp_rpc/__init__.py +4 -0
- package/server/whatsapp-rpc/src/python/whatsapp_rpc/client.py +427 -0
- package/server/whatsapp-rpc/web/app.py +609 -0
- package/server/whatsapp-rpc/web/requirements.txt +6 -0
- package/server/whatsapp-rpc/web/rpc_client.py +427 -0
- package/server/whatsapp-rpc/web/static/openapi.yaml +59 -0
- package/server/whatsapp-rpc/web/templates/base.html +150 -0
- package/server/whatsapp-rpc/web/templates/contacts.html +240 -0
- package/server/whatsapp-rpc/web/templates/dashboard.html +320 -0
- package/server/whatsapp-rpc/web/templates/groups.html +328 -0
- package/server/whatsapp-rpc/web/templates/messages.html +465 -0
- package/server/whatsapp-rpc/web/templates/messaging.html +681 -0
- package/server/whatsapp-rpc/web/templates/send.html +259 -0
- package/server/whatsapp-rpc/web/templates/settings.html +459 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
import { Input, Button, Space, Tag, Tooltip } from 'antd';
|
|
3
|
+
import { CheckCircleOutlined, CloseCircleOutlined, LoadingOutlined, DeleteOutlined } from '@ant-design/icons';
|
|
4
|
+
import { useApiKeyValidation } from '../hooks/useApiKeyValidation';
|
|
5
|
+
|
|
6
|
+
interface APIKeyValidatorProps {
|
|
7
|
+
value: string;
|
|
8
|
+
onChange: (value: string) => void;
|
|
9
|
+
placeholder?: string;
|
|
10
|
+
validationConfig: {
|
|
11
|
+
provider?: string;
|
|
12
|
+
showValidateButton?: boolean;
|
|
13
|
+
};
|
|
14
|
+
onValidationSuccess?: (models: string[]) => void;
|
|
15
|
+
isDragOver?: boolean;
|
|
16
|
+
onDragOver?: (e: React.DragEvent) => void;
|
|
17
|
+
onDragLeave?: (e: React.DragEvent) => void;
|
|
18
|
+
onDrop?: (e: React.DragEvent) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const APIKeyValidator: React.FC<APIKeyValidatorProps> = ({
|
|
22
|
+
value,
|
|
23
|
+
onChange,
|
|
24
|
+
placeholder,
|
|
25
|
+
validationConfig,
|
|
26
|
+
onValidationSuccess,
|
|
27
|
+
isDragOver = false,
|
|
28
|
+
onDragOver,
|
|
29
|
+
onDragLeave,
|
|
30
|
+
onDrop
|
|
31
|
+
}) => {
|
|
32
|
+
const { status, hasStoredKey, validate, clear, getStoredKey, isValidating, isValid } = useApiKeyValidation({
|
|
33
|
+
provider: validationConfig.provider,
|
|
34
|
+
onSuccess: onValidationSuccess
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Auto-load stored key on mount
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (hasStoredKey && !value) {
|
|
40
|
+
getStoredKey().then(storedKey => {
|
|
41
|
+
if (storedKey) onChange(storedKey);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}, [hasStoredKey, value, onChange, getStoredKey]);
|
|
45
|
+
|
|
46
|
+
const handleValidate = () => validate(value);
|
|
47
|
+
|
|
48
|
+
const handleClear = async () => {
|
|
49
|
+
await clear();
|
|
50
|
+
onChange('');
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const getStatusIcon = () => {
|
|
54
|
+
if (isValidating) return <LoadingOutlined />;
|
|
55
|
+
if (isValid) return <CheckCircleOutlined style={{ color: '#52c41a' }} />;
|
|
56
|
+
if (status === 'invalid') return <CloseCircleOutlined style={{ color: '#ff4d4f' }} />;
|
|
57
|
+
return null;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const getStatusTag = () => {
|
|
61
|
+
if (hasStoredKey && isValid) {
|
|
62
|
+
return (
|
|
63
|
+
<Tag color="success" icon={<CheckCircleOutlined />}>
|
|
64
|
+
Validated
|
|
65
|
+
</Tag>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<Space direction="vertical" style={{ width: '100%' }} size="small">
|
|
73
|
+
<Space.Compact style={{ width: '100%' }}>
|
|
74
|
+
<Input.Password
|
|
75
|
+
value={value}
|
|
76
|
+
onChange={(e) => onChange(e.target.value)}
|
|
77
|
+
placeholder={placeholder || 'Enter API key...'}
|
|
78
|
+
onDragOver={onDragOver}
|
|
79
|
+
onDragLeave={onDragLeave}
|
|
80
|
+
onDrop={onDrop}
|
|
81
|
+
suffix={getStatusIcon()}
|
|
82
|
+
status={status === 'invalid' ? 'error' : undefined}
|
|
83
|
+
style={{
|
|
84
|
+
fontFamily: 'monospace',
|
|
85
|
+
borderColor: isDragOver ? '#1890ff' : undefined,
|
|
86
|
+
backgroundColor: isDragOver ? '#e6f7ff' : undefined
|
|
87
|
+
}}
|
|
88
|
+
/>
|
|
89
|
+
|
|
90
|
+
{validationConfig.showValidateButton && (
|
|
91
|
+
<Button
|
|
92
|
+
type={isValid ? 'primary' : 'default'}
|
|
93
|
+
loading={isValidating}
|
|
94
|
+
disabled={!value?.trim() || isValidating}
|
|
95
|
+
onClick={handleValidate}
|
|
96
|
+
>
|
|
97
|
+
{isValidating ? 'Validating' : isValid ? 'Valid' : 'Validate'}
|
|
98
|
+
</Button>
|
|
99
|
+
)}
|
|
100
|
+
|
|
101
|
+
{hasStoredKey && (
|
|
102
|
+
<Tooltip title="Clear stored API key">
|
|
103
|
+
<Button
|
|
104
|
+
icon={<DeleteOutlined />}
|
|
105
|
+
onClick={handleClear}
|
|
106
|
+
type="text"
|
|
107
|
+
size="small"
|
|
108
|
+
/>
|
|
109
|
+
</Tooltip>
|
|
110
|
+
)}
|
|
111
|
+
</Space.Compact>
|
|
112
|
+
|
|
113
|
+
{getStatusTag()}
|
|
114
|
+
</Space>
|
|
115
|
+
);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export default APIKeyValidator;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NodeProps } from 'reactflow';
|
|
3
|
+
import { NodeData } from '../types/NodeTypes';
|
|
4
|
+
import BaseChatModelNode from './base/BaseChatModelNode';
|
|
5
|
+
|
|
6
|
+
const ClaudeChatModelNode: React.FC<NodeProps<NodeData>> = (props) => {
|
|
7
|
+
return (
|
|
8
|
+
<BaseChatModelNode
|
|
9
|
+
{...props}
|
|
10
|
+
providerId="anthropic"
|
|
11
|
+
displayName="Claude"
|
|
12
|
+
icon="🧠"
|
|
13
|
+
color="#FF6B35"
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default ClaudeChatModelNode;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ConditionalEdge - Custom React Flow edge with condition label display
|
|
3
|
+
*
|
|
4
|
+
* Renders edges with visual indicators for conditional branching:
|
|
5
|
+
* - Displays condition label as a badge on the edge
|
|
6
|
+
* - Different styling for conditional vs unconditional edges
|
|
7
|
+
* - Click-to-edit condition support
|
|
8
|
+
*/
|
|
9
|
+
import React, { useState, useCallback, memo } from 'react';
|
|
10
|
+
import {
|
|
11
|
+
EdgeProps,
|
|
12
|
+
getSmoothStepPath,
|
|
13
|
+
EdgeLabelRenderer,
|
|
14
|
+
BaseEdge,
|
|
15
|
+
} from 'reactflow';
|
|
16
|
+
import { useAppTheme } from '../hooks/useAppTheme';
|
|
17
|
+
import { ConditionalEdgeData, formatConditionLabel } from '../types/EdgeCondition';
|
|
18
|
+
import EdgeConditionEditor from './EdgeConditionEditor';
|
|
19
|
+
|
|
20
|
+
interface ConditionalEdgeProps extends EdgeProps<ConditionalEdgeData> {
|
|
21
|
+
/** Callback when condition is updated */
|
|
22
|
+
onConditionUpdate?: (
|
|
23
|
+
edgeId: string,
|
|
24
|
+
condition: ConditionalEdgeData['condition'],
|
|
25
|
+
label: string | undefined
|
|
26
|
+
) => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const ConditionalEdge: React.FC<ConditionalEdgeProps> = ({
|
|
30
|
+
id,
|
|
31
|
+
sourceX,
|
|
32
|
+
sourceY,
|
|
33
|
+
targetX,
|
|
34
|
+
targetY,
|
|
35
|
+
sourcePosition,
|
|
36
|
+
targetPosition,
|
|
37
|
+
style = {},
|
|
38
|
+
markerEnd,
|
|
39
|
+
data,
|
|
40
|
+
selected,
|
|
41
|
+
onConditionUpdate,
|
|
42
|
+
}) => {
|
|
43
|
+
const theme = useAppTheme();
|
|
44
|
+
const [isEditorOpen, setIsEditorOpen] = useState(false);
|
|
45
|
+
|
|
46
|
+
// Calculate edge path
|
|
47
|
+
const [edgePath, labelX, labelY] = getSmoothStepPath({
|
|
48
|
+
sourceX,
|
|
49
|
+
sourceY,
|
|
50
|
+
sourcePosition,
|
|
51
|
+
targetX,
|
|
52
|
+
targetY,
|
|
53
|
+
targetPosition,
|
|
54
|
+
borderRadius: 10,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const hasCondition = !!data?.condition;
|
|
58
|
+
const displayLabel = data?.label || (hasCondition && data?.condition ? formatConditionLabel(data.condition) : null);
|
|
59
|
+
|
|
60
|
+
const handleLabelClick = useCallback((e: React.MouseEvent) => {
|
|
61
|
+
e.stopPropagation();
|
|
62
|
+
setIsEditorOpen(true);
|
|
63
|
+
}, []);
|
|
64
|
+
|
|
65
|
+
const handleEditorClose = useCallback(() => {
|
|
66
|
+
setIsEditorOpen(false);
|
|
67
|
+
}, []);
|
|
68
|
+
|
|
69
|
+
const handleConditionSave = useCallback(
|
|
70
|
+
(condition: ConditionalEdgeData['condition'], label: string | undefined) => {
|
|
71
|
+
if (onConditionUpdate) {
|
|
72
|
+
onConditionUpdate(id, condition, label);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
[id, onConditionUpdate]
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
// Label badge style
|
|
79
|
+
const labelBadgeStyle: React.CSSProperties = {
|
|
80
|
+
position: 'absolute',
|
|
81
|
+
transform: 'translate(-50%, -50%)',
|
|
82
|
+
pointerEvents: 'all',
|
|
83
|
+
cursor: 'pointer',
|
|
84
|
+
padding: `${theme.spacing.xs} ${theme.spacing.sm}`,
|
|
85
|
+
borderRadius: theme.borderRadius.sm,
|
|
86
|
+
fontSize: theme.fontSize.xs,
|
|
87
|
+
fontWeight: theme.fontWeight.medium,
|
|
88
|
+
fontFamily: 'system-ui, sans-serif',
|
|
89
|
+
backgroundColor: hasCondition
|
|
90
|
+
? `${theme.dracula.cyan}20`
|
|
91
|
+
: theme.colors.backgroundPanel,
|
|
92
|
+
border: `1px solid ${hasCondition ? `${theme.dracula.cyan}60` : theme.colors.border}`,
|
|
93
|
+
color: hasCondition ? theme.dracula.cyan : theme.colors.textSecondary,
|
|
94
|
+
whiteSpace: 'nowrap',
|
|
95
|
+
maxWidth: '150px',
|
|
96
|
+
overflow: 'hidden',
|
|
97
|
+
textOverflow: 'ellipsis',
|
|
98
|
+
boxShadow: selected ? `0 0 6px ${theme.dracula.purple}` : 'none',
|
|
99
|
+
transition: theme.transitions.fast,
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// Add condition button (shown when no condition)
|
|
103
|
+
const addButtonStyle: React.CSSProperties = {
|
|
104
|
+
position: 'absolute',
|
|
105
|
+
transform: 'translate(-50%, -50%)',
|
|
106
|
+
pointerEvents: 'all',
|
|
107
|
+
cursor: 'pointer',
|
|
108
|
+
width: '20px',
|
|
109
|
+
height: '20px',
|
|
110
|
+
borderRadius: '50%',
|
|
111
|
+
backgroundColor: theme.colors.backgroundPanel,
|
|
112
|
+
border: `1px dashed ${theme.colors.border}`,
|
|
113
|
+
color: theme.colors.textMuted,
|
|
114
|
+
display: 'flex',
|
|
115
|
+
alignItems: 'center',
|
|
116
|
+
justifyContent: 'center',
|
|
117
|
+
fontSize: '14px',
|
|
118
|
+
opacity: selected ? 1 : 0,
|
|
119
|
+
transition: theme.transitions.fast,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<>
|
|
124
|
+
<BaseEdge
|
|
125
|
+
id={id}
|
|
126
|
+
path={edgePath}
|
|
127
|
+
markerEnd={markerEnd}
|
|
128
|
+
style={{
|
|
129
|
+
...style,
|
|
130
|
+
stroke: hasCondition ? theme.dracula.cyan : undefined,
|
|
131
|
+
strokeWidth: hasCondition ? 2 : undefined,
|
|
132
|
+
strokeDasharray: hasCondition ? '5 3' : undefined,
|
|
133
|
+
}}
|
|
134
|
+
/>
|
|
135
|
+
|
|
136
|
+
<EdgeLabelRenderer>
|
|
137
|
+
{/* Condition label or add button */}
|
|
138
|
+
{displayLabel ? (
|
|
139
|
+
<div
|
|
140
|
+
style={{
|
|
141
|
+
...labelBadgeStyle,
|
|
142
|
+
left: labelX,
|
|
143
|
+
top: labelY,
|
|
144
|
+
}}
|
|
145
|
+
onClick={handleLabelClick}
|
|
146
|
+
title={`Click to edit condition: ${displayLabel}`}
|
|
147
|
+
>
|
|
148
|
+
<span style={{ marginRight: '4px' }}>
|
|
149
|
+
<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
|
|
150
|
+
<path d="M16 3h5v5"/>
|
|
151
|
+
<path d="M8 3H3v5"/>
|
|
152
|
+
<path d="M21 3l-7 7"/>
|
|
153
|
+
<path d="M3 3l7 7"/>
|
|
154
|
+
<path d="M3 21l7-7"/>
|
|
155
|
+
<path d="M21 21l-7-7"/>
|
|
156
|
+
<path d="M16 21h5v-5"/>
|
|
157
|
+
<path d="M8 21H3v-5"/>
|
|
158
|
+
</svg>
|
|
159
|
+
</span>
|
|
160
|
+
{displayLabel}
|
|
161
|
+
</div>
|
|
162
|
+
) : (
|
|
163
|
+
<div
|
|
164
|
+
style={{
|
|
165
|
+
...addButtonStyle,
|
|
166
|
+
left: labelX,
|
|
167
|
+
top: labelY,
|
|
168
|
+
}}
|
|
169
|
+
onClick={handleLabelClick}
|
|
170
|
+
title="Click to add condition"
|
|
171
|
+
>
|
|
172
|
+
+
|
|
173
|
+
</div>
|
|
174
|
+
)}
|
|
175
|
+
</EdgeLabelRenderer>
|
|
176
|
+
|
|
177
|
+
{/* Condition Editor Modal */}
|
|
178
|
+
<EdgeConditionEditor
|
|
179
|
+
isOpen={isEditorOpen}
|
|
180
|
+
onClose={handleEditorClose}
|
|
181
|
+
condition={data?.condition}
|
|
182
|
+
label={data?.label}
|
|
183
|
+
onSave={handleConditionSave}
|
|
184
|
+
/>
|
|
185
|
+
</>
|
|
186
|
+
);
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export default memo(ConditionalEdge);
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CredentialsModal - Modern categorized credentials management panel
|
|
3
|
+
* Uses Ant Design Collapse + List for compact, modern UI
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React, { useState, useEffect, useCallback, useMemo } from 'react';
|
|
7
|
+
import { Input, Button, message, Collapse, List, Tag, Space, Tooltip } from 'antd';
|
|
8
|
+
import {
|
|
9
|
+
CheckCircleOutlined,
|
|
10
|
+
DeleteOutlined,
|
|
11
|
+
SafetyOutlined,
|
|
12
|
+
SearchOutlined,
|
|
13
|
+
EyeOutlined,
|
|
14
|
+
EyeInvisibleOutlined,
|
|
15
|
+
} from '@ant-design/icons';
|
|
16
|
+
import Modal from './ui/Modal';
|
|
17
|
+
import { useApiKeys } from '../hooks/useApiKeys';
|
|
18
|
+
import { useAppTheme } from '../hooks/useAppTheme';
|
|
19
|
+
import {
|
|
20
|
+
OpenAIIcon, ClaudeIcon, GeminiIcon, GroqIcon, OpenRouterIcon, CerebrasIcon,
|
|
21
|
+
} from './icons/AIProviderIcons';
|
|
22
|
+
|
|
23
|
+
// ============================================================================
|
|
24
|
+
// TYPES & DATA
|
|
25
|
+
// ============================================================================
|
|
26
|
+
|
|
27
|
+
interface CredentialItem {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
placeholder: string;
|
|
31
|
+
color: string;
|
|
32
|
+
desc: string;
|
|
33
|
+
Icon?: React.FC<{ size?: number }>;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface Category {
|
|
37
|
+
key: string;
|
|
38
|
+
label: string;
|
|
39
|
+
items: CredentialItem[];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const CATEGORIES: Category[] = [
|
|
43
|
+
{
|
|
44
|
+
key: 'ai',
|
|
45
|
+
label: 'AI Providers',
|
|
46
|
+
items: [
|
|
47
|
+
{ id: 'openai', name: 'OpenAI', placeholder: 'sk-...', color: '#10a37f', desc: 'GPT-4o, GPT-4, GPT-3.5', Icon: OpenAIIcon },
|
|
48
|
+
{ id: 'anthropic', name: 'Anthropic', placeholder: 'sk-ant-...', color: '#d97706', desc: 'Claude 3.5 Sonnet, Opus', Icon: ClaudeIcon },
|
|
49
|
+
{ id: 'gemini', name: 'Gemini', placeholder: 'AIza...', color: '#4285f4', desc: 'Gemini 1.5 Pro, Flash', Icon: GeminiIcon },
|
|
50
|
+
{ id: 'groq', name: 'Groq', placeholder: 'gsk_...', color: '#F55036', desc: 'Llama, Mixtral - Ultra-fast', Icon: GroqIcon },
|
|
51
|
+
{ id: 'cerebras', name: 'Cerebras', placeholder: 'csk-...', color: '#FF6600', desc: 'Llama, Qwen - Ultra-fast', Icon: CerebrasIcon },
|
|
52
|
+
{ id: 'openrouter', name: 'OpenRouter', placeholder: 'sk-or-...', color: '#6366f1', desc: 'Unified API - 100+ models', Icon: OpenRouterIcon },
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
key: 'services',
|
|
57
|
+
label: 'Services',
|
|
58
|
+
items: [
|
|
59
|
+
{ id: 'google_maps', name: 'Google Maps', placeholder: 'AIza...', color: '#34a853', desc: 'Geocoding, Places API' },
|
|
60
|
+
{ id: 'android_remote', name: 'Android Remote', placeholder: 'your-api-key...', color: '#3ddc84', desc: 'WebSocket device control' },
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
// ============================================================================
|
|
66
|
+
// MAIN COMPONENT
|
|
67
|
+
// ============================================================================
|
|
68
|
+
|
|
69
|
+
interface Props {
|
|
70
|
+
visible: boolean;
|
|
71
|
+
onClose: () => void;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const CredentialsModal: React.FC<Props> = ({ visible, onClose }) => {
|
|
75
|
+
const theme = useAppTheme();
|
|
76
|
+
const { validateApiKey, saveApiKey, getStoredApiKey, hasStoredKey, removeApiKey, validateGoogleMapsKey } = useApiKeys();
|
|
77
|
+
|
|
78
|
+
const [validKeys, setValidKeys] = useState<Record<string, boolean>>({});
|
|
79
|
+
const [loading, setLoading] = useState<Record<string, boolean>>({});
|
|
80
|
+
const [models, setModels] = useState<Record<string, string[]>>({});
|
|
81
|
+
const [keys, setKeys] = useState<Record<string, string>>({});
|
|
82
|
+
const [expanded, setExpanded] = useState<string | null>(null);
|
|
83
|
+
const [search, setSearch] = useState('');
|
|
84
|
+
const [showKey, setShowKey] = useState<Record<string, boolean>>({});
|
|
85
|
+
|
|
86
|
+
// Load stored keys
|
|
87
|
+
const loadKeys = useCallback(async () => {
|
|
88
|
+
const allItems = CATEGORIES.flatMap(c => c.items);
|
|
89
|
+
const newKeys: Record<string, string> = {};
|
|
90
|
+
const newValid: Record<string, boolean> = {};
|
|
91
|
+
|
|
92
|
+
for (const item of allItems) {
|
|
93
|
+
if (await hasStoredKey(item.id)) {
|
|
94
|
+
const key = await getStoredApiKey(item.id);
|
|
95
|
+
if (key) {
|
|
96
|
+
newKeys[item.id] = key;
|
|
97
|
+
newValid[item.id] = true;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
setKeys(newKeys);
|
|
102
|
+
setValidKeys(newValid);
|
|
103
|
+
}, [hasStoredKey, getStoredApiKey]);
|
|
104
|
+
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
if (visible) {
|
|
107
|
+
loadKeys();
|
|
108
|
+
setExpanded(null);
|
|
109
|
+
setSearch('');
|
|
110
|
+
}
|
|
111
|
+
}, [visible, loadKeys]);
|
|
112
|
+
|
|
113
|
+
const handleValidate = async (id: string) => {
|
|
114
|
+
const key = keys[id];
|
|
115
|
+
if (!key?.trim()) return message.warning('Enter an API key first');
|
|
116
|
+
|
|
117
|
+
setLoading(l => ({ ...l, [id]: true }));
|
|
118
|
+
const result = id === 'google_maps'
|
|
119
|
+
? await validateGoogleMapsKey(key)
|
|
120
|
+
: id === 'android_remote'
|
|
121
|
+
? await saveApiKey(id, key)
|
|
122
|
+
: await validateApiKey(id, key);
|
|
123
|
+
setLoading(l => ({ ...l, [id]: false }));
|
|
124
|
+
|
|
125
|
+
if (result.isValid) {
|
|
126
|
+
setValidKeys(v => ({ ...v, [id]: true }));
|
|
127
|
+
if (result.models) setModels(m => ({ ...m, [id]: result.models! }));
|
|
128
|
+
message.success('Key saved and validated');
|
|
129
|
+
} else {
|
|
130
|
+
message.error(result.error || 'Invalid key');
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const handleRemove = async (id: string) => {
|
|
135
|
+
await removeApiKey(id);
|
|
136
|
+
setKeys(k => ({ ...k, [id]: '' }));
|
|
137
|
+
setValidKeys(v => ({ ...v, [id]: false }));
|
|
138
|
+
setModels(m => ({ ...m, [id]: [] }));
|
|
139
|
+
message.success('Key removed');
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// Filter by search
|
|
143
|
+
const filteredCategories = useMemo(() => {
|
|
144
|
+
if (!search.trim()) return CATEGORIES;
|
|
145
|
+
const q = search.toLowerCase();
|
|
146
|
+
return CATEGORIES.map(cat => ({
|
|
147
|
+
...cat,
|
|
148
|
+
items: cat.items.filter(i => i.name.toLowerCase().includes(q) || i.desc.toLowerCase().includes(q)),
|
|
149
|
+
})).filter(cat => cat.items.length > 0);
|
|
150
|
+
}, [search]);
|
|
151
|
+
|
|
152
|
+
// Count configured per category
|
|
153
|
+
const getCount = (items: typeof CATEGORIES[0]['items']) =>
|
|
154
|
+
items.filter(i => validKeys[i.id]).length;
|
|
155
|
+
|
|
156
|
+
return (
|
|
157
|
+
<Modal isOpen={visible} onClose={onClose} title="API Credentials" maxWidth="95vw" maxHeight="95vh">
|
|
158
|
+
<div style={{ padding: 20 }}>
|
|
159
|
+
{/* Info banner */}
|
|
160
|
+
<div style={{
|
|
161
|
+
display: 'flex', alignItems: 'center', gap: 8, marginBottom: 16,
|
|
162
|
+
padding: 12, borderRadius: 8,
|
|
163
|
+
backgroundColor: `${theme.dracula.green}10`,
|
|
164
|
+
border: `1px solid ${theme.dracula.green}30`,
|
|
165
|
+
}}>
|
|
166
|
+
<SafetyOutlined style={{ color: theme.dracula.green }} />
|
|
167
|
+
<span style={{ fontSize: 13, color: theme.colors.textSecondary }}>
|
|
168
|
+
Keys are stored securely and used automatically by AI nodes.
|
|
169
|
+
</span>
|
|
170
|
+
</div>
|
|
171
|
+
|
|
172
|
+
{/* Search */}
|
|
173
|
+
<Input
|
|
174
|
+
placeholder="Search credentials..."
|
|
175
|
+
prefix={<SearchOutlined style={{ color: theme.colors.textMuted }} />}
|
|
176
|
+
value={search}
|
|
177
|
+
onChange={e => setSearch(e.target.value)}
|
|
178
|
+
allowClear
|
|
179
|
+
style={{ marginBottom: 16 }}
|
|
180
|
+
/>
|
|
181
|
+
|
|
182
|
+
{/* Categories */}
|
|
183
|
+
<Collapse
|
|
184
|
+
defaultActiveKey={['ai', 'services']}
|
|
185
|
+
ghost
|
|
186
|
+
style={{ background: 'transparent' }}
|
|
187
|
+
items={filteredCategories.map(cat => ({
|
|
188
|
+
key: cat.key,
|
|
189
|
+
label: (
|
|
190
|
+
<Space>
|
|
191
|
+
<span style={{ fontWeight: 600, textTransform: 'uppercase', fontSize: 11, letterSpacing: '0.05em' }}>
|
|
192
|
+
{cat.label}
|
|
193
|
+
</span>
|
|
194
|
+
<Tag color={getCount(cat.items) === cat.items.length ? 'success' : 'default'}>
|
|
195
|
+
{getCount(cat.items)}/{cat.items.length}
|
|
196
|
+
</Tag>
|
|
197
|
+
</Space>
|
|
198
|
+
),
|
|
199
|
+
children: (
|
|
200
|
+
<List
|
|
201
|
+
dataSource={cat.items}
|
|
202
|
+
renderItem={item => {
|
|
203
|
+
const isExpanded = expanded === item.id;
|
|
204
|
+
const isValid = validKeys[item.id];
|
|
205
|
+
const Icon = item.Icon;
|
|
206
|
+
|
|
207
|
+
return (
|
|
208
|
+
<List.Item
|
|
209
|
+
style={{
|
|
210
|
+
cursor: 'pointer',
|
|
211
|
+
padding: '12px 8px',
|
|
212
|
+
borderRadius: 8,
|
|
213
|
+
marginBottom: 4,
|
|
214
|
+
backgroundColor: isExpanded ? theme.colors.backgroundAlt : 'transparent',
|
|
215
|
+
flexDirection: 'column',
|
|
216
|
+
alignItems: 'stretch',
|
|
217
|
+
}}
|
|
218
|
+
onClick={() => setExpanded(isExpanded ? null : item.id)}
|
|
219
|
+
>
|
|
220
|
+
{/* Row header */}
|
|
221
|
+
<div style={{ display: 'flex', alignItems: 'center', width: '100%' }}>
|
|
222
|
+
<div style={{
|
|
223
|
+
width: 32, height: 32, borderRadius: 6, marginRight: 12,
|
|
224
|
+
backgroundColor: `${item.color}15`,
|
|
225
|
+
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
226
|
+
}}>
|
|
227
|
+
{Icon ? <Icon size={18} /> : <span>{item.id === 'google_maps' ? '📍' : '📱'}</span>}
|
|
228
|
+
</div>
|
|
229
|
+
<div style={{ flex: 1 }}>
|
|
230
|
+
<div style={{ fontWeight: 500, fontSize: 14 }}>{item.name}</div>
|
|
231
|
+
<div style={{ fontSize: 12, color: theme.colors.textMuted }}>{item.desc}</div>
|
|
232
|
+
</div>
|
|
233
|
+
{isValid && (
|
|
234
|
+
<Tag icon={<CheckCircleOutlined />} color="success">Valid</Tag>
|
|
235
|
+
)}
|
|
236
|
+
</div>
|
|
237
|
+
|
|
238
|
+
{/* Expanded content */}
|
|
239
|
+
{isExpanded && (
|
|
240
|
+
<div style={{ marginTop: 12, paddingTop: 12, borderTop: `1px solid ${theme.colors.border}` }}
|
|
241
|
+
onClick={e => e.stopPropagation()}
|
|
242
|
+
>
|
|
243
|
+
<Space.Compact style={{ width: '100%', marginBottom: 8 }}>
|
|
244
|
+
<Input
|
|
245
|
+
type={showKey[item.id] ? 'text' : 'password'}
|
|
246
|
+
value={keys[item.id] || ''}
|
|
247
|
+
onChange={e => {
|
|
248
|
+
setKeys(k => ({ ...k, [item.id]: e.target.value }));
|
|
249
|
+
setValidKeys(v => ({ ...v, [item.id]: false }));
|
|
250
|
+
}}
|
|
251
|
+
placeholder={item.placeholder}
|
|
252
|
+
style={{ fontFamily: 'monospace', fontSize: 13 }}
|
|
253
|
+
suffix={
|
|
254
|
+
<Tooltip title={showKey[item.id] ? 'Hide' : 'Show'}>
|
|
255
|
+
<span
|
|
256
|
+
onClick={() => setShowKey(s => ({ ...s, [item.id]: !s[item.id] }))}
|
|
257
|
+
style={{ cursor: 'pointer', color: theme.colors.textMuted }}
|
|
258
|
+
>
|
|
259
|
+
{showKey[item.id] ? <EyeInvisibleOutlined /> : <EyeOutlined />}
|
|
260
|
+
</span>
|
|
261
|
+
</Tooltip>
|
|
262
|
+
}
|
|
263
|
+
/>
|
|
264
|
+
<Button
|
|
265
|
+
loading={loading[item.id]}
|
|
266
|
+
onClick={() => handleValidate(item.id)}
|
|
267
|
+
type={isValid ? 'primary' : 'default'}
|
|
268
|
+
style={isValid ? { backgroundColor: theme.dracula.green, borderColor: theme.dracula.green } : {}}
|
|
269
|
+
>
|
|
270
|
+
{isValid ? 'Valid' : 'Validate'}
|
|
271
|
+
</Button>
|
|
272
|
+
</Space.Compact>
|
|
273
|
+
|
|
274
|
+
{models[item.id]?.length > 0 && (
|
|
275
|
+
<div style={{ fontSize: 12, color: theme.colors.textMuted, marginBottom: 8 }}>
|
|
276
|
+
Models: {models[item.id].slice(0, 4).join(', ')}{models[item.id].length > 4 && ` +${models[item.id].length - 4}`}
|
|
277
|
+
</div>
|
|
278
|
+
)}
|
|
279
|
+
|
|
280
|
+
{isValid && (
|
|
281
|
+
<Button size="small" danger icon={<DeleteOutlined />} onClick={() => handleRemove(item.id)}>
|
|
282
|
+
Remove
|
|
283
|
+
</Button>
|
|
284
|
+
)}
|
|
285
|
+
</div>
|
|
286
|
+
)}
|
|
287
|
+
</List.Item>
|
|
288
|
+
);
|
|
289
|
+
}}
|
|
290
|
+
/>
|
|
291
|
+
),
|
|
292
|
+
}))}
|
|
293
|
+
/>
|
|
294
|
+
|
|
295
|
+
{/* Footer */}
|
|
296
|
+
<div style={{ marginTop: 20, textAlign: 'right' }}>
|
|
297
|
+
<Button type="primary" onClick={onClose} style={{ backgroundColor: theme.dracula.green, borderColor: theme.dracula.green }}>
|
|
298
|
+
Done
|
|
299
|
+
</Button>
|
|
300
|
+
</div>
|
|
301
|
+
</div>
|
|
302
|
+
</Modal>
|
|
303
|
+
);
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
export default CredentialsModal;
|