-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Aggregate follow-up #9547
Aggregate follow-up #9547
Conversation
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.
PR Summary
This PR introduces significant changes to the aggregate operations system, particularly focusing on date-specific operations and UI improvements.
- Added dedicated 'Dates' submenu in aggregate dropdowns for earliest/latest date operations via new
DATE_AGGREGATE_OPERATIONS
enum - Replaced
AGGREGATE_OPERATIONS
withExtendedAggregateOperations
type across components for better type safety - Fixed sticky positioning and styling for aggregate footer in tables with proper shadow effects
- Added visual selection indicator for 'None' option in aggregate menus
- Improved dropdown header styling to maintain selected state when menu is open
45 file(s) reviewed, 22 comment(s)
Edit PR Review Bot Settings | Greptile
toggleDropdown(); | ||
resetFilterDropdown(); |
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.
style: toggling dropdown before resetting could cause visual glitches - consider resetting first
[ | ||
DATE_AGGREGATE_OPERATIONS.earliest, | ||
DATE_AGGREGATE_OPERATIONS.latest, | ||
], |
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.
style: Consider using DATE_AGGREGATE_OPERATIONS as an array directly rather than hardcoding array elements to avoid potential sync issues if new operations are added
if ( | ||
COUNT_AGGREGATE_OPERATION_OPTIONS.includes( | ||
aggregateOperation as AGGREGATE_OPERATIONS, | ||
) | ||
) { |
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.
logic: type assertion here could mask potential type mismatches between ExtendedAggregateOperations and AGGREGATE_OPERATIONS
const convertedViewFieldAggregateOperation = isDefined( | ||
viewField.aggregateOperation, | ||
) | ||
? convertAggregateOperationToExtendedAggregateOperation( | ||
viewField.aggregateOperation, | ||
viewFieldMetadataType, | ||
) | ||
: viewField.aggregateOperation; | ||
|
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.
logic: convertAggregateOperationToExtendedAggregateOperation is called even when viewFieldMetadataType is undefined, which could cause runtime errors
earliest = 'EARLIEST', | ||
latest = 'LATEST', |
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.
style: consider using lowercase enum values ('earliest' instead of 'EARLIEST') to match TypeScript conventions, since these are string enums
if (isDefined(allAggregations[field.name])) { | ||
Object.keys(allAggregations[field.name]).forEach((aggregation) => { |
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.
style: Accessing allAggregations[field.name] twice - once for isDefined check and once for Object.keys. Consider storing in a variable.
@@ -9,10 +10,10 @@ export const convertAggregateOperationToExtendedAggregateOperation = ( | |||
): ExtendedAggregateOperations => { | |||
if (isFieldMetadataDateKind(fieldType) === true) { |
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.
style: explicit comparison with true is redundant, could be simplified to just if (isFieldMetadataDateKind(fieldType))
if (aggregateOperation === AGGREGATE_OPERATIONS.min) { | ||
return 'EARLIEST'; | ||
return DATE_AGGREGATE_OPERATIONS.earliest; | ||
} | ||
if (aggregateOperation === AGGREGATE_OPERATIONS.max) { | ||
return 'LATEST'; | ||
return DATE_AGGREGATE_OPERATIONS.latest; | ||
} |
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.
style: consider using a switch statement for better readability and maintainability when handling multiple cases
type StyledHeaderDivProps = { | ||
isUnfolded?: boolean; | ||
isActive?: boolean; | ||
}; |
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.
style: isActive prop is defined but never used in the component
@@ -1,37 +1,56 @@ | |||
import { DropdownContent } from '@/ui/layout/dropdown/components/DropdownContent'; | |||
import { DropdownOnToggleEffect } from '@/ui/layout/dropdown/components/DropdownOnToggleEffect'; | |||
import { DropdownComponentInstanceContext } from '@/ui/layout/dropdown/contexts/DropdownComponeInstanceContext'; |
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.
syntax: 'DropdownComponeInstanceContext' contains a typo in the import path ('Compone' should be 'Component')
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.
LGTM! Good job 👏
@@ -125,6 +127,9 @@ export const RecordIndexContainer = () => { | |||
} |
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.
Seems there is duplicated logic between packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexTableContainerEffect.tsx and packages/twenty-front/src/modules/object-record/record-index/components/RecordIndexContainer.tsx
Should we create a shared hook for that?
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.
taking a note of that. I may refactor this part again as we discussed (in a later PR), to handle the conversions in the back-end, which would make that logic disappear
In this PR