mirror of https://github.com/apache/superset.git
[Explore] Handle empty metrics control data (#5241)
This commit is contained in:
parent
409ac6824a
commit
13cbf80fb3
|
@ -155,17 +155,17 @@ export default class AdhocFilterControl extends React.Component {
|
|||
)),
|
||||
].filter(option => option);
|
||||
|
||||
return options.map((option) => {
|
||||
return options.reduce((results, option) => {
|
||||
if (option.saved_metric_name) {
|
||||
return { ...option, filterOptionName: option.saved_metric_name };
|
||||
results.push({ ...option, filterOptionName: option.saved_metric_name });
|
||||
} else if (option.column_name) {
|
||||
return { ...option, filterOptionName: '_col_' + option.column_name };
|
||||
results.push({ ...option, filterOptionName: '_col_' + option.column_name });
|
||||
} else if (option instanceof AdhocMetric) {
|
||||
return { ...option, filterOptionName: '_adhocmetric_' + option.label };
|
||||
results.push({ ...option, filterOptionName: '_adhocmetric_' + option.label });
|
||||
}
|
||||
return null;
|
||||
}).sort((a, b) => (
|
||||
(a.saved_metric_name || a.column_name || a.label || '').localeCompare((
|
||||
return results;
|
||||
}, []).sort((a, b) => (
|
||||
(a.saved_metric_name || a.column_name || a.label).localeCompare((
|
||||
b.saved_metric_name || b.column_name || b.label
|
||||
))
|
||||
));
|
||||
|
|
|
@ -193,17 +193,16 @@ export default class MetricsControl extends React.PureComponent {
|
|||
...props.savedMetrics,
|
||||
];
|
||||
|
||||
return options.map((option) => {
|
||||
return options.reduce((results, option) => {
|
||||
if (option.metric_name) {
|
||||
return { ...option, optionName: option.metric_name };
|
||||
results.push({ ...option, optionName: option.metric_name });
|
||||
} else if (option.column_name) {
|
||||
return { ...option, optionName: '_col_' + option.column_name };
|
||||
results.push({ ...option, optionName: '_col_' + option.column_name });
|
||||
} else if (option.aggregate_name) {
|
||||
return { ...option, optionName: '_aggregate_' + option.aggregate_name };
|
||||
results.push({ ...option, optionName: '_aggregate_' + option.aggregate_name });
|
||||
}
|
||||
notify.error(`provided invalid option to MetricsControl, ${option}`);
|
||||
return null;
|
||||
});
|
||||
return results;
|
||||
}, []);
|
||||
}
|
||||
|
||||
isAutoGeneratedMetric(savedMetric) {
|
||||
|
|
Loading…
Reference in New Issue