Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(chart & alert): make to show metrics properly #19939

Merged
merged 4 commits into from
May 16, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions superset-frontend/src/components/AlteredSliceTag/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,12 @@ export default class AlteredSliceTag extends React.Component {
if (controlsMap[key]?.type === 'CollectionControl') {
return value.map(v => safeStringify(v)).join(', ');
}
if (controlsMap[key]?.type === 'MetricsControl' && Array.isArray(value)) {
const formattedValue = value.map(v => (v.label ? v.label : v));
return formattedValue.length ? formattedValue.join(', ') : '[]';
}
if (typeof value === 'boolean') {
return value ? 'true' : 'false';
}
if (value.constructor === Array) {
return value.length ? value.join(', ') : '[]';
const formattedValue = value.map(v => (v.label ? v.label : v));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could potentially be called for other control types aside from metrics.
Why did you move it from above? Was the code not entering? We're essentially switching from Array.isArray to value.constructor, which should have similar effect.
If that's the only reason, we could replace Array.isArray with value.constructor in the other block you removed, but keeping it locked to the metrics control.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@diegomedina248
It does make sense. Resolved.

prosdev0107 marked this conversation as resolved.
Show resolved Hide resolved
return formattedValue.length ? formattedValue.join(', ') : '[]';
}
if (typeof value === 'string' || typeof value === 'number') {
return value;
Expand Down