diff --git a/src/plugins/condition/ConditionSetViewProvider.js b/src/plugins/condition/ConditionSetViewProvider.js index 9d22a3a85e..535b0d7d53 100644 --- a/src/plugins/condition/ConditionSetViewProvider.js +++ b/src/plugins/condition/ConditionSetViewProvider.js @@ -39,8 +39,10 @@ export default class ConditionSetViewProvider { return isConditionSet && this.openmct.router.isNavigatedObject(objectPath); } - canEdit(domainObject) { - return domainObject.type === 'conditionSet'; + canEdit(domainObject, objectPath) { + const isConditionSet = domainObject.type === 'conditionSet'; + + return isConditionSet && this.openmct.router.isNavigatedObject(objectPath); } view(domainObject, objectPath) { diff --git a/src/plugins/formActions/CreateAction.js b/src/plugins/formActions/CreateAction.js index 374fa54ba9..2b780466e8 100644 --- a/src/plugins/formActions/CreateAction.js +++ b/src/plugins/formActions/CreateAction.js @@ -99,6 +99,7 @@ export default class CreateAction extends PropertiesAction { */ async _navigateAndEdit(domainObject, parentDomainObjectpath) { let objectPath; + let self = this; if (parentDomainObjectpath) { objectPath = parentDomainObjectpath && [domainObject].concat(parentDomainObjectpath); } else { @@ -110,13 +111,18 @@ export default class CreateAction extends PropertiesAction { .reverse() .join('/'); - this.openmct.router.navigate(url); + function editObject() { + const objectView = self.openmct.objectViews.get(domainObject, objectPath)[0]; + const canEdit = objectView && objectView.canEdit && objectView.canEdit(domainObject, objectPath); - const objectView = this.openmct.objectViews.get(domainObject, objectPath)[0]; - const canEdit = objectView && objectView.canEdit && objectView.canEdit(domainObject, objectPath); - if (canEdit) { - this.openmct.editor.edit(); + if (canEdit) { + self.openmct.editor.edit(); + } } + + this.openmct.router.once('afterNavigation', editObject); + + this.openmct.router.navigate(url); } /** diff --git a/src/plugins/imagery/components/ImageryTimeView.vue b/src/plugins/imagery/components/ImageryTimeView.vue index 9c83cbe5e5..137924b159 100644 --- a/src/plugins/imagery/components/ImageryTimeView.vue +++ b/src/plugins/imagery/components/ImageryTimeView.vue @@ -65,13 +65,8 @@ export default { keyString: undefined }; }, - computed: { - imageHistorySize() { - return this.imageHistory.length; - } - }, watch: { - imageHistorySize(newSize, oldSize) { + imageHistory(newHistory, oldHistory) { this.updatePlotImagery(); } }, diff --git a/src/plugins/imagery/components/ImageryView.vue b/src/plugins/imagery/components/ImageryView.vue index d0129a20bf..f15ed95469 100644 --- a/src/plugins/imagery/components/ImageryView.vue +++ b/src/plugins/imagery/components/ImageryView.vue @@ -240,9 +240,6 @@ export default { }; }, computed: { - imageHistorySize() { - return this.imageHistory.length; - }, compassRoseSizingClasses() { let compassRoseSizingClasses = ''; if (this.sizedImageDimensions.width < 300) { @@ -409,19 +406,23 @@ export default { } }, watch: { - imageHistorySize(newSize, oldSize) { - let imageIndex; - if (this.focusedImageTimestamp !== undefined) { - const foundImageIndex = this.imageHistory.findIndex(image => { - return image.time === this.focusedImageTimestamp; - }); - imageIndex = foundImageIndex > -1 ? foundImageIndex : newSize - 1; - } else { - imageIndex = newSize > 0 ? newSize - 1 : undefined; - } + imageHistory: { + handler(newHistory, oldHistory) { + const newSize = newHistory.length; + let imageIndex; + if (this.focusedImageTimestamp !== undefined) { + const foundImageIndex = this.imageHistory.findIndex(image => { + return image.time === this.focusedImageTimestamp; + }); + imageIndex = foundImageIndex > -1 ? foundImageIndex : newSize - 1; + } else { + imageIndex = newSize > 0 ? newSize - 1 : undefined; + } - this.setFocusedImage(imageIndex, false); - this.scrollToRight(); + this.setFocusedImage(imageIndex, false); + this.scrollToRight(); + }, + deep: true }, focusedImageIndex() { this.trackDuration(); @@ -510,12 +511,6 @@ export default { this.timeContext.off("clock", this.trackDuration); } }, - boundsChange(bounds, isTick) { - if (!isTick) { - this.previousFocusedImage = this.focusedImage ? JSON.parse(JSON.stringify(this.focusedImage)) : undefined; - this.requestHistory(); - } - }, expand() { const actionCollection = this.openmct.actions.getActionsCollection(this.objectPath, this.currentView); const visibleActions = actionCollection.getVisibleActions(); @@ -690,22 +685,32 @@ export default { return; } - if (this.previousFocusedImage) { - // determine if the previous image exists in the new bounds of imageHistory - const matchIndex = this.matchIndexOfPreviousImage( - this.previousFocusedImage, - this.imageHistory - ); - focusedIndex = matchIndex > -1 ? matchIndex : this.imageHistory.length - 1; - - delete this.previousFocusedImage; - } - if (thumbnailClick) { //We use the props till the user changes what they want to see this.focusedImageTimestamp = undefined; + //set the previousFocusedImage when a user chooses an image + this.previousFocusedImage = this.imageHistory[focusedIndex] ? JSON.parse(JSON.stringify(this.imageHistory[focusedIndex])) : undefined; } + if (this.previousFocusedImage) { + // determine if the previous image exists in the new bounds of imageHistory + if (!thumbnailClick) { + const matchIndex = this.matchIndexOfPreviousImage( + this.previousFocusedImage, + this.imageHistory + ); + focusedIndex = matchIndex > -1 ? matchIndex : this.imageHistory.length - 1; + } + + if (!(this.isPaused || thumbnailClick) + || focusedIndex === this.imageHistory.length - 1) { + delete this.previousFocusedImage; + } + } + + this.focusedImageIndex = focusedIndex; + + //TODO: do we even need this anymore? if (this.isPaused && !thumbnailClick && this.focusedImageTimestamp === undefined) { this.nextImageIndex = focusedIndex; //this could happen if bounds changes @@ -716,8 +721,6 @@ export default { return; } - this.focusedImageIndex = focusedIndex; - if (thumbnailClick && !this.isPaused) { this.paused(true); } diff --git a/src/plugins/imagery/mixins/imageryData.js b/src/plugins/imagery/mixins/imageryData.js index b3ac61ad2c..ae150ea592 100644 --- a/src/plugins/imagery/mixins/imageryData.js +++ b/src/plugins/imagery/mixins/imageryData.js @@ -120,9 +120,15 @@ export default { return this.timeFormatter.parse(datum); }, boundsChange(bounds, isTick) { - if (!isTick) { - this.requestHistory(); + if (isTick) { + return; } + + // forcibly reset the imageContainer size to prevent an aspect ratio distortion + delete this.imageContainerWidth; + delete this.imageContainerHeight; + + return this.requestHistory(); }, async requestHistory() { let bounds = this.timeContext.bounds(); diff --git a/src/plugins/linkAction/LinkAction.js b/src/plugins/linkAction/LinkAction.js index 0f51ad7a5f..e4f4c8b47a 100644 --- a/src/plugins/linkAction/LinkAction.js +++ b/src/plugins/linkAction/LinkAction.js @@ -91,11 +91,11 @@ export default class LinkAction { } validate(currentParent) { - return (object, data) => { - const parentCandidate = data.value; + return (data) => { + const parentCandidate = data.value[0]; const currentParentKeystring = this.openmct.objects.makeKeyString(currentParent.identifier); const parentCandidateKeystring = this.openmct.objects.makeKeyString(parentCandidate.identifier); - const objectKeystring = this.openmct.objects.makeKeyString(object.identifier); + const objectKeystring = this.openmct.objects.makeKeyString(this.object.identifier); if (!parentCandidateKeystring || !currentParentKeystring) { return false; @@ -114,7 +114,7 @@ export default class LinkAction { return false; } - return parentCandidate && this.openmct.composition.checkPolicy(parentCandidate, object); + return parentCandidate && this.openmct.composition.checkPolicy(parentCandidate, this.object); }; } } diff --git a/src/plugins/notebook/components/Notebook.vue b/src/plugins/notebook/components/Notebook.vue index ca3ce49e26..705a587335 100644 --- a/src/plugins/notebook/components/Notebook.vue +++ b/src/plugins/notebook/components/Notebook.vue @@ -142,7 +142,6 @@ import { clearDefaultNotebook, getDefaultNotebook, setDefaultNotebook, setDefaul import { addNotebookEntry, createNewEmbed, getEntryPosById, getNotebookEntries, mutateObject } from '../utils/notebook-entries'; import { saveNotebookImageDomainObject, updateNamespaceOfDomainObject } from '../utils/notebook-image'; import { NOTEBOOK_VIEW_TYPE } from '../notebook-constants'; -import objectUtils from 'objectUtils'; import { debounce } from 'lodash'; import objectLink from '../../../ui/mixins/object-link'; @@ -461,11 +460,6 @@ export default { ? getDefaultNotebook().defaultSectionId : undefined; }, - getDefaultNotebookObject() { - const defaultNotebook = getDefaultNotebook(); - - return defaultNotebook && this.openmct.objects.get(defaultNotebook.identifier); - }, getLinktoNotebook() { const objectPath = this.openmct.router.path; const link = objectLink.computed.objectLink.call({ @@ -625,12 +619,12 @@ export default { this.sectionsChanged({ sections }); }, - removeDefaultClass(domainObject) { - if (!domainObject) { + removeDefaultClass(defaultNotebookIdentifier) { + if (!defaultNotebookIdentifier) { return; } - this.openmct.status.delete(domainObject.identifier); + this.openmct.status.delete(defaultNotebookIdentifier); }, resetSearch() { this.search = ''; @@ -639,15 +633,16 @@ export default { toggleNav() { this.showNav = !this.showNav; }, - async updateDefaultNotebook(notebookStorage) { - const defaultNotebookObject = await this.getDefaultNotebookObject(); - const isSameNotebook = defaultNotebookObject - && objectUtils.makeKeyString(defaultNotebookObject.identifier) === objectUtils.makeKeyString(notebookStorage.identifier); + updateDefaultNotebook(notebookStorage) { + const defaultNotebook = getDefaultNotebook(); + const defaultNotebookIdentifier = defaultNotebook && defaultNotebook.identifier; + const isSameNotebook = defaultNotebookIdentifier + && this.openmct.objects.areIdsEqual(defaultNotebookIdentifier, notebookStorage.identifier); if (!isSameNotebook) { - this.removeDefaultClass(defaultNotebookObject); + this.removeDefaultClass(defaultNotebookIdentifier); } - if (!defaultNotebookObject || !isSameNotebook) { + if (!defaultNotebookIdentifier || !isSameNotebook) { setDefaultNotebook(this.openmct, notebookStorage, this.domainObject); } diff --git a/src/plugins/notebook/snapshot.js b/src/plugins/notebook/snapshot.js index 282640f161..b3762da797 100644 --- a/src/plugins/notebook/snapshot.js +++ b/src/plugins/notebook/snapshot.js @@ -110,7 +110,8 @@ export default class Snapshot { } return () => { - window.location.href = window.location.origin + url; + const path = window.location.href.split('#'); + window.location.href = path[0] + url; }; } } diff --git a/src/plugins/notebook/utils/notebook-entries.js b/src/plugins/notebook/utils/notebook-entries.js index 5c6abb6462..4ce9901419 100644 --- a/src/plugins/notebook/utils/notebook-entries.js +++ b/src/plugins/notebook/utils/notebook-entries.js @@ -105,11 +105,6 @@ export function addNotebookEntry(openmct, domainObject, notebookStorage, embed = const date = Date.now(); const configuration = domainObject.configuration; const entries = configuration.entries || {}; - - if (!entries) { - return; - } - const embeds = embed ? [embed] : []; @@ -125,7 +120,8 @@ export function addNotebookEntry(openmct, domainObject, notebookStorage, embed = const newEntries = addEntryIntoPage(notebookStorage, entries, entry); addDefaultClass(domainObject, openmct); - domainObject.configuration.entries = newEntries; + + mutateObject(openmct, domainObject, 'configuration.entries', newEntries); return id; } diff --git a/src/plugins/summaryWidget/SummaryWidgetsCompositionPolicy.js b/src/plugins/summaryWidget/SummaryWidgetsCompositionPolicy.js index 28b86107f7..09e002211d 100644 --- a/src/plugins/summaryWidget/SummaryWidgetsCompositionPolicy.js +++ b/src/plugins/summaryWidget/SummaryWidgetsCompositionPolicy.js @@ -29,7 +29,9 @@ define( } SummaryWidgetsCompositionPolicy.prototype.allow = function (parent, child) { - if (parent.type === 'summary-widget' && !this.openmct.telemetry.isTelemetryObject(child)) { + const parentType = parent.type; + + if (parentType === 'summary-widget' && !this.openmct.telemetry.isTelemetryObject(child)) { return false; } diff --git a/src/ui/components/ObjectView.vue b/src/ui/components/ObjectView.vue index cc462b61a0..5184733067 100644 --- a/src/ui/components/ObjectView.vue +++ b/src/ui/components/ObjectView.vue @@ -152,11 +152,15 @@ export default { this.openmct.objectViews.off('clearData', this.clearData); }, getStyleReceiver() { - let styleReceiver = this.$refs.objectViewWrapper.querySelector('.js-style-receiver') - || this.$refs.objectViewWrapper.querySelector(':first-child'); + let styleReceiver; - if (styleReceiver === null) { - styleReceiver = undefined; + if (this.$refs.objectViewWrapper !== undefined) { + styleReceiver = this.$refs.objectViewWrapper.querySelector('.js-style-receiver') + || this.$refs.objectViewWrapper.querySelector(':first-child'); + + if (styleReceiver === null) { + styleReceiver = undefined; + } } return styleReceiver; diff --git a/src/ui/inspector/details/Properties.vue b/src/ui/inspector/details/Properties.vue index 2127546c38..f7ff3beaea 100644 --- a/src/ui/inspector/details/Properties.vue +++ b/src/ui/inspector/details/Properties.vue @@ -186,6 +186,10 @@ export default { return { name: field.name, value: field.path.reduce((object, key) => { + if (object === undefined) { + return object; + } + return object[key]; }, this.domainObject) }; diff --git a/src/ui/layout/mct-tree.vue b/src/ui/layout/mct-tree.vue index 2161ea5dad..e02c4264c8 100644 --- a/src/ui/layout/mct-tree.vue +++ b/src/ui/layout/mct-tree.vue @@ -445,6 +445,10 @@ export default { } // sorting composition items + if (!a.name || !b.name) { + return 0; + } + if (a.name.toLowerCase() > b.name.toLowerCase()) { return 1; diff --git a/src/ui/mixins/object-link.js b/src/ui/mixins/object-link.js index 71e09e5106..227b9c7518 100644 --- a/src/ui/mixins/object-link.js +++ b/src/ui/mixins/object-link.js @@ -1,4 +1,4 @@ -import objectPathToUrl from '/src/tools/url'; +import objectPathToUrl from '../../tools/url'; export default { inject: ['openmct'],