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


##########
superset-frontend/src/explore/components/DataTablesPane/components/useGridResultTable.tsx:
##########
@@ -37,10 +37,28 @@ export function useGridColumns(
             .filter((column: string) => Object.keys(data[0]).includes(column))
             .map((key, index) => {
               const colType = coltypes?.[index];
-              const headerLabel = columnDisplayNames?.[key] ?? key;
+
+              const rawHeader = columnDisplayNames?.[key] ?? key;
+              let cleanHeader = rawHeader;
+
+              try {
+                let jsonToParse = rawHeader;
+                let suffix = '';
+
+                if (rawHeader.endsWith('__contribution')) {
+                  jsonToParse = rawHeader.replace('__contribution', '');
+                  suffix = ' (contribution)';
+                }
+
+                const parsed = JSON.parse(jsonToParse);
+                if (parsed && typeof parsed === 'object' && parsed.label) {
+                  cleanHeader = `${parsed.label}${suffix}`;
+                }
+              } catch (_) {}

Review Comment:
   Test coverage was added in DataTablesPane.test.tsx covering the JSON parsing 
and contribution-suffix logic: plain columns, `revenue__contribution`, 
JSON-encoded metric keys, and JSON metric + contribution suffix all assert the 
rendered header. Resolving as addressed.



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