codeant-ai-for-open-source[bot] commented on code in PR #43275: URL: https://github.com/apache/superset/pull/43275#discussion_r3799891482
########## superset-frontend/src/dashboard/components/gridComponents/new/NewFilterComponent.test.tsx: ########## @@ -0,0 +1,46 @@ +/** + * 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 { render } from 'spec/helpers/testing-library'; +import NewFilterComponent from 'src/dashboard/components/gridComponents/new/NewFilterComponent'; +import { NEW_FILTER_ID } from 'src/dashboard/util/constants'; +import { FILTER_TYPE } from 'src/dashboard/util/componentTypes'; + +jest.mock( + 'src/dashboard/components/gridComponents/new/DraggableNewComponent', + () => + ({ type, id }: { type: string; id: string }) => ( + <div data-test="mock-draggable-new-component">{`${type}:${id}`}</div> + ), Review Comment: **Suggestion:** The mock sets `data-test`, but Testing Library's `getByTestId` searches for `data-testid`, so both tests fail to find the rendered element. Use the attribute recognized by `getByTestId` or query the existing attribute explicitly. [api mismatch] <details> <summary><b>Severity Level:</b> Major ⚠️</summary> ```mdx - ❌ NewFilterComponent tests fail during test execution. - ⚠️ CI cannot verify filter-card rendering behavior. ``` </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=2ee1e48692504562ae4b4a7db4283148&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=2ee1e48692504562ae4b4a7db4283148&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) <details> <summary><b>Prompt for AI Agent 🤖 </b></summary> ```mdx This is a comment left during a code review. **Path:** superset-frontend/src/dashboard/components/gridComponents/new/NewFilterComponent.test.tsx **Line:** 27:29 **Comment:** *Api Mismatch: The mock sets `data-test`, but Testing Library's `getByTestId` searches for `data-testid`, so both tests fail to find the rendered element. Use the attribute recognized by `getByTestId` or query the existing attribute explicitly. 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. Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43275&comment_hash=60d80a5037c5292a307e2ad3d3174759245f41526db55af870a52bf3a025f1f1&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43275&comment_hash=60d80a5037c5292a307e2ad3d3174759245f41526db55af870a52bf3a025f1f1&reaction=dislike'>👎</a> ########## superset-frontend/src/filters/components/DateTimeFilter/controlPanel.ts: ########## @@ -0,0 +1,67 @@ +/** + * 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 { + ControlPanelConfig, + sharedControls, +} from '@superset-ui/chart-controls'; +import { t } from '@apache-superset/core/translation'; + +const config: ControlPanelConfig = { + // For control input types, see: superset-frontend/src/explore/components/controls/index.js + controlPanelSections: [ + { + label: t('Query'), + expanded: true, + controlSetRows: [ + [ + { + name: 'groupby', + config: { + ...sharedControls.groupby, + label: t('Column'), + required: true, + }, + }, + ], + ], + }, + { + label: t('UI Configuration'), + expanded: true, + controlSetRows: [ + [ + { + name: 'enableEmptyFilter', + config: { + type: 'CheckboxControl', + label: t('Filter value is required'), + default: false, + renderTrigger: true, + description: t( + 'User must select a value before applying the filter', + ), + }, + }, Review Comment: **Suggestion:** This control exposes a “Filter value is required” setting, but the DateTime filter implementation does not read `enableEmptyFilter` or enforce a non-empty selection. Changing this checkbox therefore has no runtime effect and misleads users configuring the filter; either implement the validation or remove the control. [incomplete implementation] <details> <summary><b>Severity Level:</b> Major ⚠️</summary> ```mdx - ❌ Required DateTime filters accept empty selections. - ⚠️ Dashboard authors receive misleading validation configuration. ``` </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=f2892e12dc7c44808951c84f8c2f73ab&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=f2892e12dc7c44808951c84f8c2f73ab&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) <details> <summary><b>Prompt for AI Agent 🤖 </b></summary> ```mdx This is a comment left during a code review. **Path:** superset-frontend/src/filters/components/DateTimeFilter/controlPanel.ts **Line:** 50:60 **Comment:** *Incomplete Implementation: This control exposes a “Filter value is required” setting, but the DateTime filter implementation does not read `enableEmptyFilter` or enforce a non-empty selection. Changing this checkbox therefore has no runtime effect and misleads users configuring the filter; either implement the validation or remove the control. 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. Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43275&comment_hash=5b9cb425230e0ebbc270447960dbd0cc90bbc804282a14683e1f2b0a3529c166&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43275&comment_hash=5b9cb425230e0ebbc270447960dbd0cc90bbc804282a14683e1f2b0a3529c166&reaction=dislike'>👎</a> ########## superset-frontend/src/filters/components/CustomControls/transformProps.ts: ########## @@ -0,0 +1,107 @@ +/** + * 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 } from '@superset-ui/core'; +import { + CustomControlsTransformedProps, + PluginFilterCustomControlsQueryFormData, +} from './types'; + +export default function transformProps( + chartProps: ChartProps, +): CustomControlsTransformedProps { + const { + width, + height, + formData = {}, + queriesData, + hooks = {}, + filterState, + displaySettings, + theme, + } = chartProps; + const { setDataMask = () => {} } = hooks; + + const customControlsFormData = + formData as PluginFilterCustomControlsQueryFormData; + const controlValues = + (customControlsFormData.controlValues as Record<string, unknown>) || {}; + + const rawGroupby = (formData as Record<string, unknown>).groupby; + const groupbyCol = Array.isArray(rawGroupby) ? rawGroupby[0] : rawGroupby; + + const filterColumn = + (formData.targets as Array<{ column?: { name?: string } }>)?.[0]?.column + ?.name || + (typeof groupbyCol === 'string' ? groupbyCol : undefined) || Review Comment: **Suggestion:** When `groupby` contains a custom SQL column object, `groupbyCol` is an object and this logic discards it instead of extracting its label, column name, or SQL expression. Since no later fallback is necessarily present, `filterColumn` becomes undefined, leaving the control with no options and preventing the filter from working for custom SQL dimensions. Normalize object-valued groupby entries the same way as the query builder. [logic error] <details> <summary><b>Severity Level:</b> Major ⚠️</summary> ```mdx - ❌ Custom SQL dimension filters render without selectable options. - ⚠️ Canvas filter configuration fails for adhoc groupby columns. ``` </details> [](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=792ba568f1534a889976a3d1c9345e73&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) [](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=792ba568f1534a889976a3d1c9345e73&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset) <details> <summary><b>Prompt for AI Agent 🤖 </b></summary> ```mdx This is a comment left during a code review. **Path:** superset-frontend/src/filters/components/CustomControls/transformProps.ts **Line:** 45:51 **Comment:** *Logic Error: When `groupby` contains a custom SQL column object, `groupbyCol` is an object and this logic discards it instead of extracting its label, column name, or SQL expression. Since no later fallback is necessarily present, `filterColumn` becomes undefined, leaving the control with no options and preventing the filter from working for custom SQL dimensions. Normalize object-valued groupby entries the same way as the query builder. 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. Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix ``` </details> <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43275&comment_hash=5c0412f511da41bb2e74191d65d8389f1125128582de217220e6b1b62323e140&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43275&comment_hash=5c0412f511da41bb2e74191d65d8389f1125128582de217220e6b1b62323e140&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]
