From dae3bdc5f96c64ab3805ca0753388aa6a39c8cc3 Mon Sep 17 00:00:00 2001 From: Taylor Date: Tue, 3 May 2022 14:56:32 -0400 Subject: [PATCH 1/4] fix(chart & alert): make to show metrics properly --- .../plugins/plugin-chart-table/src/controlPanel.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx index c121547518e46..54d8218cdb457 100644 --- a/superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx @@ -263,6 +263,7 @@ const config: ControlPanelConfig = { }, ], ['adhoc_filters'], + ['metrics'], [ { name: 'timeseries_limit_metric', From 02fb6efef809de7bf27c3bc86e98d4ac33f473ac Mon Sep 17 00:00:00 2001 From: Taylor Date: Wed, 4 May 2022 15:57:04 -0400 Subject: [PATCH 2/4] fix(chart & alert): make to remove duplicate metrics --- .../plugins/plugin-chart-table/src/controlPanel.tsx | 1 - superset-frontend/src/components/AlteredSliceTag/index.jsx | 7 ++----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx b/superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx index 54d8218cdb457..c121547518e46 100644 --- a/superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx +++ b/superset-frontend/plugins/plugin-chart-table/src/controlPanel.tsx @@ -263,7 +263,6 @@ const config: ControlPanelConfig = { }, ], ['adhoc_filters'], - ['metrics'], [ { name: 'timeseries_limit_metric', diff --git a/superset-frontend/src/components/AlteredSliceTag/index.jsx b/superset-frontend/src/components/AlteredSliceTag/index.jsx index 2faa62c8908db..f3ee4cdbc9767 100644 --- a/superset-frontend/src/components/AlteredSliceTag/index.jsx +++ b/superset-frontend/src/components/AlteredSliceTag/index.jsx @@ -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)); + return formattedValue.length ? formattedValue.join(', ') : '[]'; } if (typeof value === 'string' || typeof value === 'number') { return value; From 30d7f097e9492779b9e03a93c5e41a527bc33528 Mon Sep 17 00:00:00 2001 From: Taylor Date: Wed, 4 May 2022 18:12:15 -0400 Subject: [PATCH 3/4] fix(chart & alert): make to restore metrics control alert slice --- superset-frontend/src/components/AlteredSliceTag/index.jsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/superset-frontend/src/components/AlteredSliceTag/index.jsx b/superset-frontend/src/components/AlteredSliceTag/index.jsx index f3ee4cdbc9767..ae7aec97e2291 100644 --- a/superset-frontend/src/components/AlteredSliceTag/index.jsx +++ b/superset-frontend/src/components/AlteredSliceTag/index.jsx @@ -147,11 +147,15 @@ export default class AlteredSliceTag extends React.Component { if (controlsMap[key]?.type === 'CollectionControl') { return value.map(v => safeStringify(v)).join(', '); } + 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) { - const formattedValue = value.map(v => (v.label ? v.label : v)); + const formattedValue = value.map(v => (v?.label ?? v)); return formattedValue.length ? formattedValue.join(', ') : '[]'; } if (typeof value === 'string' || typeof value === 'number') { From 057e5d38840b2f2406c3a39d70166a00fc452602 Mon Sep 17 00:00:00 2001 From: Taylor Date: Thu, 5 May 2022 04:30:00 -0400 Subject: [PATCH 4/4] fix(chart & alert): make to fix lint issue --- .../src/components/AlteredSliceTag/index.jsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/superset-frontend/src/components/AlteredSliceTag/index.jsx b/superset-frontend/src/components/AlteredSliceTag/index.jsx index ae7aec97e2291..dd5dfb3c87868 100644 --- a/superset-frontend/src/components/AlteredSliceTag/index.jsx +++ b/superset-frontend/src/components/AlteredSliceTag/index.jsx @@ -147,15 +147,18 @@ export default class AlteredSliceTag extends React.Component { if (controlsMap[key]?.type === 'CollectionControl') { return value.map(v => safeStringify(v)).join(', '); } - if (controlsMap[key]?.type === 'MetricsControl' && value.constructor === Array) { - const formattedValue = value.map(v => (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) { - const formattedValue = value.map(v => (v?.label ?? v)); + const formattedValue = value.map(v => v?.label ?? v); return formattedValue.length ? formattedValue.join(', ') : '[]'; } if (typeof value === 'string' || typeof value === 'number') {