From c2187aa1d591b2a1a826fc3bb69a4154c37945bb Mon Sep 17 00:00:00 2001 From: Evan Rusackas Date: Sat, 20 Dec 2025 00:39:51 -0800 Subject: [PATCH] fix(types): add types to MetricDefinitionValue component MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add MetricDefinitionValueProps interface - Add proper imports for Metric, Datasource, ISaveableDatasource - Type getSavedMetricByName parameter - Use optional chaining for savedMetrics 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../MetricControl/MetricDefinitionValue.tsx | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/superset-frontend/src/explore/components/controls/MetricControl/MetricDefinitionValue.tsx b/superset-frontend/src/explore/components/controls/MetricControl/MetricDefinitionValue.tsx index c300252dd29..ba86a4bb8ee 100644 --- a/superset-frontend/src/explore/components/controls/MetricControl/MetricDefinitionValue.tsx +++ b/superset-frontend/src/explore/components/controls/MetricControl/MetricDefinitionValue.tsx @@ -17,10 +17,30 @@ * under the License. */ import PropTypes from 'prop-types'; +import { Metric } from '@superset-ui/core'; +import { Datasource } from 'src/explore/types'; +import { ISaveableDatasource } from 'src/SqlLab/components/SaveDatasetModal'; import columnType from './columnType'; import AdhocMetricOption from './AdhocMetricOption'; import AdhocMetric from './AdhocMetric'; import savedMetricType from './savedMetricType'; +import { savedMetricType as SavedMetricTypeDef } from './types'; + +interface MetricDefinitionValueProps { + option: AdhocMetric | SavedMetricTypeDef | string; + index: number; + onMetricEdit?: (newMetric: Metric, oldMetric: Metric) => void; + onRemoveMetric?: (index: number) => void; + onMoveLabel?: (dragIndex: number, hoverIndex: number) => void; + onDropLabel?: () => void; + columns?: { column_name: string; type: string }[]; + savedMetrics?: SavedMetricTypeDef[]; + savedMetricsOptions?: SavedMetricTypeDef[]; + multi?: boolean; + datasource?: Datasource & ISaveableDatasource; + datasourceWarningMessage?: string; + type?: string; +} const propTypes = { option: PropTypes.oneOfType([PropTypes.object, PropTypes.string]).isRequired, @@ -51,9 +71,9 @@ export default function MetricDefinitionValue({ type, multi, datasourceWarningMessage, -}) { - const getSavedMetricByName = metricName => - savedMetrics.find(metric => metric.metric_name === metricName); +}: MetricDefinitionValueProps) { + const getSavedMetricByName = (metricName: string) => + savedMetrics?.find(metric => metric.metric_name === metricName); let savedMetric; if (typeof option === 'string') {