-
Notifications
You must be signed in to change notification settings - Fork 16.4k
feat(explore): add interactive table query building with SQL visibility #36772
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
76c49ef
a1ea1af
4b2e6d1
ab04af5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -53,7 +53,8 @@ import { SearchOutlined } from '@ant-design/icons'; | |||||
| import { debounce, isEqual } from 'lodash'; | ||||||
| import Pagination from './components/Pagination'; | ||||||
| import SearchSelectDropdown from './components/SearchSelectDropdown'; | ||||||
| import { SearchOption, SortByItem } from '../types'; | ||||||
| import { SearchOption, SortByItem, TableChartFormData } from '../types'; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: The three identifiers Severity Level: Minor
Suggested change
Why it matters? ⭐Those identifiers are used only as TypeScript types in this file (props and related types). Converting to Prompt for AI Agent 🤖This is a comment left during a code review.
**Path:** superset-frontend/plugins/plugin-chart-ag-grid-table/src/AgGridTable/index.tsx
**Line:** 56:56
**Comment:**
*Type Error: The three identifiers `SearchOption`, `SortByItem`, and `TableChartFormData` are types; importing them as runtime values may cause bundling/runtime problems if they are exported only as types. Change this to a type-only import to ensure the import is erased during compilation.
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. |
||||||
| import { HandlerFunction } from '@superset-ui/core'; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Importing Severity Level: Minor
Suggested change
Why it matters? ⭐This is a valid, useful change — HandlerFunction is only used as a prop type in this file, so using Prompt for AI Agent 🤖This is a comment left during a code review.
**Path:** superset-frontend/plugins/plugin-chart-ag-grid-table/src/AgGridTable/index.tsx
**Line:** 57:57
**Comment:**
*Type Error: Importing `HandlerFunction` as a value import can cause runtime bundling/import issues if `HandlerFunction` is exported only as a TypeScript type (not a runtime value). Use a type-only import to ensure the import is erased at compile time and avoid potential runtime errors.
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. |
||||||
| import getInitialSortState, { shouldSort } from '../utils/getInitialSortState'; | ||||||
| import { PAGE_SIZE_OPTIONS } from '../consts'; | ||||||
|
|
||||||
|
|
@@ -102,6 +103,8 @@ export interface AgGridTableProps { | |||||
| onColumnStateChange?: (state: AgGridChartStateWithMetadata) => void; | ||||||
| gridRef?: RefObject<AgGridReact>; | ||||||
| chartState?: AgGridChartState; | ||||||
| setControlValue?: HandlerFunction; | ||||||
| formData?: TableChartFormData; | ||||||
| } | ||||||
|
|
||||||
| ModuleRegistry.registerModules([AllCommunityModule, ClientSideRowModelModule]); | ||||||
|
|
@@ -138,6 +141,8 @@ const AgGridDataTable: FunctionComponent<AgGridTableProps> = memo( | |||||
| width, | ||||||
| onColumnStateChange, | ||||||
| chartState, | ||||||
| setControlValue, | ||||||
| formData, | ||||||
| }) => { | ||||||
| const gridRef = useRef<AgGridReact>(null); | ||||||
| const inputRef = useRef<HTMLInputElement>(null); | ||||||
|
|
@@ -520,6 +525,8 @@ const AgGridDataTable: FunctionComponent<AgGridTableProps> = memo( | |||||
| serverPaginationData?.sortBy || [], | ||||||
| ), | ||||||
| isActiveFilterValue, | ||||||
| setControlValue, | ||||||
| formData, | ||||||
| }} | ||||||
| /> | ||||||
| {serverPagination && ( | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -139,6 +139,28 @@ export const MenuContainer = styled.div` | |||||
| background-color: ${theme.colorBorderSecondary}; | ||||||
| margin: ${theme.sizeUnit}px 0; | ||||||
| } | ||||||
|
|
||||||
| .menu-submenu { | ||||||
| position: relative; | ||||||
|
|
||||||
| .submenu { | ||||||
| display: none; | ||||||
| position: absolute; | ||||||
| left: 100%; | ||||||
| top: 0; | ||||||
| min-width: ${theme.sizeUnit * 35}px; | ||||||
| background: var(--ag-menu-background-color, ${theme.colorBgBase}); | ||||||
| border: var(--ag-menu-border, 1px solid ${theme.colorBorderSecondary}); | ||||||
| box-shadow: var(--ag-menu-shadow, ${theme.boxShadow}); | ||||||
| border-radius: ${theme.borderRadius}px; | ||||||
| padding: ${theme.sizeUnit}px 0; | ||||||
| z-index: 100; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Hardcoded stacking order: the submenu uses a fixed Severity Level: Critical 🚨
Suggested change
Why it matters? ⭐Making the z-index configurable via a CSS variable (with a sensible fallback) prevents stacking collisions Prompt for AI Agent 🤖This is a comment left during a code review.
**Path:** superset-frontend/plugins/plugin-chart-ag-grid-table/src/styles/index.tsx
**Line:** 157:157
**Comment:**
*Possible Bug: Hardcoded stacking order: the submenu uses a fixed `z-index: 100` which can collide with other components; make it configurable via a CSS variable with a sensible fallback so it can be adjusted where the menu is used.
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. |
||||||
| } | ||||||
|
|
||||||
| &:hover .submenu { | ||||||
| display: block; | ||||||
| } | ||||||
| } | ||||||
| `} | ||||||
| `; | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -469,7 +469,7 @@ const transformProps = ( | |||||
| queriesData = [], | ||||||
| ownState: serverPaginationData, | ||||||
| filterState, | ||||||
| hooks: { setDataMask = () => {}, onChartStateChange }, | ||||||
| hooks: { setDataMask = () => {}, onChartStateChange, setControlValue }, | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Destructuring Severity Level: Minor
Suggested change
Why it matters? ⭐Accurate. If chartProps.hooks is undefined, destructuring its properties will throw at runtime. Defaulting the parent object (hooks = {}) is a small, defensive change that prevents a TypeError and is safe even if the type normally guarantees hooks exists. Prompt for AI Agent 🤖This is a comment left during a code review.
**Path:** superset-frontend/plugins/plugin-chart-ag-grid-table/src/transformProps.ts
**Line:** 472:472
**Comment:**
*Null Pointer: Destructuring `hooks` directly from `chartProps` without a default for the parent object will throw if `chartProps.hooks` is undefined (TypeError: cannot destructure property of 'undefined'). Provide a default empty object for `hooks` in the destructuring so the nested defaults are applied safely.
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. |
||||||
| emitCrossFilters, | ||||||
| theme, | ||||||
| } = chartProps; | ||||||
|
|
@@ -739,6 +739,7 @@ const transformProps = ( | |||||
| formData, | ||||||
| chartState: serverPaginationData?.chartState, | ||||||
| onChartStateChange, | ||||||
| setControlValue, | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: The returned props now include Severity Level: Critical 🚨
Suggested change
Why it matters? ⭐Valid: ensuring the returned prop is always a function (coalesce to a noop) prevents consumers from having to null-check before calling it. This duplicates the safety of providing a default during destructuring, but is a safe fallback if you can't change the destructuring. Prompt for AI Agent 🤖This is a comment left during a code review.
**Path:** superset-frontend/plugins/plugin-chart-ag-grid-table/src/transformProps.ts
**Line:** 742:742
**Comment:**
*Possible Bug: The returned props now include `setControlValue` (added to the returned object) but it may be undefined; returning an undefined value that callers will invoke can cause runtime errors. Ensure the returned property is always a function by coalescing to a noop when `setControlValue` is falsy.
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. |
||||||
| }; | ||||||
| }; | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -43,6 +43,7 @@ import { | |||||
| IHeaderParams, | ||||||
| CustomCellRendererProps, | ||||||
| } from '@superset-ui/core/components/ThemedAgGridReact'; | ||||||
| import { HandlerFunction } from '@superset-ui/core'; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: Non-type import of Severity Level: Minor
Suggested change
Why it matters? ⭐HandlerFunction is only used in type positions in this file (interfaces), so switching to Prompt for AI Agent 🤖This is a comment left during a code review.
**Path:** superset-frontend/plugins/plugin-chart-ag-grid-table/src/types.ts
**Line:** 46:46
**Comment:**
*Type Error: Non-type import of `HandlerFunction` can emit a runtime import for a symbol that may only exist as a TypeScript type and not as a JS value; that can produce a runtime "undefined" import or bundler/runtime error. Import type-only declarations using `import type` to ensure no runtime import is emitted.
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. |
||||||
|
|
||||||
| export type CustomFormatter = (value: DataRecordValue) => string; | ||||||
|
|
||||||
|
|
@@ -179,6 +180,7 @@ export interface AgGridTableChartTransformedProps< | |||||
| formData: TableChartFormData; | ||||||
| onChartStateChange?: (chartState: JsonObject) => void; | ||||||
| chartState?: AgGridChartState; | ||||||
| setControlValue?: HandlerFunction; | ||||||
| } | ||||||
|
|
||||||
| export enum ColorSchemeEnum { | ||||||
|
|
@@ -194,6 +196,8 @@ export interface SortState { | |||||
| export interface CustomContext { | ||||||
| initialSortState: SortState[]; | ||||||
| onColumnHeaderClicked: (args: { column: SortState }) => void; | ||||||
| setControlValue?: HandlerFunction; | ||||||
| formData?: TableChartFormData; | ||||||
| } | ||||||
|
|
||||||
| export interface CustomHeaderParams extends IHeaderParams { | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The column interaction handlers use colId without checking if it's defined. Since colId = column?.getColId() can be undefined, this could add undefined to groupby or create invalid metrics, corrupting form data.
Code Review Run #48c584
Should Bito avoid suggestions like this for future reviews? (Manage Rules)