File tree Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Original file line number Diff line number Diff 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 ( ! / ^ ( i n p u t s | t r a n s f o r m ) $ / . 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 ( ! / ^ ( i n p u t s | t r a n s f o r m ) $ / . 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 [ ] )
You can’t perform that action at this time.
0 commit comments