Hide vue plots from showing up in the view-switcher and in the preview window (#3725)

* Hide vue plots from showing up in the view-switcher and in the preview window.
This commit is contained in:
Shefali Joshi 2021-03-03 11:33:31 -08:00 committed by GitHub
parent b68f79f427
commit b8ded0a16e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 101 additions and 47 deletions

View File

@ -71,10 +71,10 @@ define(
openmct.editor.cancel();
}
function isFirstViewEditable(domainObject) {
let firstView = openmct.objectViews.get(domainObject)[0];
function isFirstViewEditable(domainObject, objectPath) {
let firstView = openmct.objectViews.get(domainObject, objectPath)[0];
return firstView && firstView.canEdit && firstView.canEdit(domainObject);
return firstView && firstView.canEdit && firstView.canEdit(domainObject, objectPath);
}
function navigateAndEdit(object) {
@ -88,7 +88,7 @@ define(
window.location.href = url;
if (isFirstViewEditable(object.useCapability('adapter'))) {
if (isFirstViewEditable(object.useCapability('adapter'), objectPath)) {
openmct.editor.edit();
}
}

View File

@ -32,7 +32,7 @@ define([], function () {
if (Object.prototype.hasOwnProperty.call(view, 'provider')) {
const domainObject = legacyObject.useCapability('adapter');
return view.provider.canView(domainObject);
return view.provider.canView(domainObject, this.openmct.router.path);
}
return true;

View File

@ -98,7 +98,7 @@ describe("The LAD Table", () => {
});
it("should provide a table view only for lad table objects", () => {
let applicableViews = openmct.objectViews.get(mockObj.ladTable);
let applicableViews = openmct.objectViews.get(mockObj.ladTable, []);
let ladTableView = applicableViews.find(
(viewProvider) => viewProvider.key === ladTableKey
@ -185,7 +185,7 @@ describe("The LAD Table", () => {
end: bounds.end
});
applicableViews = openmct.objectViews.get(mockObj.ladTable);
applicableViews = openmct.objectViews.get(mockObj.ladTable, []);
ladTableViewProvider = applicableViews.find((viewProvider) => viewProvider.key === ladTableKey);
ladTableView = ladTableViewProvider.view(mockObj.ladTable, [mockObj.ladTable]);
ladTableView.show(child, true);
@ -296,7 +296,7 @@ describe("The LAD Table Set", () => {
});
it("should provide a lad table set view only for lad table set objects", () => {
let applicableViews = openmct.objectViews.get(mockObj.ladTableSet);
let applicableViews = openmct.objectViews.get(mockObj.ladTableSet, []);
let ladTableSetView = applicableViews.find(
(viewProvider) => viewProvider.key === ladTableSetKey
@ -391,7 +391,7 @@ describe("The LAD Table Set", () => {
end: bounds.end
});
applicableViews = openmct.objectViews.get(mockObj.ladTableSet);
applicableViews = openmct.objectViews.get(mockObj.ladTableSet, []);
ladTableSetViewProvider = applicableViews.find((viewProvider) => viewProvider.key === ladTableSetKey);
ladTableSetView = ladTableSetViewProvider.view(mockObj.ladTableSet, [mockObj.ladTableSet]);
ladTableSetView.show(child, true);

View File

@ -67,11 +67,11 @@ describe("AutoflowTabularPlugin", () => {
});
it("applies its view to the type from options", () => {
expect(provider.canView(testObject)).toBe(true);
expect(provider.canView(testObject, [])).toBe(true);
});
it("does not apply to other types", () => {
expect(provider.canView({ type: 'foo' })).toBe(false);
expect(provider.canView({ type: 'foo' }, [])).toBe(false);
});
describe("provides a view which", () => {

View File

@ -136,7 +136,7 @@ describe('the plugin', function () {
}
};
const applicableViews = openmct.objectViews.get(testViewObject);
const applicableViews = openmct.objectViews.get(testViewObject, []);
let conditionSetView = applicableViews.find((viewProvider) => viewProvider.key === 'conditionSet.view');
expect(conditionSetView).toBeDefined();
});

View File

@ -83,7 +83,7 @@ describe('the plugin', function () {
}
};
const applicableViews = openmct.objectViews.get(testViewObject);
const applicableViews = openmct.objectViews.get(testViewObject, []);
let displayLayoutViewProvider = applicableViews.find((viewProvider) => viewProvider.key === 'layout.view');
expect(displayLayoutViewProvider).toBeDefined();
});

View File

@ -235,7 +235,7 @@ describe("The Imagery View Layout", () => {
});
it("should provide an imagery view only for imagery producing objects", () => {
let applicableViews = openmct.objectViews.get(imageryObject);
let applicableViews = openmct.objectViews.get(imageryObject, []);
let imageryView = applicableViews.find(
viewProvider => viewProvider.key === imageryKey
);
@ -265,7 +265,7 @@ describe("The Imagery View Layout", () => {
end: bounds.end + 100
});
applicableViews = openmct.objectViews.get(imageryObject);
applicableViews = openmct.objectViews.get(imageryObject, []);
imageryViewProvider = applicableViews.find(viewProvider => viewProvider.key === imageryKey);
imageryView = imageryViewProvider.view(imageryObject);
imageryView.show(child);

View File

@ -101,7 +101,7 @@ describe("Notebook plugin:", () => {
creatable: true
};
const applicableViews = openmct.objectViews.get(notebookViewObject);
const applicableViews = openmct.objectViews.get(notebookViewObject, []);
notebookViewProvider = applicableViews.find(viewProvider => viewProvider.key === notebookObject.key);
notebookView = notebookViewProvider.view(notebookViewObject);

View File

@ -82,7 +82,7 @@ describe('the plugin', function () {
type: "plan"
};
const applicableViews = openmct.objectViews.get(testViewObject);
const applicableViews = openmct.objectViews.get(testViewObject, []);
let planView = applicableViews.find((viewProvider) => viewProvider.key === 'plan.view');
expect(planView).toBeDefined();
});
@ -135,7 +135,7 @@ describe('the plugin', function () {
}
};
const applicableViews = openmct.objectViews.get(planDomainObject);
const applicableViews = openmct.objectViews.get(planDomainObject, []);
planView = applicableViews.find((viewProvider) => viewProvider.key === 'plan.view');
let view = planView.view(planDomainObject, mockObjectPath);
view.show(child, true);

View File

@ -32,12 +32,12 @@ export default function OverlayPlotViewProvider(openmct) {
key: 'plot-overlay',
name: 'Overlay Plot',
cssClass: 'icon-telemetry',
canView(domainObject) {
return domainObject.type === 'telemetry.plot.overlay';
canView(domainObject, objectPath) {
return isCompactView(objectPath) && domainObject.type === 'telemetry.plot.overlay';
},
canEdit(domainObject) {
return domainObject.type === 'telemetry.plot.overlay';
canEdit(domainObject, objectPath) {
return isCompactView(objectPath) && domainObject.type === 'telemetry.plot.overlay';
},
view: function (domainObject, objectPath) {

View File

@ -47,8 +47,8 @@ export default function PlotViewProvider(openmct) {
key: 'plot-simple',
name: 'Plot',
cssClass: 'icon-telemetry',
canView(domainObject) {
return hasTelemetry(domainObject, openmct);
canView(domainObject, objectPath) {
return isCompactView(objectPath) && hasTelemetry(domainObject, openmct);
},
view: function (domainObject, objectPath) {

View File

@ -33,8 +33,27 @@ describe("the plugin", function () {
let openmct;
let telemetryPromise;
let cleanupFirst;
let mockObjectPath;
beforeEach((done) => {
mockObjectPath = [
{
name: 'mock folder',
type: 'fake-folder',
identifier: {
key: 'mock-folder',
namespace: ''
}
},
{
name: 'mock parent folder',
type: 'time-strip',
identifier: {
key: 'mock-parent-folder',
namespace: ''
}
}
];
const testTelemetry = [
{
'utc': 1,
@ -134,7 +153,7 @@ describe("the plugin", function () {
}
};
const applicableViews = openmct.objectViews.get(testTelemetryObject);
const applicableViews = openmct.objectViews.get(testTelemetryObject, mockObjectPath);
let plotView = applicableViews.find((viewProvider) => viewProvider.key === "plot-simple");
expect(plotView).toBeDefined();
});
@ -150,7 +169,7 @@ describe("the plugin", function () {
}
};
const applicableViews = openmct.objectViews.get(testTelemetryObject);
const applicableViews = openmct.objectViews.get(testTelemetryObject, mockObjectPath);
let plotView = applicableViews.find((viewProvider) => viewProvider.key === "plot-overlay");
expect(plotView).toBeDefined();
});
@ -166,7 +185,7 @@ describe("the plugin", function () {
}
};
const applicableViews = openmct.objectViews.get(testTelemetryObject);
const applicableViews = openmct.objectViews.get(testTelemetryObject, mockObjectPath);
let plotView = applicableViews.find((viewProvider) => viewProvider.key === "plot-stacked");
expect(plotView).toBeDefined();
});
@ -218,7 +237,7 @@ describe("the plugin", function () {
}
};
applicableViews = openmct.objectViews.get(testTelemetryObject);
applicableViews = openmct.objectViews.get(testTelemetryObject, mockObjectPath);
plotViewProvider = applicableViews.find((viewProvider) => viewProvider.key === "plot-simple");
plotView = plotViewProvider.view(testTelemetryObject, [testTelemetryObject]);
plotView.show(child, true);

View File

@ -32,12 +32,12 @@ export default function StackedPlotViewProvider(openmct) {
key: 'plot-stacked',
name: 'Stacked Plot',
cssClass: 'icon-telemetry',
canView(domainObject) {
return domainObject.type === 'telemetry.plot.stacked';
canView(domainObject, objectPath) {
return isCompactView(objectPath) && domainObject.type === 'telemetry.plot.stacked';
},
canEdit(domainObject) {
return domainObject.type === 'telemetry.plot.stacked';
canEdit(domainObject, objectPath) {
return isCompactView(objectPath) && domainObject.type === 'telemetry.plot.stacked';
},
view: function (domainObject, objectPath) {

View File

@ -103,7 +103,7 @@ describe("the plugin", () => {
}
};
const applicableViews = openmct.objectViews.get(testTelemetryObject);
const applicableViews = openmct.objectViews.get(testTelemetryObject, []);
let tableView = applicableViews.find((viewProvider) => viewProvider.key === 'table');
expect(tableView).toBeDefined();
});
@ -174,7 +174,7 @@ describe("the plugin", () => {
openmct.router.path = [testTelemetryObject];
applicableViews = openmct.objectViews.get(testTelemetryObject);
applicableViews = openmct.objectViews.get(testTelemetryObject, []);
tableViewProvider = applicableViews.find((viewProvider) => viewProvider.key === 'table');
tableView = tableViewProvider.view(testTelemetryObject, [testTelemetryObject]);
tableView.show(child, true);

View File

@ -87,9 +87,9 @@ const unknownObjectType = {
}
};
function getViewKey(domainObject, openmct) {
function getViewKey(domainObject, objectPath, openmct) {
let viewKey = '';
const plotView = openmct.objectViews.get(domainObject).find((view) => {
const plotView = openmct.objectViews.get(domainObject, objectPath).find((view) => {
return view.key.startsWith('plot-') && view.key !== 'plot-single';
});
if (plotView) {
@ -136,7 +136,7 @@ export default {
let type = this.openmct.types.get(domainObject.type) || unknownObjectType;
let keyString = this.openmct.objects.makeKeyString(domainObject.identifier);
let objectPath = [domainObject].concat(this.objectPath.slice());
let viewKey = getViewKey(domainObject, this.openmct);
let viewKey = getViewKey(domainObject, objectPath, this.openmct);
let rowCount = 0;
if (domainObject.type === 'plan') {
rowCount = Object.keys(getValidatedPlan(domainObject)).length;

View File

@ -29,8 +29,27 @@ describe('the plugin', function () {
let element;
let child;
let openmct;
let mockObjectPath;
beforeEach((done) => {
mockObjectPath = [
{
name: 'mock folder',
type: 'fake-folder',
identifier: {
key: 'mock-folder',
namespace: ''
}
},
{
name: 'mock parent folder',
type: 'time-strip',
identifier: {
key: 'mock-parent-folder',
namespace: ''
}
}
];
const appHolder = document.createElement('div');
appHolder.style.width = '640px';
appHolder.style.height = '480px';
@ -87,7 +106,7 @@ describe('the plugin', function () {
type: "time-strip"
};
const applicableViews = openmct.objectViews.get(testViewObject);
const applicableViews = openmct.objectViews.get(testViewObject, mockObjectPath);
timelineView = applicableViews.find((viewProvider) => viewProvider.key === 'time-strip.view');
let view = timelineView.view(testViewObject, element);
view.show(child, true);

View File

@ -320,7 +320,8 @@ export default {
let provider = this.openmct.objectViews.getByProviderKey(this.getViewKey());
if (!provider) {
provider = this.openmct.objectViews.get(this.domainObject)[0];
let objectPath = this.currentObjectPath || this.objectPath;
provider = this.openmct.objectViews.get(this.domainObject, objectPath)[0];
if (!provider) {
return;
}
@ -329,10 +330,11 @@ export default {
return provider;
},
editIfEditable(event) {
let objectPath = this.currentObjectPath || this.objectPath;
let provider = this.getViewProvider();
if (provider
&& provider.canEdit
&& provider.canEdit(this.domainObject)
&& provider.canEdit(this.domainObject, objectPath)
&& this.isEditingAllowed()
&& !this.openmct.editor.isEditing()) {
this.openmct.editor.edit();

View File

@ -159,10 +159,14 @@ export default {
return this.views.filter(v => v.key === this.viewKey)[0] || {};
},
views() {
if (this.openmct.router.started !== true) {
return [];
}
return this
.openmct
.objectViews
.get(this.domainObject)
.get(this.domainObject, this.openmct.router.path)
.map((p) => {
return {
key: p.key,
@ -197,7 +201,7 @@ export default {
if (currentViewKey !== undefined) {
let currentViewProvider = this.openmct.objectViews.getByProviderKey(currentViewKey);
return currentViewProvider.canEdit && currentViewProvider.canEdit(this.domainObject);
return currentViewProvider.canEdit && currentViewProvider.canEdit(this.domainObject, this.openmct.router.path);
}
return false;

View File

@ -58,7 +58,7 @@ export default {
};
},
mounted() {
this.views = this.openmct.objectViews.get(this.domainObject).map((view) => {
this.views = this.openmct.objectViews.get(this.domainObject, this.objectPath).map((view) => {
view.callBack = () => {
return this.setView(view);
};

View File

@ -39,10 +39,16 @@ define(['EventEmitter'], function (EventEmitter) {
/**
* @private for platform-internal use
* @param {*} item the object to be viewed
* @param {array} objectPath - The current contextual object path of the view object
* eg current domainObject is located under MyItems which is under Root
* @returns {module:openmct.ViewProvider[]} any providers
* which can provide views of this object
*/
ViewRegistry.prototype.get = function (item) {
ViewRegistry.prototype.get = function (item, objectPath) {
if (objectPath === undefined) {
throw "objectPath must be provided to get applicable views for an object";
}
function byPriority(providerA, providerB) {
let priorityA = providerA.priority ? providerA.priority(item) : DEFAULT_VIEW_PRIORITY;
let priorityB = providerB.priority ? providerB.priority(item) : DEFAULT_VIEW_PRIORITY;
@ -52,7 +58,7 @@ define(['EventEmitter'], function (EventEmitter) {
return this.getAllProviders()
.filter(function (provider) {
return provider.canView(item);
return provider.canView(item, objectPath);
}).sort(byPriority);
};
@ -181,6 +187,8 @@ define(['EventEmitter'], function (EventEmitter) {
* @memberof module:openmct.ViewProvider#
* @param {module:openmct.DomainObject} domainObject the domain object
* to be viewed
* @param {array} objectPath - The current contextual object path of the view object
* eg current domainObject is located under MyItems which is under Root
* @returns {boolean} 'true' if the view applies to the provided object,
* otherwise 'false'.
*/
@ -201,6 +209,8 @@ define(['EventEmitter'], function (EventEmitter) {
* @memberof module:openmct.ViewProvider#
* @param {module:openmct.DomainObject} domainObject the domain object
* to be edited
* @param {array} objectPath - The current contextual object path of the view object
* eg current domainObject is located under MyItems which is under Root
* @returns {boolean} 'true' if the view can be used to edit the provided object,
* otherwise 'false'.
*/

View File

@ -100,13 +100,13 @@ define([
document.title = browseObject.name; //change document title to current object in main view
if (currentProvider && currentProvider.canView(browseObject)) {
if (currentProvider && currentProvider.canView(browseObject, openmct.router.path)) {
viewObject(browseObject, currentProvider);
return;
}
let defaultProvider = openmct.objectViews.get(browseObject)[0];
let defaultProvider = openmct.objectViews.get(browseObject, openmct.router.path)[0];
if (defaultProvider) {
openmct.router.updateParams({
view: defaultProvider.key