rusackas commented on code in PR #37625:
URL: https://github.com/apache/superset/pull/37625#discussion_r2766059226


##########
superset-frontend/plugins/legacy-plugin-chart-horizon/src/transformProps.ts:
##########
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import { ChartProps } from '@superset-ui/core';
+
+export default function transformProps(chartProps: ChartProps) {
+  const { height, width, formData, queriesData } = chartProps;
+  const {
+    horizon_color_scale: horizonColorScale,
+    series_height: seriesHeight,
+  } = formData;
+
+  // Only include colorScale if defined, otherwise let defaultProps apply
+  return {
+    ...(horizonColorScale !== undefined && {
+      colorScale: horizonColorScale as string,
+    }),
+    data: queriesData[0].data,
+    height,
+    seriesHeight: parseInt(String(seriesHeight ?? 20), 10),
+    width,
+  };

Review Comment:
   formData comes from ChartProps, which types it as Record<string, unknown> — 
this is a framework-level type from @superset-ui/core that represents arbitrary 
form data from the explore view. Individual plugin transformProps functions are 
the boundary where these unknown values get narrowed to specific types.
   
     The as string cast is the standard pattern used across every legacy 
plugin's transformProps. "Adding proper typing to the formData interface" would 
mean modifying the shared ChartProps type in @superset-ui/core, which is a 
separate effort well outside the scope of a TS migration PR. The cast here is 
correct and expected.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to