bito-code-review[bot] commented on code in PR #37779:
URL: https://github.com/apache/superset/pull/37779#discussion_r2779245579


##########
superset-frontend/plugins/plugin-chart-unified-list-bar/src/plugin/transformProps.ts:
##########
@@ -0,0 +1,123 @@
+/**
+ * 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, TimeseriesDataRecord, ensureIsArray } from 
'@superset-ui/core';
+import { UnifiedListBarChartProps, UnifiedListBarChartCustomizeProps } from 
'../types';
+
+// Helper to extract clean column name from formData value (which can be 
string, array, or object)
+const getColumnName = (col: any): string => {
+    if (!col) return '';
+    if (typeof col === 'string') return col;
+    if (Array.isArray(col) && col.length > 0) return getColumnName(col[0]);
+    if (typeof col === 'object') {
+        if (col.label) return col.label;
+        if (col.column_name) return col.column_name;
+        if (col.column && col.column.column_name) return 
col.column.column_name;
+        if (col.sqlExpression) return col.sqlExpression;
+    }
+    return String(col);
+};
+
+// Helper to convert ColorPickerControl value (RGBA object) to CSS color string
+const rgbaToString = (color: any): string => {
+    if (typeof color === 'string') return color;
+    if (color && typeof color === 'object' && 'r' in color && 'g' in color && 
'b' in color) {
+        const a = color.a !== undefined ? color.a : 1;
+        return `rgba(${color.r}, ${color.g}, ${color.b}, ${a})`;
+    }
+    return '#000000'; // Default black
+};
+
+export default function transformProps(chartProps: ChartProps): 
UnifiedListBarChartProps {
+    const { width, height, formData, queriesData } = chartProps;
+
+    // Extract values using camelCase (Superset converts snake_case control 
names to camelCase)
+    const {
+        keyColumn,
+        keySubColumn,
+        secondaryColumns,
+        metricColumn,
+        maxMetricColumn,
+        severityColumn,
+        colorColumn,
+        rowsPerItem = '2',
+        alignMetric = 'right',
+        showBar = true,
+        showMetricValue = true,
+        keyFontSize = 16,
+        keyColor,
+        keySubFontSize = 11,
+        secondaryFontSize = 12,
+        barColorPositive,
+        barColorNegative,
+        conditionalColorRules,
+        iconRules,
+    } = formData;
+
+    const data = queriesData[0].data as TimeseriesDataRecord[];
+
+    // DEBUG: Log to verify values
+    console.log('=== TRANSFORM PROPS DEBUG ===');
+    console.log('keyColumn:', keyColumn);
+    console.log('keySubColumn:', keySubColumn);
+    console.log('colorColumn:', colorColumn);
+    console.log('metricColumn:', metricColumn);
+    console.log('keyFontSize:', keyFontSize, 'secondaryFontSize:', 
secondaryFontSize);
+
+    // Extract clean column names
+    const keyColumnName = getColumnName(keyColumn);
+    const keySubColumnName = getColumnName(keySubColumn);
+    const secondaryColumnNames = 
ensureIsArray(secondaryColumns).map(getColumnName).filter(Boolean);
+    const metricColumnName = getColumnName(metricColumn);
+    const maxMetricColumnName = getColumnName(maxMetricColumn);
+    const severityColumnName = getColumnName(severityColumn);
+    const colorColumnName = getColumnName(colorColumn);
+
+    const customize: UnifiedListBarChartCustomizeProps = {
+        keyColumn: keyColumnName,
+        keySubColumn: keySubColumnName || undefined,
+        secondaryColumns: secondaryColumnNames,
+        metricColumn: metricColumnName || undefined,
+        maxMetricColumn: maxMetricColumnName || undefined,
+        severityColumn: severityColumnName || undefined,
+        colorColumn: colorColumnName || undefined,
+        rowsPerItem: rowsPerItem,
+        alignMetric: alignMetric,
+        showBar: showBar,
+        showMetricValue: showMetricValue,
+        keyFontSize: Number(keyFontSize) || 16,
+        keyColor: rgbaToString(keyColor),
+        keySubFontSize: Number(keySubFontSize) || 11,
+        secondaryFontSize: Number(secondaryFontSize) || 12,
+        barColorPositive: rgbaToString(barColorPositive),
+        barColorNegative: rgbaToString(barColorNegative),
+        conditionalColorRules: typeof conditionalColorRules === 'string'
+            ? JSON.parse(conditionalColorRules)
+            : conditionalColorRules,
+        iconRules: typeof iconRules === 'string'
+            ? JSON.parse(iconRules)
+            : iconRules,

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Unsafe JSON Parsing</b></div>
   <div id="fix">
   
   JSON.parse calls could throw if strings are malformed. Add error handling to 
prevent crashes.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
           conditionalColorRules: (() => {
               try {
                   return typeof conditionalColorRules === 'string' ? 
JSON.parse(conditionalColorRules) : conditionalColorRules;
               } catch {
                   return undefined;
               }
           })(),
           iconRules: (() => {
               try {
                   return typeof iconRules === 'string' ? JSON.parse(iconRules) 
: iconRules;
               } catch {
                   return undefined;
               }
           })(),
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #3fac3a</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



##########
docker/pythonpath_dev/superset_config.py:
##########
@@ -142,3 +142,94 @@ class CeleryConfig:
     )
 except ImportError:
     logger.info("Using default Docker config...")
+
+
+EXTRA_CATEGORICAL_COLOR_SCHEMES = [
+     {
+         "id": 'risk_meter',
+         "description": '',
+         "label": 'Rik Meter Theme RYG',
+         "colors":
+          ['#008450','#D19900','#B81D13']
+     },
+     {
+        "id": 'ey_color_palette',
+        "description": '',
+        "label": 'EY Color Palette I',
+               "isDefault": False,

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Mixed spaces and tabs indentation</b></div>
   <div id="fix">
   
   Replace mixed tabs and spaces with consistent spaces on line 159. Multiple 
similar indentation issues exist on lines 167, 175, 183, 191, 199, 207, 215, 
223, and 231.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
           "id": 'ey_color_palette',
           "description": '',
           "label": 'EY Color Palette I',
           "isDefault": False,
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #3fac3a</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



-- 
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