codeant-ai-for-open-source[bot] commented on code in PR #37109:
URL: https://github.com/apache/superset/pull/37109#discussion_r2811111317


##########
superset-frontend/src/components/Chart/DrillDetail/DrillDetailTableControls.tsx:
##########
@@ -27,13 +27,21 @@ import {
 import { css, useTheme } from '@apache-superset/core/ui';
 import RowCountLabel from 'src/components/RowCountLabel';
 import { Icons } from '@superset-ui/core/components/Icons';
+import { Tooltip } from '@superset-ui/core/components';
+import { CopyToClipboardButton } from 
'src/explore/components/DataTableControl';
+import DownloadDropdown from './DownloadDropdown';
 
 export type TableControlsProps = {
   filters: BinaryQueryObjectFilterClause[];
   setFilters: (filters: BinaryQueryObjectFilterClause[]) => void;
   totalCount?: number;
   loading: boolean;
   onReload: () => void;
+  canDownload: boolean;
+  onDownloadCSV: () => void;
+  onDownloadXLSX: () => void;
+  data?: Record<string, any>;

Review Comment:
   **Suggestion:** The `data` prop in `TableControlsProps` is typed as a single 
record, but it is passed an array of row objects from `DrillDetailPane` and 
ultimately used by `CopyToClipboardButton` as tabular data; this incorrect type 
makes the public contract misleading and can cause runtime issues if callers 
follow the type and pass a non-array, since the downstream logic expects an 
array-like structure. [type error]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ TypeScript check/build fails for Drill Detail pane.
   - ⚠️ Prop contract misleads future callers about `data` shape.
   - ⚠️ Inconsistent typing around clipboard export table data.
   ```
   </details>
   
   ```suggestion
     data?: Record<string, any>[];
   ```
   <details>
   <summary><b>Steps of Reproduction ✅ </b></summary>
   
   ```mdx
   1. Open 
`superset-frontend/src/components/Chart/DrillDetail/DrillDetailTableControls.tsx`
   and locate `TableControlsProps` at lines 34–44, where `data` is declared as 
`data?:
   Record<string, any>;`.
   
   2. Open 
`superset-frontend/src/components/Chart/DrillDetail/DrillDetailPane.tsx` 
(function
   shown between lines 96–413) and find the `data` variable defined as `const 
data:
   DataType[] = useMemo(...);` and passed into `<TableControls ... data={data} 
... />` in the
   JSX near the end of the file (around lines 360–380).
   
   3. Run the frontend type checker/build (e.g. `npm run type-check` or `npm 
run build` for
   the Superset frontend). TypeScript will report an error at the 
`TableControls` usage in
   `DrillDetailPane.tsx`, stating that type `DataType[]` is not assignable to 
parameter type
   `Record<string, any> | undefined`.
   
   4. Inspect `CopyToClipboardButton` in
   `superset-frontend/src/explore/components/DataTableControl.tsx`, which is 
imported in
   `DrillDetailTableControls.tsx` and used as `<CopyToClipboardButton 
data={data}
   columns={columnNames} />`; its props expect tabular row data (an array of 
records). This
   confirms that the intended shape of `data` is an array, and the current prop 
type is
   misleading and inconsistent with actual usage.
   ```
   </details>
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/src/components/Chart/DrillDetail/DrillDetailTableControls.tsx
   **Line:** 43:43
   **Comment:**
        *Type Error: The `data` prop in `TableControlsProps` is typed as a 
single record, but it is passed an array of row objects from `DrillDetailPane` 
and ultimately used by `CopyToClipboardButton` as tabular data; this incorrect 
type makes the public contract misleading and can cause runtime issues if 
callers follow the type and pass a non-array, since the downstream logic 
expects an array-like structure.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37109&comment_hash=d7795adc591d5624f8d6b6e46317b028e0ed029a3f1f26ee700ebccbb68f72e6&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F37109&comment_hash=d7795adc591d5624f8d6b6e46317b028e0ed029a3f1f26ee700ebccbb68f72e6&reaction=dislike'>👎</a>



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