@tldiagram/core-ui 1.87.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/App.d.ts +1 -0
- package/dist/api/client.d.ts +143 -0
- package/dist/api/transport-vscode.d.ts +8 -0
- package/dist/api/transport.d.ts +1 -0
- package/dist/components/CodePreviewPanel-vscode.d.ts +7 -0
- package/dist/components/CodePreviewPanel.d.ts +9 -0
- package/dist/components/ConfirmDialog.d.ts +12 -0
- package/dist/components/ConnectorPanel.d.ts +21 -0
- package/dist/components/ContextBoundaryElement.d.ts +11 -0
- package/dist/components/ContextNeighborElement.d.ts +29 -0
- package/dist/components/ContextStraightConnector.d.ts +4 -0
- package/dist/components/CrossBranchControls.d.ts +9 -0
- package/dist/components/DependenciesOnboarding.d.ts +5 -0
- package/dist/components/DrawingCanvas.d.ts +39 -0
- package/dist/components/ElementLibrary-vscode.d.ts +7 -0
- package/dist/components/ElementLibrary.d.ts +22 -0
- package/dist/components/ElementNode.d.ts +36 -0
- package/dist/components/ElementPanel.d.ts +25 -0
- package/dist/components/ExploreOnboarding.d.ts +5 -0
- package/dist/components/ExplorePageOnboarding.d.ts +5 -0
- package/dist/components/ExportModal.d.ts +16 -0
- package/dist/components/FloatingEdge.d.ts +9 -0
- package/dist/components/GitSourceLinker.d.ts +8 -0
- package/dist/components/HeaderContext.d.ts +16 -0
- package/dist/components/Icons.d.ts +95 -0
- package/dist/components/ImportModal.d.ts +10 -0
- package/dist/components/InlineElementAdder.d.ts +17 -0
- package/dist/components/LayoutSection.d.ts +7 -0
- package/dist/components/LocalSourceLinker.d.ts +8 -0
- package/dist/components/MiniZoomOnboarding.d.ts +5 -0
- package/dist/components/NavBreadcrumb.d.ts +6 -0
- package/dist/components/NodeBody.d.ts +12 -0
- package/dist/components/NodeContainer.d.ts +8 -0
- package/dist/components/NodeHoverCard.d.ts +10 -0
- package/dist/components/PanelHeader.d.ts +8 -0
- package/dist/components/PanelUI.d.ts +3 -0
- package/dist/components/ProxyConnectorEdge.d.ts +4 -0
- package/dist/components/ProxyConnectorPanel.d.ts +9 -0
- package/dist/components/SafeBackground.d.ts +13 -0
- package/dist/components/ScrollIndicatorWrapper.d.ts +8 -0
- package/dist/components/SetChildModal.d.ts +10 -0
- package/dist/components/SetParentModal.d.ts +10 -0
- package/dist/components/SlidingPanel.d.ts +16 -0
- package/dist/components/TagUpsert.d.ts +8 -0
- package/dist/components/TopMenuBar.d.ts +8 -0
- package/dist/components/ViewBezierConnector.d.ts +4 -0
- package/dist/components/ViewDrawMenu.d.ts +22 -0
- package/dist/components/ViewEditorEdgeLabelLayout.d.ts +16 -0
- package/dist/components/ViewEditorOnboarding.d.ts +5 -0
- package/dist/components/ViewExplorer/TagManager/ColorPicker.d.ts +7 -0
- package/dist/components/ViewExplorer/TagManager/GroupNamingPopover.d.ts +10 -0
- package/dist/components/ViewExplorer/TagManager/LayerItem.d.ts +27 -0
- package/dist/components/ViewExplorer/TagManager/TagItem.d.ts +25 -0
- package/dist/components/ViewExplorer/TagManager/index.d.ts +21 -0
- package/dist/components/ViewExplorer/ViewNavigator.d.ts +11 -0
- package/dist/components/ViewExplorer/ViewSearch.d.ts +8 -0
- package/dist/components/ViewExplorer/ViewTree.d.ts +18 -0
- package/dist/components/ViewExplorer/index.d.ts +31 -0
- package/dist/components/ViewExplorer/types.d.ts +11 -0
- package/dist/components/ViewExplorer/utils.d.ts +6 -0
- package/dist/components/ViewExplorer-vscode.d.ts +6 -0
- package/dist/components/ViewFloatingMenu-vscode.d.ts +27 -0
- package/dist/components/ViewFloatingMenu.d.ts +39 -0
- package/dist/components/ViewGridNode.d.ts +29 -0
- package/dist/components/ViewHeaderButton.d.ts +11 -0
- package/dist/components/ViewPanel.d.ts +18 -0
- package/dist/components/ViewsGridOnboarding.d.ts +5 -0
- package/dist/components/ZUI/ZUICanvas.d.ts +18 -0
- package/dist/components/ZUI/index.d.ts +2 -0
- package/dist/components/ZUI/layout.d.ts +18 -0
- package/dist/components/ZUI/proxy.d.ts +25 -0
- package/dist/components/ZUI/renderer.d.ts +30 -0
- package/dist/components/ZUI/types.d.ts +140 -0
- package/dist/components/ZUI/useZUIInteraction.d.ts +21 -0
- package/dist/config/runtime-vscode.d.ts +22 -0
- package/dist/config/runtime.d.ts +5 -0
- package/dist/constants/colors.d.ts +27 -0
- package/dist/constants/diagramColors.d.ts +1 -0
- package/dist/context/ThemeContext.d.ts +27 -0
- package/dist/crossBranch/graph.d.ts +13 -0
- package/dist/crossBranch/resolve.d.ts +22 -0
- package/dist/crossBranch/settings.d.ts +6 -0
- package/dist/crossBranch/store.d.ts +11 -0
- package/dist/crossBranch/types.d.ts +96 -0
- package/dist/demo/DemoPage.d.ts +9 -0
- package/dist/demo/seed.d.ts +9 -0
- package/dist/demo/store.d.ts +137 -0
- package/dist/demo/viewEditor.d.ts +26 -0
- package/dist/favicon.svg +35 -0
- package/dist/hooks/useSafeFitView.d.ts +16 -0
- package/dist/index.css +1 -0
- package/dist/index.d.ts +115 -0
- package/dist/index.js +19966 -0
- package/dist/lib/vscodeBridge-vscode.d.ts +13 -0
- package/dist/lib/vscodeBridge.d.ts +5 -0
- package/dist/logo-120.png +0 -0
- package/dist/logo-bw.png +0 -0
- package/dist/logo-bw.svg +15 -0
- package/dist/logo-text.svg +51 -0
- package/dist/logo.svg +35 -0
- package/dist/pages/AppearanceSettings.d.ts +3 -0
- package/dist/pages/Dependencies.d.ts +1 -0
- package/dist/pages/InfiniteZoom.d.ts +7 -0
- package/dist/pages/Settings.d.ts +7 -0
- package/dist/pages/ViewEditor/components/EditorMenus.d.ts +24 -0
- package/dist/pages/ViewEditor/components/EditorOverlays.d.ts +30 -0
- package/dist/pages/ViewEditor/components/EmptyCanvasState.d.ts +7 -0
- package/dist/pages/ViewEditor/context.d.ts +13 -0
- package/dist/pages/ViewEditor/hooks/useCanvasInteractions.d.ts +201 -0
- package/dist/pages/ViewEditor/hooks/useDrawingEngine.d.ts +40 -0
- package/dist/pages/ViewEditor/hooks/useViewContextNeighbours.d.ts +20 -0
- package/dist/pages/ViewEditor/hooks/useViewData.d.ts +74 -0
- package/dist/pages/ViewEditor/index.d.ts +8 -0
- package/dist/pages/ViewEditor/utils.d.ts +14 -0
- package/dist/pages/Views.d.ts +6 -0
- package/dist/pages/ViewsGrid.d.ts +6 -0
- package/dist/pkg/importer/mermaid.d.ts +7 -0
- package/dist/pkg/importer/mermaid.test.d.ts +1 -0
- package/dist/platform/PlatformContext.d.ts +6 -0
- package/dist/platform/context.d.ts +3 -0
- package/dist/platform/local.d.ts +2 -0
- package/dist/platform/types.d.ts +17 -0
- package/dist/slots.d.ts +67 -0
- package/dist/theme.d.ts +2 -0
- package/dist/types/index.d.ts +193 -0
- package/dist/types/vscode-messages.d.ts +60 -0
- package/dist/utils/edgeDistribution.d.ts +34 -0
- package/dist/utils/githubApi.d.ts +4 -0
- package/dist/utils/githubCache.d.ts +17 -0
- package/dist/utils/ids.d.ts +2 -0
- package/dist/utils/technologyCatalog.d.ts +15 -0
- package/dist/utils/toast.d.ts +15 -0
- package/dist/utils/treesitter.d.ts +13 -0
- package/dist/utils/url.d.ts +12 -0
- package/package.json +159 -0
- package/src/App.tsx +141 -0
- package/src/api/client.ts +618 -0
- package/src/api/transport-vscode.ts +28 -0
- package/src/api/transport.ts +7 -0
- package/src/assets/logo-mark.svg +31 -0
- package/src/assets/logo-wordmark.svg +22 -0
- package/src/assets/logo.svg +35 -0
- package/src/components/CodePreviewPanel-vscode.tsx +85 -0
- package/src/components/CodePreviewPanel.tsx +384 -0
- package/src/components/ConfirmDialog.tsx +66 -0
- package/src/components/ConnectorPanel.tsx +403 -0
- package/src/components/ContextBoundaryElement.tsx +35 -0
- package/src/components/ContextNeighborElement.tsx +282 -0
- package/src/components/ContextStraightConnector.tsx +144 -0
- package/src/components/CrossBranchControls.tsx +105 -0
- package/src/components/DependenciesOnboarding.tsx +427 -0
- package/src/components/DrawingCanvas.tsx +391 -0
- package/src/components/ElementLibrary-vscode.tsx +9 -0
- package/src/components/ElementLibrary.tsx +512 -0
- package/src/components/ElementNode.tsx +1033 -0
- package/src/components/ElementPanel.tsx +928 -0
- package/src/components/ExploreOnboarding.tsx +347 -0
- package/src/components/ExplorePageOnboarding.tsx +383 -0
- package/src/components/ExportModal.tsx +132 -0
- package/src/components/FloatingEdge.tsx +115 -0
- package/src/components/GitSourceLinker.tsx +1053 -0
- package/src/components/HeaderContext.tsx +30 -0
- package/src/components/Icons.tsx +245 -0
- package/src/components/ImportModal.tsx +219 -0
- package/src/components/InlineElementAdder.tsx +216 -0
- package/src/components/LayoutSection.tsx +624 -0
- package/src/components/LocalSourceLinker.tsx +330 -0
- package/src/components/MiniZoomOnboarding.tsx +78 -0
- package/src/components/NavBreadcrumb.tsx +24 -0
- package/src/components/NodeBody.tsx +89 -0
- package/src/components/NodeContainer.tsx +58 -0
- package/src/components/NodeHoverCard.tsx +135 -0
- package/src/components/PanelHeader.tsx +36 -0
- package/src/components/PanelUI.tsx +24 -0
- package/src/components/ProxyConnectorEdge.tsx +169 -0
- package/src/components/ProxyConnectorPanel.tsx +130 -0
- package/src/components/SafeBackground.tsx +19 -0
- package/src/components/ScrollIndicatorWrapper.tsx +117 -0
- package/src/components/SetChildModal.tsx +191 -0
- package/src/components/SetParentModal.tsx +187 -0
- package/src/components/SlidingPanel.tsx +114 -0
- package/src/components/TagUpsert.tsx +142 -0
- package/src/components/TopMenuBar.tsx +380 -0
- package/src/components/ViewBezierConnector.tsx +143 -0
- package/src/components/ViewDrawMenu.tsx +270 -0
- package/src/components/ViewEditorEdgeLabelLayout.ts +189 -0
- package/src/components/ViewEditorOnboarding.tsx +445 -0
- package/src/components/ViewExplorer/TagManager/ColorPicker.tsx +49 -0
- package/src/components/ViewExplorer/TagManager/GroupNamingPopover.tsx +96 -0
- package/src/components/ViewExplorer/TagManager/LayerItem.tsx +228 -0
- package/src/components/ViewExplorer/TagManager/TagItem.tsx +242 -0
- package/src/components/ViewExplorer/TagManager/index.tsx +418 -0
- package/src/components/ViewExplorer/ViewNavigator.tsx +121 -0
- package/src/components/ViewExplorer/ViewSearch.tsx +33 -0
- package/src/components/ViewExplorer/ViewTree.tsx +98 -0
- package/src/components/ViewExplorer/index.tsx +384 -0
- package/src/components/ViewExplorer/types.ts +13 -0
- package/src/components/ViewExplorer/utils.ts +56 -0
- package/src/components/ViewExplorer-vscode.tsx +8 -0
- package/src/components/ViewFloatingMenu-vscode.tsx +248 -0
- package/src/components/ViewFloatingMenu.tsx +379 -0
- package/src/components/ViewGridNode.tsx +451 -0
- package/src/components/ViewHeaderButton.tsx +60 -0
- package/src/components/ViewPanel.tsx +162 -0
- package/src/components/ViewsGridOnboarding.tsx +400 -0
- package/src/components/ZUI/ZUICanvas.tsx +853 -0
- package/src/components/ZUI/index.ts +3 -0
- package/src/components/ZUI/layout.ts +323 -0
- package/src/components/ZUI/proxy.ts +278 -0
- package/src/components/ZUI/renderer.ts +1189 -0
- package/src/components/ZUI/types.ts +150 -0
- package/src/components/ZUI/useZUIInteraction.ts +720 -0
- package/src/config/runtime-vscode.ts +46 -0
- package/src/config/runtime.ts +30 -0
- package/src/constants/colors.ts +80 -0
- package/src/constants/diagramColors.ts +9 -0
- package/src/context/ThemeContext.tsx +158 -0
- package/src/crossBranch/graph.ts +207 -0
- package/src/crossBranch/resolve.ts +643 -0
- package/src/crossBranch/settings.ts +59 -0
- package/src/crossBranch/store.ts +71 -0
- package/src/crossBranch/types.ts +102 -0
- package/src/demo/DemoPage.tsx +184 -0
- package/src/demo/seed.ts +67 -0
- package/src/demo/store.ts +536 -0
- package/src/demo/viewEditor.ts +110 -0
- package/src/hooks/useSafeFitView.ts +60 -0
- package/src/index.css +309 -0
- package/src/index.ts +184 -0
- package/src/kafka-ss.png +0 -0
- package/src/lib/vscodeBridge-vscode.ts +27 -0
- package/src/lib/vscodeBridge.ts +7 -0
- package/src/main.tsx +46 -0
- package/src/pages/AppearanceSettings.tsx +135 -0
- package/src/pages/Dependencies.tsx +926 -0
- package/src/pages/InfiniteZoom.tsx +404 -0
- package/src/pages/Settings.tsx +91 -0
- package/src/pages/ViewEditor/EDGE_DISTRIBUTION.md +64 -0
- package/src/pages/ViewEditor/components/EditorMenus.tsx +112 -0
- package/src/pages/ViewEditor/components/EditorOverlays.tsx +172 -0
- package/src/pages/ViewEditor/components/EmptyCanvasState.tsx +42 -0
- package/src/pages/ViewEditor/context.tsx +21 -0
- package/src/pages/ViewEditor/hooks/useCanvasInteractions.ts +1349 -0
- package/src/pages/ViewEditor/hooks/useDrawingEngine.ts +127 -0
- package/src/pages/ViewEditor/hooks/useViewContextNeighbours.ts +501 -0
- package/src/pages/ViewEditor/hooks/useViewData.ts +491 -0
- package/src/pages/ViewEditor/index.tsx +1366 -0
- package/src/pages/ViewEditor/utils.ts +88 -0
- package/src/pages/Views.tsx +171 -0
- package/src/pages/ViewsGrid.tsx +1310 -0
- package/src/pkg/importer/mermaid.test.ts +141 -0
- package/src/pkg/importer/mermaid.ts +76 -0
- package/src/platform/PlatformContext.tsx +17 -0
- package/src/platform/context.ts +9 -0
- package/src/platform/local.tsx +15 -0
- package/src/platform/types.ts +19 -0
- package/src/slots.ts +92 -0
- package/src/styles/editor-panels.css +66 -0
- package/src/styles/theme.css +56 -0
- package/src/theme.ts +336 -0
- package/src/types/index.ts +234 -0
- package/src/types/offline-ambient.d.ts +14 -0
- package/src/types/vscode-messages.ts +32 -0
- package/src/utils/edgeDistribution.ts +103 -0
- package/src/utils/githubApi.ts +121 -0
- package/src/utils/githubCache.ts +108 -0
- package/src/utils/ids.ts +9 -0
- package/src/utils/technologyCatalog.ts +143 -0
- package/src/utils/toast.ts +100 -0
- package/src/utils/treesitter.ts +147 -0
- package/src/utils/url.ts +72 -0
- package/src/vite-env.d.ts +1 -0
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
import { memo, useEffect, useRef, useState, useCallback } from 'react'
|
|
2
|
+
import type { ConnectorPanelSlots } from '../slots'
|
|
3
|
+
import {
|
|
4
|
+
Box,
|
|
5
|
+
Button,
|
|
6
|
+
Divider,
|
|
7
|
+
FormControl,
|
|
8
|
+
FormLabel,
|
|
9
|
+
HStack,
|
|
10
|
+
SimpleGrid,
|
|
11
|
+
Input,
|
|
12
|
+
Textarea,
|
|
13
|
+
useBreakpointValue,
|
|
14
|
+
useDisclosure,
|
|
15
|
+
VStack,
|
|
16
|
+
} from '@chakra-ui/react'
|
|
17
|
+
import { api } from '../api/client'
|
|
18
|
+
import type { Connector } from '../types'
|
|
19
|
+
import ConfirmDialog from './ConfirmDialog'
|
|
20
|
+
import SlidingPanel from './SlidingPanel'
|
|
21
|
+
import PanelHeader from './PanelHeader'
|
|
22
|
+
|
|
23
|
+
import { useViewEditorContext } from '../pages/ViewEditor/context'
|
|
24
|
+
|
|
25
|
+
const IconRadioBox = ({
|
|
26
|
+
isSelected,
|
|
27
|
+
onClick,
|
|
28
|
+
isDisabled,
|
|
29
|
+
children,
|
|
30
|
+
title,
|
|
31
|
+
}: {
|
|
32
|
+
isSelected: boolean
|
|
33
|
+
onClick: () => void
|
|
34
|
+
isDisabled?: boolean
|
|
35
|
+
children: React.ReactNode
|
|
36
|
+
title?: string
|
|
37
|
+
}) => (
|
|
38
|
+
<Box
|
|
39
|
+
as="button"
|
|
40
|
+
type="button"
|
|
41
|
+
onClick={onClick}
|
|
42
|
+
disabled={isDisabled}
|
|
43
|
+
title={title}
|
|
44
|
+
w="full"
|
|
45
|
+
h="36px"
|
|
46
|
+
display="flex"
|
|
47
|
+
alignItems="center"
|
|
48
|
+
justifyContent="center"
|
|
49
|
+
bg={isSelected ? 'whiteAlpha.200' : 'whiteAlpha.50'}
|
|
50
|
+
borderWidth="1px"
|
|
51
|
+
borderColor={isSelected ? 'whiteAlpha.400' : 'whiteAlpha.100'}
|
|
52
|
+
borderRadius="md"
|
|
53
|
+
color={isSelected ? 'white' : 'whiteAlpha.600'}
|
|
54
|
+
opacity={isDisabled ? 0.5 : 1}
|
|
55
|
+
cursor={isDisabled ? 'not-allowed' : 'pointer'}
|
|
56
|
+
_hover={!isDisabled ? { bg: 'whiteAlpha.300', borderColor: 'whiteAlpha.300', color: 'white' } : undefined}
|
|
57
|
+
transition="all 0.2s"
|
|
58
|
+
>
|
|
59
|
+
{children}
|
|
60
|
+
</Box>
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
export interface ConnectorPanelProps extends ConnectorPanelSlots {
|
|
64
|
+
isOpen: boolean
|
|
65
|
+
onClose: () => void
|
|
66
|
+
connector: Connector | null
|
|
67
|
+
orgId: string
|
|
68
|
+
onSave: (connector: Connector) => void
|
|
69
|
+
autoSave?: boolean
|
|
70
|
+
onDelete: (edgeId: number) => void
|
|
71
|
+
hasBackdrop?: boolean
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Name: Edit Connector Panel
|
|
76
|
+
* Role: Opens when clicked on a connector and displays its fields, allowing for editing. Same as Edit Element Panel but for connectors.
|
|
77
|
+
* Location: Right side of the screen on desktop. Overlays screen on mobile.
|
|
78
|
+
* Aliases: Connector Properties, Connector Details.
|
|
79
|
+
*/
|
|
80
|
+
function ConnectorPanel({ isOpen, onClose, connector, orgId, onSave, autoSave = false, onDelete, hasBackdrop = true, connectorPanelAfterContentSlot }: ConnectorPanelProps) {
|
|
81
|
+
const { canEdit, viewId } = useViewEditorContext()
|
|
82
|
+
const isReadOnly = !canEdit
|
|
83
|
+
const autoSaveEdit = autoSave && !!connector && !isReadOnly
|
|
84
|
+
const isMobile = useBreakpointValue({ base: true, md: false }) ?? false
|
|
85
|
+
const [label, setLabel] = useState('')
|
|
86
|
+
const [description, setDescription] = useState('')
|
|
87
|
+
const [relType, setRelType] = useState('')
|
|
88
|
+
const [direction, setDirection] = useState('forward')
|
|
89
|
+
const [connectorType, setConnectorType] = useState('bezier')
|
|
90
|
+
const [url, setUrl] = useState('')
|
|
91
|
+
const [loading, setLoading] = useState(false)
|
|
92
|
+
const confirmDelete = useDisclosure()
|
|
93
|
+
|
|
94
|
+
const lastSavedFingerprintRef = useRef<string>('')
|
|
95
|
+
const savingRef = useRef(false)
|
|
96
|
+
const pendingSaveRef = useRef(false)
|
|
97
|
+
|
|
98
|
+
useEffect(() => {
|
|
99
|
+
if (connector) {
|
|
100
|
+
setLabel(connector.label ?? '')
|
|
101
|
+
setDescription(connector.description ?? '')
|
|
102
|
+
setRelType(connector.relationship ?? '')
|
|
103
|
+
const dir = connector.direction === 'bidirectional' ? 'both' : (connector.direction ?? 'forward')
|
|
104
|
+
setDirection(dir)
|
|
105
|
+
const type = connector.style === 'default' ? 'bezier' : (connector.style ?? 'bezier')
|
|
106
|
+
setConnectorType(type)
|
|
107
|
+
setUrl(connector.url ?? '')
|
|
108
|
+
|
|
109
|
+
lastSavedFingerprintRef.current = JSON.stringify({
|
|
110
|
+
label: connector.label ?? '',
|
|
111
|
+
description: connector.description ?? '',
|
|
112
|
+
relationship: connector.relationship ?? '',
|
|
113
|
+
direction: dir,
|
|
114
|
+
style: type,
|
|
115
|
+
url: connector.url ?? '',
|
|
116
|
+
})
|
|
117
|
+
} else {
|
|
118
|
+
lastSavedFingerprintRef.current = ''
|
|
119
|
+
}
|
|
120
|
+
}, [connector, isOpen])
|
|
121
|
+
|
|
122
|
+
const buildPayloadAndFingerprint = useCallback(async () => {
|
|
123
|
+
const payload = {
|
|
124
|
+
label,
|
|
125
|
+
description,
|
|
126
|
+
relationship: relType,
|
|
127
|
+
direction,
|
|
128
|
+
style: connectorType,
|
|
129
|
+
url,
|
|
130
|
+
}
|
|
131
|
+
return { payload, fingerprint: JSON.stringify(payload) }
|
|
132
|
+
}, [label, description, relType, direction, connectorType, url])
|
|
133
|
+
|
|
134
|
+
const saveIfDirty = useCallback(async () => {
|
|
135
|
+
if (!autoSaveEdit || !connector) return
|
|
136
|
+
|
|
137
|
+
if (savingRef.current || viewId == null) return
|
|
138
|
+
|
|
139
|
+
const { payload, fingerprint } = await buildPayloadAndFingerprint()
|
|
140
|
+
if (fingerprint === lastSavedFingerprintRef.current) return
|
|
141
|
+
|
|
142
|
+
savingRef.current = true
|
|
143
|
+
try {
|
|
144
|
+
const updated = await api.workspace.connectors.update(viewId, connector.id, {
|
|
145
|
+
label: payload.label,
|
|
146
|
+
description: payload.description,
|
|
147
|
+
relationship: payload.relationship,
|
|
148
|
+
direction: payload.direction,
|
|
149
|
+
style: payload.style,
|
|
150
|
+
url: payload.url,
|
|
151
|
+
})
|
|
152
|
+
lastSavedFingerprintRef.current = fingerprint
|
|
153
|
+
onSave(updated)
|
|
154
|
+
} catch {
|
|
155
|
+
// ignore
|
|
156
|
+
} finally {
|
|
157
|
+
savingRef.current = false
|
|
158
|
+
if (pendingSaveRef.current) {
|
|
159
|
+
pendingSaveRef.current = false
|
|
160
|
+
void saveIfDirty()
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}, [autoSaveEdit, connector, viewId, buildPayloadAndFingerprint, onSave])
|
|
164
|
+
|
|
165
|
+
const saveIfDirtyRef = useRef<(() => Promise<void>) | null>(null)
|
|
166
|
+
useEffect(() => { saveIfDirtyRef.current = saveIfDirty }, [saveIfDirty])
|
|
167
|
+
|
|
168
|
+
const scheduleAutoSave = () => {
|
|
169
|
+
if (!autoSaveEdit) return
|
|
170
|
+
requestAnimationFrame(() => {
|
|
171
|
+
void saveIfDirtyRef.current?.()
|
|
172
|
+
})
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const handleClose = useCallback(() => {
|
|
176
|
+
if (autoSaveEdit) {
|
|
177
|
+
void saveIfDirtyRef.current?.()
|
|
178
|
+
}
|
|
179
|
+
onClose()
|
|
180
|
+
}, [autoSaveEdit, onClose])
|
|
181
|
+
|
|
182
|
+
useEffect(() => {
|
|
183
|
+
if (!isOpen) return
|
|
184
|
+
const handler = (e: KeyboardEvent) => {
|
|
185
|
+
if (e.key === 'Escape') handleClose()
|
|
186
|
+
}
|
|
187
|
+
window.addEventListener('keydown', handler)
|
|
188
|
+
return () => window.removeEventListener('keydown', handler)
|
|
189
|
+
}, [isOpen, handleClose])
|
|
190
|
+
|
|
191
|
+
const handleSave = async () => {
|
|
192
|
+
if (isReadOnly || !connector || viewId == null) return
|
|
193
|
+
setLoading(true)
|
|
194
|
+
try {
|
|
195
|
+
const { payload } = await buildPayloadAndFingerprint()
|
|
196
|
+
const updated = await api.workspace.connectors.update(viewId, connector.id, {
|
|
197
|
+
label: payload.label,
|
|
198
|
+
description: payload.description,
|
|
199
|
+
relationship: payload.relationship,
|
|
200
|
+
direction: payload.direction,
|
|
201
|
+
style: payload.style,
|
|
202
|
+
url: payload.url,
|
|
203
|
+
})
|
|
204
|
+
onSave(updated)
|
|
205
|
+
onClose()
|
|
206
|
+
} catch {
|
|
207
|
+
// intentionally empty
|
|
208
|
+
} finally {
|
|
209
|
+
setLoading(false)
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const handleDelete = async () => {
|
|
214
|
+
if (isReadOnly || !connector) return
|
|
215
|
+
try {
|
|
216
|
+
await api.workspace.connectors.delete(orgId, connector.id)
|
|
217
|
+
onDelete(connector.id)
|
|
218
|
+
confirmDelete.onClose()
|
|
219
|
+
onClose()
|
|
220
|
+
} catch {
|
|
221
|
+
// intentionally empty
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return (
|
|
226
|
+
<>
|
|
227
|
+
<SlidingPanel isOpen={isOpen} onClose={handleClose} panelKey="connector" side={isMobile ? 'left' : 'right'} width="300px" hasBackdrop={hasBackdrop}>
|
|
228
|
+
<PanelHeader title="Edit Connector" onClose={handleClose} />
|
|
229
|
+
|
|
230
|
+
{/* Body */}
|
|
231
|
+
<Box px={4} py={4} overflowY="auto" flex={1}>
|
|
232
|
+
<VStack spacing={4} align="stretch">
|
|
233
|
+
<FormControl isDisabled={isReadOnly} id="connector-label">
|
|
234
|
+
<FormLabel>Label / Name</FormLabel>
|
|
235
|
+
<Input
|
|
236
|
+
name="label"
|
|
237
|
+
size="sm"
|
|
238
|
+
value={label}
|
|
239
|
+
onChange={(e) => setLabel(e.target.value)}
|
|
240
|
+
onBlur={scheduleAutoSave}
|
|
241
|
+
placeholder="uses, calls, sends to…"
|
|
242
|
+
/>
|
|
243
|
+
</FormControl>
|
|
244
|
+
<FormControl isDisabled={isReadOnly} id="connector-direction">
|
|
245
|
+
<FormLabel>Direction</FormLabel>
|
|
246
|
+
<SimpleGrid columns={2} spacing={2}>
|
|
247
|
+
<IconRadioBox
|
|
248
|
+
isSelected={direction === 'forward'}
|
|
249
|
+
onClick={() => { setDirection('forward'); scheduleAutoSave() }}
|
|
250
|
+
isDisabled={isReadOnly}
|
|
251
|
+
title="Forward"
|
|
252
|
+
>
|
|
253
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M5 12h14m-7-7 7 7-7 7"/></svg>
|
|
254
|
+
</IconRadioBox>
|
|
255
|
+
<IconRadioBox
|
|
256
|
+
isSelected={direction === 'backward'}
|
|
257
|
+
onClick={() => { setDirection('backward'); scheduleAutoSave() }}
|
|
258
|
+
isDisabled={isReadOnly}
|
|
259
|
+
title="Backward"
|
|
260
|
+
>
|
|
261
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M19 12H5m7 7-7-7 7-7"/></svg>
|
|
262
|
+
</IconRadioBox>
|
|
263
|
+
<IconRadioBox
|
|
264
|
+
isSelected={direction === 'both'}
|
|
265
|
+
onClick={() => { setDirection('both'); scheduleAutoSave() }}
|
|
266
|
+
isDisabled={isReadOnly}
|
|
267
|
+
title="Bidirectional"
|
|
268
|
+
>
|
|
269
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M8 8l-4 4 4 4M16 8l4 4-4 4M4 12h16"/></svg>
|
|
270
|
+
</IconRadioBox>
|
|
271
|
+
<IconRadioBox
|
|
272
|
+
isSelected={direction === 'none'}
|
|
273
|
+
onClick={() => { setDirection('none'); scheduleAutoSave() }}
|
|
274
|
+
isDisabled={isReadOnly}
|
|
275
|
+
title="None"
|
|
276
|
+
>
|
|
277
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M5 12h14"/></svg>
|
|
278
|
+
</IconRadioBox>
|
|
279
|
+
</SimpleGrid>
|
|
280
|
+
</FormControl>
|
|
281
|
+
<FormControl isDisabled={isReadOnly} id="connector-style">
|
|
282
|
+
<FormLabel>Connector Style</FormLabel>
|
|
283
|
+
<SimpleGrid columns={2} spacing={2}>
|
|
284
|
+
<IconRadioBox
|
|
285
|
+
isSelected={connectorType === 'smoothstep'}
|
|
286
|
+
onClick={() => { setConnectorType('smoothstep'); scheduleAutoSave() }}
|
|
287
|
+
isDisabled={isReadOnly}
|
|
288
|
+
title="Smooth Step"
|
|
289
|
+
>
|
|
290
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M5 19H9C10.6569 19 12 17.6569 12 16V8C12 6.34315 13.3431 5 15 5H19" /></svg>
|
|
291
|
+
</IconRadioBox>
|
|
292
|
+
<IconRadioBox
|
|
293
|
+
isSelected={connectorType === 'bezier'}
|
|
294
|
+
onClick={() => { setConnectorType('bezier'); scheduleAutoSave() }}
|
|
295
|
+
isDisabled={isReadOnly}
|
|
296
|
+
title="Bezier"
|
|
297
|
+
>
|
|
298
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M5 19C5 11 19 13 19 5" /></svg>
|
|
299
|
+
</IconRadioBox>
|
|
300
|
+
<IconRadioBox
|
|
301
|
+
isSelected={connectorType === 'straight'}
|
|
302
|
+
onClick={() => { setConnectorType('straight'); scheduleAutoSave() }}
|
|
303
|
+
isDisabled={isReadOnly}
|
|
304
|
+
title="Straight"
|
|
305
|
+
>
|
|
306
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M5 19L19 5" /></svg>
|
|
307
|
+
</IconRadioBox>
|
|
308
|
+
<IconRadioBox
|
|
309
|
+
isSelected={connectorType === 'step'}
|
|
310
|
+
onClick={() => { setConnectorType('step'); scheduleAutoSave() }}
|
|
311
|
+
isDisabled={isReadOnly}
|
|
312
|
+
title="Step"
|
|
313
|
+
>
|
|
314
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M5 19H12V5H19" /></svg>
|
|
315
|
+
</IconRadioBox>
|
|
316
|
+
</SimpleGrid>
|
|
317
|
+
</FormControl>
|
|
318
|
+
<FormControl isDisabled={isReadOnly} id="connector-rel-type">
|
|
319
|
+
<FormLabel>Relationship Type</FormLabel>
|
|
320
|
+
<Input
|
|
321
|
+
name="relationship"
|
|
322
|
+
size="sm"
|
|
323
|
+
value={relType}
|
|
324
|
+
onChange={(e) => setRelType(e.target.value)}
|
|
325
|
+
onBlur={scheduleAutoSave}
|
|
326
|
+
placeholder="HTTP, gRPC, async…"
|
|
327
|
+
/>
|
|
328
|
+
</FormControl>
|
|
329
|
+
<FormControl isDisabled={isReadOnly} id="connector-url">
|
|
330
|
+
<FormLabel>URL</FormLabel>
|
|
331
|
+
<Input
|
|
332
|
+
name="url"
|
|
333
|
+
size="sm"
|
|
334
|
+
value={url}
|
|
335
|
+
onChange={(e) => setUrl(e.target.value)}
|
|
336
|
+
onBlur={scheduleAutoSave}
|
|
337
|
+
placeholder="https://docs.example.com/…"
|
|
338
|
+
/>
|
|
339
|
+
</FormControl>
|
|
340
|
+
<FormControl isDisabled={isReadOnly} id="connector-description">
|
|
341
|
+
<FormLabel>Description</FormLabel>
|
|
342
|
+
<Textarea
|
|
343
|
+
name="description"
|
|
344
|
+
size="sm"
|
|
345
|
+
value={description}
|
|
346
|
+
onChange={(e) => setDescription(e.target.value)}
|
|
347
|
+
onBlur={scheduleAutoSave}
|
|
348
|
+
placeholder="Describe the relationship…"
|
|
349
|
+
rows={4}
|
|
350
|
+
/>
|
|
351
|
+
</FormControl>
|
|
352
|
+
|
|
353
|
+
{connectorPanelAfterContentSlot}
|
|
354
|
+
|
|
355
|
+
</VStack>
|
|
356
|
+
</Box>
|
|
357
|
+
|
|
358
|
+
<Divider borderColor="whiteAlpha.100" />
|
|
359
|
+
|
|
360
|
+
{/* Footer */}
|
|
361
|
+
<HStack px={4} py={3} justify="space-between" flexShrink={0}>
|
|
362
|
+
{canEdit ? (
|
|
363
|
+
<Button variant="ghost" size="sm" color="red.400" _hover={{ bg: 'red.900', color: 'red.100' }} onClick={confirmDelete.onOpen}>
|
|
364
|
+
Delete
|
|
365
|
+
</Button>
|
|
366
|
+
) : (
|
|
367
|
+
<Box />
|
|
368
|
+
)}
|
|
369
|
+
<HStack>
|
|
370
|
+
{!autoSaveEdit && (
|
|
371
|
+
<>
|
|
372
|
+
<Button variant="ghost" size="sm" onClick={handleClose}>
|
|
373
|
+
Cancel
|
|
374
|
+
</Button>
|
|
375
|
+
{canEdit && (
|
|
376
|
+
<Button size="sm" px={5} colorScheme="blue" onClick={handleSave} isLoading={loading}>
|
|
377
|
+
Save
|
|
378
|
+
</Button>
|
|
379
|
+
)}
|
|
380
|
+
</>
|
|
381
|
+
)}
|
|
382
|
+
{autoSaveEdit && (
|
|
383
|
+
<Button variant="ghost" size="sm" onClick={handleClose}>
|
|
384
|
+
Close
|
|
385
|
+
</Button>
|
|
386
|
+
)}
|
|
387
|
+
</HStack>
|
|
388
|
+
</HStack>
|
|
389
|
+
</SlidingPanel>
|
|
390
|
+
|
|
391
|
+
<ConfirmDialog
|
|
392
|
+
isOpen={confirmDelete.isOpen}
|
|
393
|
+
onClose={confirmDelete.onClose}
|
|
394
|
+
onConfirm={handleDelete}
|
|
395
|
+
title="Delete Connector"
|
|
396
|
+
body="Delete this connector? This action cannot be undone."
|
|
397
|
+
confirmLabel="Delete"
|
|
398
|
+
/>
|
|
399
|
+
</>
|
|
400
|
+
)
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
export default memo(ConnectorPanel)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { memo } from 'react'
|
|
2
|
+
import { Handle, Position } from 'reactflow'
|
|
3
|
+
import { Box } from '@chakra-ui/react'
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
data: {
|
|
7
|
+
width: number
|
|
8
|
+
height: number
|
|
9
|
+
parentName: string
|
|
10
|
+
onNavigateToDiagram: () => void
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function ContextBoundaryElement({ data }: Props) {
|
|
15
|
+
return (
|
|
16
|
+
<Box
|
|
17
|
+
w={`${data.width}px`}
|
|
18
|
+
h={`${data.height}px`}
|
|
19
|
+
border="2px dashed rgba(255, 255, 255, 0.15)"
|
|
20
|
+
rounded="3xl"
|
|
21
|
+
position="relative"
|
|
22
|
+
pointerEvents="none"
|
|
23
|
+
bg="rgba(0, 0, 0, 0.05)"
|
|
24
|
+
>
|
|
25
|
+
<Handle type="source" position={Position.Top} id="top" style={{ opacity: 0, pointerEvents: 'none' }} isConnectable={false} />
|
|
26
|
+
<Handle type="source" position={Position.Bottom} id="bottom" style={{ opacity: 0, pointerEvents: 'none' }} isConnectable={false} />
|
|
27
|
+
<Handle type="source" position={Position.Left} id="left" style={{ opacity: 0, pointerEvents: 'none' }} isConnectable={false} />
|
|
28
|
+
<Handle type="source" position={Position.Right} id="right" style={{ opacity: 0, pointerEvents: 'none' }} isConnectable={false} />
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
</Box>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default memo(ContextBoundaryElement)
|