bito-code-review[bot] commented on code in PR #42330: URL: https://github.com/apache/superset/pull/42330#discussion_r3636169767
########## superset-frontend/src/filters/components/CustomFilter/index.ts: ########## @@ -0,0 +1,50 @@ +/** + * 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 { t, Behavior, ChartMetadata, ChartPlugin } from '@superset-ui/core'; Review Comment: <div> <div id="suggestion"> <div id="issue"><b>Import path inconsistency</b></div> <div id="fix"> The `t` function is imported from `@superset-ui/core` on line 19, but all other filter plugins in this directory (Select, Range, TimeColumn, TimeGrain) import `t` from `@apache-superset/core/translation`. This import path inconsistency may cause build issues or unexpected behavior. </div> </div> <small><i>Code Review Run #3e7d56</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 ########## superset-frontend/src/filters/components/CustomDateFilter/CustomDateFilterPlugin.test.tsx: ########## @@ -0,0 +1,74 @@ +/** + * 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, screen } from 'spec/helpers/testing-library'; +import CustomDateFilterPlugin from './CustomDateFilterPlugin'; + +const defaultProps = { + data: [], + formData: { + groupby: ['order_date'], + controlType: 'date', + granularitySqla: 'order_date', + }, + width: 200, + height: 100, + filterState: { value: [] }, + setDataMask: jest.fn(), + setHoveredFilter: jest.fn(), + unsetHoveredFilter: jest.fn(), + setFocusedFilter: jest.fn(), + unsetFocusedFilter: jest.fn(), + setFilterActive: jest.fn(), + inputRef: { current: null }, + isRefreshing: false, + appSection: 'FILTER_BAR', +}; + +describe('CustomDateFilterPlugin', () => { + beforeEach(() => { + jest.clearAllMocks(); + }); + + test('renders date picker by default', () => { + render(<CustomDateFilterPlugin {...defaultProps} />, { useRedux: true }); + expect(screen.getByPlaceholderText('Select date')).toBeInTheDocument(); + }); + + test('renders date picker when controlType is date', () => { + render( + <CustomDateFilterPlugin + {...defaultProps} + formData={{ ...defaultProps.formData, controlType: 'date' }} + />, + { useRedux: true }, + ); + expect(screen.getByPlaceholderText('Select date')).toBeInTheDocument(); + }); + + test('renders datetime picker when controlType is datetime', () => { + render( + <CustomDateFilterPlugin + {...defaultProps} + formData={{ ...defaultProps.formData, controlType: 'datetime' }} + />, + { useRedux: true }, + ); + expect(screen.getByPlaceholderText('Select date')).toBeInTheDocument(); + }); Review Comment: <div> <div id="suggestion"> <div id="issue"><b>Semantic test duplication</b></div> <div id="fix"> Tests for date and datetime modes (lines 48-73) use identical assertions, making them semantically duplicated. The component distinguishes datetime from date via `showTime` prop, but the tests don't verify this behavioral difference. Consider adding a test that explicitly verifies the datetime mode correctly includes time in its filter output. </div> </div> <small><i>Code Review Run #3e7d56</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 ########## superset-frontend/src/filters/components/CustomDateFilter/CustomDateFilterPlugin.tsx: ########## @@ -0,0 +1,185 @@ +/** + * 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 { useCallback, useEffect, useState } from 'react'; +import { JsonObject } from '@superset-ui/core'; +import { styled } from '@apache-superset/core/theme'; +import { DatePicker } from '@superset-ui/core/components'; +import { FilterPluginStyle } from '../common'; +import { PluginFilterCustomDateFilterQueryFormData, DEFAULT_FORM_DATA } from './types'; + +interface CustomDateFilterPluginProps { + data: { [key: string]: any }[]; + formData: PluginFilterCustomDateFilterQueryFormData; + width: number; + height: number; + filterState: { value?: any[] }; + setDataMask: (arg: JsonObject) => void; + setHoveredFilter: (arg: string) => void; + unsetHoveredFilter: () => void; + setFocusedFilter: (arg: string) => void; + unsetFocusedFilter: () => void; + setFilterActive: (arg: boolean) => void; Review Comment: <div> <div id="suggestion"> <div id="issue"><b>Uncalled setFilterActive callback</b></div> <div id="fix"> The `setFilterActive` prop declared at line 37 is never invoked. Compare to `TimeColumnFilterPlugin.tsx` lines 44, 120 which correctly wires `setFilterActive` to the `onOpenChange` handler of a DatePicker. Without this callback, parent components cannot track whether this filter is active (open), which affects keyboard navigation and filter bar behavior. </div> </div> <small><i>Code Review Run #3e7d56</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]
