Skip to content

Commit 7f533c5

Browse files
authored
feat: pushing more links (#3779)
1 parent a9bcf5f commit 7f533c5

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

src/flows/components/Sidebar.tsx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,64 @@ const Sidebar: FC = () => {
240240
title: 'Export to Client Library',
241241
menu: <ClientList />,
242242
},
243+
{
244+
title: 'Link to Source',
245+
disable: () => {
246+
if (!flow.data.allIDs.includes(id)) {
247+
return true
248+
}
249+
250+
const {type} = flow.data.byID[id]
251+
252+
if (!/^(inputs|transform)$/.test(PIPE_DEFINITIONS[type]?.family)) {
253+
return true
254+
}
255+
256+
return false
257+
},
258+
action: () => {
259+
const {type} = flow.data.byID[id]
260+
event('notebook source link', {notebooksCellType: type})
261+
const url = new URL(
262+
`${window.location.origin}/api/v2private/notebooks/${flow.id}/query/${id}`
263+
).toString()
264+
try {
265+
navigator.clipboard.writeText(url)
266+
dispatch(notify(panelCopyLinkSuccess()))
267+
} catch {
268+
dispatch(notify(panelCopyLinkFail()))
269+
}
270+
},
271+
},
272+
{
273+
title: 'Link to Results',
274+
disable: () => {
275+
if (!flow.data.allIDs.includes(id)) {
276+
return true
277+
}
278+
279+
const {type} = flow.data.byID[id]
280+
281+
if (!/^(inputs|transform)$/.test(PIPE_DEFINITIONS[type]?.family)) {
282+
return true
283+
}
284+
285+
return false
286+
},
287+
action: () => {
288+
const {type} = flow.data.byID[id]
289+
event('notebook result link', {notebooksCellType: type})
290+
const url = new URL(
291+
`${window.location.origin}/api/v2private/notebooks/${flow.id}/run/${id}`
292+
).toString()
293+
try {
294+
navigator.clipboard.writeText(url)
295+
dispatch(notify(panelCopyLinkSuccess()))
296+
} catch {
297+
dispatch(notify(panelCopyLinkFail()))
298+
}
299+
},
300+
},
243301
],
244302
},
245303
] as ControlSection[])

0 commit comments

Comments
 (0)