Files
openmct/src/ui/preview/PreviewAction.js
Andrew Henry 92b2582d0d Preview instead of navigate in edit mode + highlight navigated object (#2252)
* Preview instead of navigate when in edit mode.

* Prevent preview of navigated object

* Removed trailing comma

* Observe navigation from tree items instead of mct-tree

* Cleanup of redundant code

* .is-selected -> .is-navigated-object
2019-01-11 11:21:52 -08:00

74 lines
2.6 KiB
JavaScript

/*****************************************************************************
* Open MCT, Copyright (c) 2014-2018, United States Government
* as represented by the Administrator of the National Aeronautics and Space
* Administration. All rights reserved.
*
* Open MCT is licensed under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* Open MCT includes source code licensed under additional open source
* licenses. See the Open Source Licenses file (LICENSES.md) included with
* this source code distribution or the Licensing information page available
* at runtime from the About dialog for additional information.
*****************************************************************************/
import Preview from './Preview.vue';
import Vue from 'vue';
export default class PreviewAction {
constructor(openmct) {
/**
* Metadata
*/
this.name = 'Preview';
this.description = 'Preview in large dialog';
this.cssClass = 'icon-eye-open';
/**
* Dependencies
*/
this._openmct = openmct;
}
invoke(objectPath) {
let preview = new Vue({
components: {
Preview
},
provide: {
openmct: this._openmct,
objectPath: objectPath
},
template: '<Preview></Preview>'
});
preview.$mount();
let overlay = this._openmct.overlays.overlay({
element: preview.$el,
size: 'large',
buttons: [
{
label: 'Done',
callback: () => overlay.dismiss()
}
],
onDestroy: () => preview.$destroy()
});
}
appliesTo(objectPath) {
return !this._isNavigatedObject(objectPath)
}
_isNavigatedObject(objectPath) {
let targetObject = objectPath[0];
let navigatedObject = this._openmct.router.path[0];
return targetObject.identifier.namespace === navigatedObject.identifier.namespace &&
targetObject.identifier.key === navigatedObject.identifier.key;
}
}