mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 23:28:14 +00:00
[Views] Warn if view omits key
Warn if a view definition does not include a key, and prune it from the list of views. This avoids an underlying cause of WTD-628, which is fixed for plots specifically in the previous commit but could recur if other views were to omit keys.
This commit is contained in:
@ -37,7 +37,25 @@ define(
|
||||
* @constructor
|
||||
* @param {View[]} an array of view definitions
|
||||
*/
|
||||
function ViewProvider(views) {
|
||||
function ViewProvider(views, $log) {
|
||||
|
||||
// Views without defined keys cannot be used in the user
|
||||
// interface, and can result in unexpected behavior. These
|
||||
// are filtered out using this function.
|
||||
function validate(view) {
|
||||
var key = view.key;
|
||||
|
||||
// Leave a log message to support detection of this issue.
|
||||
if (!key) {
|
||||
$log.warn([
|
||||
"No key specified for view in ",
|
||||
(view.bundle || {}).path,
|
||||
"; omitting this view."
|
||||
].join(""));
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
// Check if an object has all capabilities designated as `needs`
|
||||
// for a view. Exposing a capability via delegation is taken to
|
||||
@ -79,6 +97,9 @@ define(
|
||||
});
|
||||
}
|
||||
|
||||
// Filter out any key-less views
|
||||
views = views.filter(validate);
|
||||
|
||||
return {
|
||||
/**
|
||||
* Get all views which are applicable to this domain object.
|
||||
|
Reference in New Issue
Block a user