Refactor embed.vue charts(): from "Add empty region when group metrics are missing"
Background
Our value for metricsWithData changed from a statefully maintained variable to a getter in !20900 (merged).
This can allow the embed component to calculate charts() and move them the logic to a getter.
Proposal
Refactor this computed prop, which calculates which charts to display in a very round about way:
charts() {
if (!this.dashboard || !this.dashboard.panel_groups) {
return [];
}
const groupWithMetrics = this.dashboard.panel_groups.find(group =>
group.panels.find(chart => this.chartHasData(chart)),
) || { panels: [] };
return groupWithMetrics.panels.filter(chart => this.chartHasData(chart));
},
Original Discussion
The following discussion from !20900 (merged) should be addressed:
-
@dbodicherla started a discussion: (+1 comment) question: I wonder if we should get call to
metricsWithData()out of a loop.
Edited by Miguel Rincon