Snapshot images should use the namespace of the notebook they are being saved to or LocalStorage (#4020)
* Snapshot images should use the namespace of the notebook they are being saved to, or LocalStorage #4007 Co-authored-by: Shefali Joshi <simplyrender@gmail.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { addNotebookEntry, createNewEmbed } from './utils/notebook-entries';
|
||||
import { getDefaultNotebook, getNotebookSectionAndPage, getDefaultNotebookLink, setDefaultNotebook } from './utils/notebook-storage';
|
||||
import { NOTEBOOK_DEFAULT } from '@/plugins/notebook/notebook-constants';
|
||||
import { createNotebookImageDomainObject, DEFAULT_SIZE } from './utils/notebook-image';
|
||||
import { createNotebookImageDomainObject, saveNotebookImageDomainObject, updateNamespaceOfDomainObject, DEFAULT_SIZE } from './utils/notebook-image';
|
||||
|
||||
import SnapshotContainer from './snapshot-container';
|
||||
import ImageExporter from '../../exporters/ImageExporter';
|
||||
@@ -35,29 +35,28 @@ export default class Snapshot {
|
||||
* @private
|
||||
*/
|
||||
_saveSnapShot(notebookType, fullSizeImageURL, thumbnailImageURL, snapshotMeta) {
|
||||
createNotebookImageDomainObject(this.openmct, fullSizeImageURL)
|
||||
.then(object => {
|
||||
const thumbnailImage = { src: thumbnailImageURL || '' };
|
||||
const snapshot = {
|
||||
fullSizeImageObjectIdentifier: object.identifier,
|
||||
thumbnailImage
|
||||
};
|
||||
const embed = createNewEmbed(snapshotMeta, snapshot);
|
||||
if (notebookType === NOTEBOOK_DEFAULT) {
|
||||
this._saveToDefaultNoteBook(embed);
|
||||
const object = createNotebookImageDomainObject(fullSizeImageURL);
|
||||
const thumbnailImage = { src: thumbnailImageURL || '' };
|
||||
const snapshot = {
|
||||
fullSizeImageObjectIdentifier: object.identifier,
|
||||
thumbnailImage
|
||||
};
|
||||
const embed = createNewEmbed(snapshotMeta, snapshot);
|
||||
if (notebookType === NOTEBOOK_DEFAULT) {
|
||||
const notebookStorage = getDefaultNotebook();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this._saveToNotebookSnapshots(embed);
|
||||
});
|
||||
this._saveToDefaultNoteBook(notebookStorage, embed);
|
||||
const notebookImageDomainObject = updateNamespaceOfDomainObject(object, notebookStorage.identifier.namespace);
|
||||
saveNotebookImageDomainObject(this.openmct, notebookImageDomainObject);
|
||||
} else {
|
||||
this._saveToNotebookSnapshots(object, embed);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_saveToDefaultNoteBook(embed) {
|
||||
const notebookStorage = getDefaultNotebook();
|
||||
_saveToDefaultNoteBook(notebookStorage, embed) {
|
||||
this.openmct.objects.get(notebookStorage.identifier)
|
||||
.then(async (domainObject) => {
|
||||
addNotebookEntry(this.openmct, domainObject, notebookStorage, embed);
|
||||
@@ -85,8 +84,8 @@ export default class Snapshot {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_saveToNotebookSnapshots(embed) {
|
||||
this.snapshotContainer.addSnapshot(embed);
|
||||
_saveToNotebookSnapshots(notebookImageDomainObject, embed) {
|
||||
this.snapshotContainer.addSnapshot(notebookImageDomainObject, embed);
|
||||
}
|
||||
|
||||
_showNotification(msg, url) {
|
||||
|
||||
Reference in New Issue
Block a user