Skip to content

Commit 304a740

Browse files
authored
Merge pull request #302 from code0-tech/feat/fixing-definition-showing
Fixing copy to clipboard and endpoint definition visibility
2 parents f776b80 + 2e10d1b commit 304a740

5 files changed

Lines changed: 40 additions & 12 deletions

File tree

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"dependencies": {
1717
"@apollo/client": "^4.0.9",
1818
"@code0-tech/pictor": "^0.11.1",
19-
"@code0-tech/triangulum": "^0.26.1",
19+
"@code0-tech/triangulum": "^0.26.2",
2020
"@codemirror/lang-javascript": "^6.2.5",
2121
"@codemirror/lint": "^6.9.5",
2222
"@icons-pack/react-simple-icons": "^13.13.0",

src/packages/ce/src/flow/components/panels/FlowPanelDefinitionComponent.tsx

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ export const FlowPanelDefinitionComponent: React.FC = () => {
6868
)
6969

7070
const module = React.useMemo(
71-
() => moduleService.getById(flowType?.runtimeModule?.id, {
71+
() => moduleService.getById(flowType?.runtimeFlowType?.runtimeModule?.id, {
7272
namespaceId: namespaceId,
7373
projectId: projectId,
7474
runtimeId: project?.primaryRuntime?.id
7575
}),
76-
[flowType?.runtimeModule?.id, namespaceId, projectId, project?.primaryRuntime?.id, moduleStore]
76+
[flowType?.runtimeFlowType?.runtimeModule?.id, namespaceId, projectId, project?.primaryRuntime?.id, moduleStore]
7777
)
7878

7979
let endpoint = `http://${module?.definitions?.nodes?.[0]?.host}:${module?.definitions?.nodes?.[0]?.port}${module?.definitions?.nodes?.[0]?.endpoint}`
@@ -83,6 +83,27 @@ export const FlowPanelDefinitionComponent: React.FC = () => {
8383
endpoint = endpoint.replace(`\${{${setting?.flowSettingIdentifier}}}`, setting?.value)
8484
})
8585

86+
const copyEndpoint = (event: React.MouseEvent<HTMLElement>) => {
87+
if (!navigator?.clipboard?.writeText) {
88+
// Without a secure context there is no Clipboard API and the hook falls back to a
89+
// textarea on document.body, which the modal dialog's focus trap keeps unfocusable,
90+
// so Firefox copies nothing. Run the same fallback inside the dialog instead; the
91+
// copyToClipboard call below still records the copied state.
92+
const dialog = event.currentTarget.closest("[role='dialog']")
93+
if (dialog) {
94+
const textArea = document.createElement("textarea")
95+
textArea.value = endpoint
96+
textArea.style.position = "fixed"
97+
textArea.style.opacity = "0"
98+
dialog.appendChild(textArea)
99+
textArea.select()
100+
document.execCommand("copy")
101+
dialog.removeChild(textArea)
102+
}
103+
}
104+
copyToClipboard(endpoint)
105+
}
106+
86107
return module?.definitions?.nodes?.[0] &&
87108
<Panel position={"bottom-right"} data-qa-selector={"flow-builder-definition-panel"}>
88109
<ButtonGroup style={{textWrap: "nowrap"}}>
@@ -110,9 +131,8 @@ export const FlowPanelDefinitionComponent: React.FC = () => {
110131
) : undefined}
111132
right={
112133
<ButtonGroup color={"primary"}>
113-
<Button onClick={() => {
114-
copyToClipboard(endpoint)
115-
}} paddingSize={"xxs"} variant={"none"} color={"secondary"}>
134+
<Button onClick={copyEndpoint}
135+
paddingSize={"xxs"} variant={"none"} color={"secondary"}>
116136
{hasCopiedText ? <IconCheck size={13}/> :
117137
<IconCopy size={13}/>}
118138
</Button>

src/packages/ce/src/flowtype/services/fragments/FlowType.fragment.graphql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ fragment FlowType on FlowType {
3131
__typename
3232
id
3333
}
34+
runtimeFlowType {
35+
__typename
36+
id
37+
runtimeModule {
38+
__typename
39+
id
40+
}
41+
}
3442
signature
3543
flowTypeSettings (first: $firstFlowTypeSetting, after: $afterFlowTypeSetting) {
3644
__typename

src/packages/ce/src/project/views/ProjectsView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ export const ProjectsView: React.FC = () => {
5555
</div>
5656
<ButtonGroup>
5757
<Link href={`/namespace/${namespaceId}/projects/create`}>
58-
<Button paddingSize={"xxs"} color={"success"}>Create</Button>
58+
<Button color={"success"}>Create</Button>
5959
</Link>
6060
<Menu>
6161
<MenuTrigger asChild>
62-
<Button paddingSize={"xxs"} color={"secondary"} variant={"filled"}>Sort</Button>
62+
<Button color={"secondary"} variant={"filled"}>Sort</Button>
6363
</MenuTrigger>
6464
<MenuPortal>
6565
<MenuContent>

0 commit comments

Comments
 (0)