@@ -131,6 +131,7 @@ const Sidebar: FC = () => {
131131 const { getPanelQueries} = useContext ( FlowQueryContext )
132132 const { id, hide, menu, showSub} = useContext ( SidebarContext )
133133 const dispatch = useDispatch ( )
134+ const { source, visual} = getPanelQueries ( id )
134135
135136 const sections = ( [
136137 {
@@ -145,24 +146,6 @@ const Sidebar: FC = () => {
145146 remove ( id )
146147 } ,
147148 } ,
148- {
149- title : 'Share' ,
150- action : ( ) => {
151- const { type} = flow . data . byID [ id ]
152- event ( 'notebook_share_panel' , { notebooksCellType : type } )
153- const url = new URL (
154- `${ window . location . origin } ${ window . location . pathname } ?panel=${ id } `
155- ) . toString ( )
156- try {
157- navigator . clipboard . writeText ( url )
158- event ( 'panel_share_success' , { notebooksCellType : type } )
159- dispatch ( notify ( panelCopyLinkSuccess ( ) ) )
160- } catch {
161- event ( 'panel_share_failure' , { notebooksCellType : type } )
162- dispatch ( notify ( panelCopyLinkFail ( ) ) )
163- }
164- } ,
165- } ,
166149 {
167150 title : 'Duplicate' ,
168151 action : ( ) => {
@@ -179,13 +162,13 @@ const Sidebar: FC = () => {
179162 {
180163 title : ( ) => {
181164 if ( ! flow . meta . allIDs . includes ( id ) ) {
182- return 'Hide panel '
165+ return 'Hide Panel '
183166 }
184167
185168 if ( flow . meta . byID [ id ] . visible ) {
186- return 'Hide panel '
169+ return 'Hide Panel '
187170 }
188- return 'Show panel '
171+ return 'Show Panel '
189172 } ,
190173 action : ( ) => {
191174 event ( 'Panel Visibility Toggled' , {
@@ -199,6 +182,9 @@ const Sidebar: FC = () => {
199182 } ,
200183 {
201184 title : 'Convert to |> Flux' ,
185+ disable : ( ) => {
186+ return ! source
187+ } ,
202188 hidden : ( ) => {
203189 if ( ! flow . data . allIDs . includes ( id ) ) {
204190 return true
@@ -222,8 +208,6 @@ const Sidebar: FC = () => {
222208
223209 event ( 'Convert Cell To Flux' , { from : type } )
224210
225- const { source, visual} = getPanelQueries ( id )
226-
227211 const init = JSON . parse (
228212 JSON . stringify ( PIPE_DEFINITIONS [ 'rawFluxEditor' ] . initial )
229213 )
@@ -239,6 +223,9 @@ const Sidebar: FC = () => {
239223 {
240224 title : 'Export to Client Library' ,
241225 menu : < ClientList /> ,
226+ disable : ( ) => {
227+ return ! source
228+ } ,
242229 hidden : ( ) => {
243230 if ( ! flow . data . allIDs . includes ( id ) ) {
244231 return true
@@ -253,8 +240,29 @@ const Sidebar: FC = () => {
253240 return false
254241 } ,
255242 } ,
243+ {
244+ title : 'Link to Panel' ,
245+ action : ( ) => {
246+ const { type} = flow . data . byID [ id ]
247+ event ( 'notebook_share_panel' , { notebooksCellType : type } )
248+ const url = new URL (
249+ `${ window . location . origin } ${ window . location . pathname } ?panel=${ id } `
250+ ) . toString ( )
251+ try {
252+ navigator . clipboard . writeText ( url )
253+ event ( 'panel_share_success' , { notebooksCellType : type } )
254+ dispatch ( notify ( panelCopyLinkSuccess ( ) ) )
255+ } catch {
256+ event ( 'panel_share_failure' , { notebooksCellType : type } )
257+ dispatch ( notify ( panelCopyLinkFail ( ) ) )
258+ }
259+ } ,
260+ } ,
256261 {
257262 title : 'Link to Source' ,
263+ disable : ( ) => {
264+ return ! source
265+ } ,
258266 hidden : ( ) => {
259267 if ( ! flow . data . allIDs . includes ( id ) ) {
260268 return true
@@ -283,6 +291,9 @@ const Sidebar: FC = () => {
283291 } ,
284292 {
285293 title : 'Link to Results' ,
294+ disable : ( ) => {
295+ return ! source
296+ } ,
286297 hidden : ( ) => {
287298 if ( ! flow . data . allIDs . includes ( id ) ) {
288299 return true
0 commit comments