@@ -192,6 +192,10 @@ class NeoDash extends React.Component {
192192 // If a JSON string is available, try to parse it and set the state.
193193 try {
194194 let loaded = JSON . parse ( this . state . json )
195+ // Quietly auto-upgrade to Neodash 1.1...
196+ if ( this . version === "1.1" && loaded . version === "1.0" ) {
197+ this . upgradeDashboardJson ( loaded ) ;
198+ }
195199 if ( loaded . version && loaded . version !== this . version ) {
196200 this . stateChanged ( {
197201 label : "CreateError" ,
@@ -214,6 +218,16 @@ class NeoDash extends React.Component {
214218 }
215219 }
216220
221+ upgradeDashboardJson ( loaded ) {
222+ loaded . version = "1.1" ;
223+ loaded . pages = [
224+ {
225+ title : "Page 1" ,
226+ reports : loaded . reports
227+ }
228+ ]
229+ }
230+
217231 setPageStateFromLoadedJson ( loaded ) {
218232 this . state . pageTitles = loaded . pages . map ( ( page ) => {
219233 return page . title
@@ -301,7 +315,6 @@ class NeoDash extends React.Component {
301315 * @param update - a JSON dictionary {update, label} describing the change that was made.
302316 */
303317 stateChanged ( update ) {
304- console . log ( update )
305318 if ( update . label === "ConnectURLChanged" ) {
306319 this . connection . url = update . value ;
307320 }
@@ -348,22 +361,24 @@ class NeoDash extends React.Component {
348361 this . state . count += 1 ;
349362 }
350363 if ( update . label === "PageChanged" ) {
351- if ( update . value . tagName !== "INPUT" ) {
352- // We should always click an Input element when switching pages
353- return
364+ let tabClicked = null ;
365+ if ( update . value . tagName === "INPUT" ) {
366+ tabClicked = update . value . parentNode . parentNode . parentNode ;
367+
368+ } else if ( update . value . className === "input-field" ) {
369+ tabClicked = update . value . parentNode . parentNode ;
370+ }
371+ if ( tabClicked == null ) {
372+ return ;
354373 }
355- console . log ( update . value )
356- console . log ( update . value . parentNode )
357- console . log ( update . value . parentNode . parentNode )
358- console . log ( update . value . parentNode . parentNode . parentNode )
359- let tabClicked = update . value . parentNode . parentNode . parentNode ;
360374 let index = Array . from ( tabClicked . parentNode . children ) . indexOf ( tabClicked ) ;
361375 if ( this . state . pagenumber === index ) {
362376 return ;
363377 }
364378 this . state . pagenumber = index ;
365379 let loaded = JSON . parse ( this . state . json )
366380 this . generateDashboardCardComponents ( loaded ) ;
381+
367382 }
368383 if ( update . label === "PageTitleChanged" ) {
369384 let tabClicked = update . value . parentNode . parentNode . parentNode ;
0 commit comments