@@ -61,13 +61,15 @@ class CodapiSnippet extends HTMLElement {
6161 // init initializes the component state.
6262 init ( ) {
6363 const filesStr = this . getAttribute ( "files" ) ;
64- this . executor = new Executor ( {
65- engine : this . getAttribute ( "engine" ) ,
66- sandbox : this . getAttribute ( "sandbox" ) ,
67- command : this . getAttribute ( "command" ) ,
68- template : this . getAttribute ( "template" ) ,
69- files : filesStr ? filesStr . split ( " " ) : null ,
70- } ) ;
64+ this . executor = this . hasAttribute ( "sandbox" )
65+ ? new Executor ( {
66+ engine : this . getAttribute ( "engine" ) ,
67+ sandbox : this . getAttribute ( "sandbox" ) ,
68+ command : this . getAttribute ( "command" ) ,
69+ template : this . getAttribute ( "template" ) ,
70+ files : filesStr ? filesStr . split ( " " ) : null ,
71+ } )
72+ : null ;
7173 this . dependsOn = this . getAttribute ( "depends-on" ) ;
7274 this . state = State . unknown ;
7375 }
@@ -80,6 +82,7 @@ class CodapiSnippet extends HTMLElement {
8082
8183 this . _toolbar = this . querySelector ( "codapi-toolbar" ) ;
8284 const actions = this . getAttribute ( "actions" ) ;
85+ this . _toolbar . runnable = this . executor != null ;
8386 this . _toolbar . addActions ( actions ? actions . split ( " " ) : null ) ;
8487
8588 const status = this . _toolbar . querySelector ( "codapi-status" ) ;
@@ -197,6 +200,9 @@ class CodapiSnippet extends HTMLElement {
197200
198201 // execute runs the code.
199202 async execute ( command = undefined ) {
203+ if ( ! this . executor ) {
204+ return ;
205+ }
200206 if ( this . snippet . isEmpty ) {
201207 this . _output . showMessage ( "(empty)" ) ;
202208 return ;
0 commit comments