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

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

* fix(chart & alert): make to remove duplicate metrics

* fix(chart & alert): make to restore metrics control alert slice

* fix(chart & alert): make to fix lint issue
This commit is contained in:
smileydev 2022-05-16 15:22:47 -05:00 committed by GitHub
parent 4126c365c5
commit 55aef4db3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -109,15 +109,19 @@ 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));
if (
controlsMap[key]?.type === 'MetricsControl' &&
value.constructor === Array
) {
const formattedValue = value.map(v => 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);
return formattedValue.length ? formattedValue.join(', ') : '[]';
}
if (typeof value === 'string' || typeof value === 'number') {
return value;