@@ -565,12 +565,12 @@ class JupyterStateStore {
565565 )
566566 */
567567 const coded = this . dictCompress . codeState ( key , mime , state , old . fullstate )
568- console . log (
568+ /* console.log(
569569 'coded state test',
570570 JSON.stringify(state).length,
571571 coded.byteLength
572572 )
573- console . log ( 'fullstate' , old . fullstate )
573+ console.log('fullstate', old.fullstate) */
574574 /*
575575 console.log(
576576 'coded state diff',
@@ -636,6 +636,7 @@ export class JupyterHublet extends Component {
636636 this . state = { }
637637 this . state . movemodeactiv = { }
638638 this . state . kernelStatus = 'unknown'
639+ this . state . appLocked = true
639640 this . appletwidth = 100
640641 this . appletheight = 100
641642 this . jState = new JupyterStateStore ( )
@@ -676,6 +677,16 @@ export class JupyterHublet extends Component {
676677 ) {
677678 this . installStateReceiver ( )
678679 }
680+
681+ if ( ! this . props . isnotepad ) {
682+ if (
683+ prevState . appLocked !== this . state . appLocked &&
684+ this . state . appLocked
685+ ) {
686+ // We are locked again, so go back to locked state!
687+ this . sendCompleteStateUpdate ( )
688+ }
689+ }
679690 }
680691
681692 installStateReceiver ( ) {
@@ -778,17 +789,18 @@ export class JupyterHublet extends Component {
778789 }
779790
780791 receiveStateUpdate ( buffer ) {
781- if ( ! this . props . master ) {
782- // master gets no updates
783- const stateUpdate = this . jState . receiveData ( buffer )
784- console . log ( 'receiveStateUpdate result' , stateUpdate )
785- const { path, mime, state } = stateUpdate
786- this . jupyteredit . current ?. sendInterceptorUpdate ?. ( {
787- path,
788- mime,
789- state
790- } )
791- }
792+ if ( this . props . master ) return
793+ // master gets no updates
794+ const stateUpdate = this . jState . receiveData ( buffer )
795+ console . log ( 'receiveStateUpdate result' , stateUpdate )
796+ // do not update jupyter edit, while student is allowed to alter the state
797+ if ( ! this . props . isnotepad && ! this . state . appLocked ) return
798+ const { path, mime, state } = stateUpdate
799+ this . jupyteredit . current ?. sendInterceptorUpdate ?. ( {
800+ path,
801+ mime,
802+ state
803+ } )
792804 }
793805
794806 processInitialStateUpdates ( ) {
@@ -802,6 +814,10 @@ export class JupyterHublet extends Component {
802814 }
803815 // ok, we got all updates
804816 // we know iterate over all fullstate models and send them out
817+ this . sendCompleteStateUpdate ( )
818+ }
819+
820+ sendCompleteStateUpdate ( ) {
805821 this . jState . getAllStateData ( ) . forEach ( ( { path, mime, state } ) => {
806822 this . jupyteredit . current ?. sendInterceptorUpdate ?. ( {
807823 path,
@@ -1093,12 +1109,17 @@ export class JupyterHublet extends Component {
10931109 ) }
10941110 </ div >
10951111 < div style = { { position : 'absolute' , right : '0px' , bottom : '0px' } } >
1096- < AppletButton
1097- // eslint-disable-next-line no-constant-condition
1098- icon = { true ? 'pi pi-lock-open' : 'pi pi-lock' }
1099- key = 'lockbutton'
1100- tooltip = 'Unlock/Lock to instructors applet state'
1101- />
1112+ { ! this . props . isnotepad && (
1113+ < AppletButton
1114+ // eslint-disable-next-line no-constant-condition
1115+ icon = { ! this . state . appLocked ? 'pi pi-lock-open' : 'pi pi-lock' }
1116+ key = 'lockbutton'
1117+ tooltip = 'Unlock/Lock to instructors applet state'
1118+ onClick = { ( ) => {
1119+ this . setState ( ( state ) => ( { appLocked : ! state . appLocked } ) )
1120+ } }
1121+ />
1122+ ) }
11021123 { ! master && this . props . makeAppletMaster && (
11031124 < AppletButton
11041125 icon = { < FontAwesomeIcon icon = { faTachometerAlt } /> }
@@ -1203,7 +1224,12 @@ export class JupyterHublet extends Component {
12031224 >
12041225 < JupyterEdit
12051226 editActivated = { this . state . jupyteredit }
1206- pointerOff = { ! this . props . master }
1227+ pointerOff = {
1228+ ! (
1229+ ( this . props . master && this . props . isnotepad ) ||
1230+ ( ! this . state . appLocked && ! this . props . isnotepad )
1231+ )
1232+ }
12071233 rerunAtStartup = { true }
12081234 installScreenShotPatches = {
12091235 ! ! this . props
0 commit comments