mgr/dashboard: Fix validation of OSDs

There were situations where the OSD was removed and then we tried to access some
property of the OSD object, causing a frontend error.

Signed-off-by: Tiago Melo <tmelo@suse.com>
This commit is contained in:
Tiago Melo 2019-09-19 13:39:22 +00:00
parent e78569a4cb
commit 0a27d5a1aa

View File

@ -241,13 +241,14 @@ export class OsdListComponent implements OnInit {
return true;
}
const validOsds = [];
let validOsds = [];
if (this.selection.hasSelection) {
for (const osdId of this.getSelectedIds()) {
validOsds.push(this.osds.filter((o) => o.id === osdId).pop());
}
}
validOsds = validOsds.filter((osd) => !_.isUndefined(osd));
if (validOsds.length === 0) {
// `osd` is undefined if the selected OSD has been removed.
return true;