Notebook localstorage issue (#3545)

* Unable to edit Notebooks (Firefox) #3534
Unable to take a snapshot - snapshot dropdown not working #3533

* Navigating to a Notebook snapshot not working #3538

Co-authored-by: Shefali Joshi <simplyrender@gmail.com>
This commit is contained in:
Nikhil 2020-11-24 14:21:36 -08:00 committed by GitHub
parent 87751e882c
commit d1656f8561
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 2 deletions

View File

@ -118,7 +118,7 @@ export default {
painterroInstance.show(this.embed.snapshot.src); painterroInstance.show(this.embed.snapshot.src);
}, },
changeLocation() { changeLocation() {
const link = this.embed.historicLink; const hash = this.embed.historicLink;
const bounds = this.openmct.time.bounds(); const bounds = this.openmct.time.bounds();
const isTimeBoundChanged = this.embed.bounds.start !== bounds.start const isTimeBoundChanged = this.embed.bounds.start !== bounds.start
@ -143,6 +143,7 @@ export default {
this.openmct.notifications.alert(message); this.openmct.notifications.alert(message);
} }
const link = `${location.host}${location.pathname}${hash}`;
const url = new URL(link); const url = new URL(link);
window.location.href = url.hash; window.location.href = url.hash;
}, },

View File

@ -17,7 +17,7 @@
<script> <script>
import Snapshot from '../snapshot'; import Snapshot from '../snapshot';
import { getDefaultNotebook } from '../utils/notebook-storage'; import { getDefaultNotebook, validateNotebookStorageObject } from '../utils/notebook-storage';
import { NOTEBOOK_DEFAULT, NOTEBOOK_SNAPSHOT } from '../notebook-constants'; import { NOTEBOOK_DEFAULT, NOTEBOOK_SNAPSHOT } from '../notebook-constants';
export default { export default {
@ -49,6 +49,8 @@ export default {
}; };
}, },
mounted() { mounted() {
validateNotebookStorageObject();
this.notebookSnapshot = new Snapshot(this.openmct); this.notebookSnapshot = new Snapshot(this.openmct);
this.setDefaultNotebookStatus(); this.setDefaultNotebookStatus();
}, },

View File

@ -67,3 +67,24 @@ export function setDefaultNotebookPage(page) {
notebookStorage.page = page; notebookStorage.page = page;
saveDefaultNotebook(notebookStorage); saveDefaultNotebook(notebookStorage);
} }
export function validateNotebookStorageObject() {
const notebookStorage = getDefaultNotebook();
let valid = false;
if (notebookStorage) {
Object.entries(notebookStorage).forEach(([key, value]) => {
const validKey = key !== undefined && key !== null;
const validValue = value !== undefined && value !== null;
valid = validKey && validValue;
});
}
if (valid) {
return notebookStorage;
}
console.warn('Invalid Notebook object, clearing default notebook storage');
clearDefaultNotebook();
}