mirror of
https://github.com/apache/superset.git
synced 2024-09-12 08:39:45 -04:00
[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);
|
].filter(option => option);
|
||||||
|
|
||||||
return options.map((option) => {
|
return options.reduce((results, option) => {
|
||||||
if (option.saved_metric_name) {
|
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) {
|
} 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) {
|
} else if (option instanceof AdhocMetric) {
|
||||||
return { ...option, filterOptionName: '_adhocmetric_' + option.label };
|
results.push({ ...option, filterOptionName: '_adhocmetric_' + option.label });
|
||||||
}
|
}
|
||||||
return null;
|
return results;
|
||||||
}).sort((a, b) => (
|
}, []).sort((a, b) => (
|
||||||
(a.saved_metric_name || a.column_name || a.label || '').localeCompare((
|
(a.saved_metric_name || a.column_name || a.label).localeCompare((
|
||||||
b.saved_metric_name || b.column_name || b.label
|
b.saved_metric_name || b.column_name || b.label
|
||||||
))
|
))
|
||||||
));
|
));
|
||||||
|
@ -193,17 +193,16 @@ export default class MetricsControl extends React.PureComponent {
|
|||||||
...props.savedMetrics,
|
...props.savedMetrics,
|
||||||
];
|
];
|
||||||
|
|
||||||
return options.map((option) => {
|
return options.reduce((results, option) => {
|
||||||
if (option.metric_name) {
|
if (option.metric_name) {
|
||||||
return { ...option, optionName: option.metric_name };
|
results.push({ ...option, optionName: option.metric_name });
|
||||||
} else if (option.column_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) {
|
} 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 results;
|
||||||
return null;
|
}, []);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isAutoGeneratedMetric(savedMetric) {
|
isAutoGeneratedMetric(savedMetric) {
|
||||||
|
Loading…
Reference in New Issue
Block a user