Skip to content
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

Merged
merged 12 commits into from
Jan 10, 2025
Merged

Aggregate follow-up #9547

merged 12 commits into from
Jan 10, 2025

Conversation

ijreilly
Copy link
Collaborator

@ijreilly ijreilly commented Jan 10, 2025

In this PR

  1. Menu should keep selected when the menu is open
  2. Cropping
  3. Put earliest date / latest date in a separate "Date" submenu
  • Refactor around date aggregate operations

Copy link
Contributor

@greptile-apps greptile-apps bot left a 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 with ExtendedAggregateOperations 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

Comment on lines 12 to 13
toggleDropdown();
resetFilterDropdown();
Copy link
Contributor

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

Comment on lines +49 to +52
[
DATE_AGGREGATE_OPERATIONS.earliest,
DATE_AGGREGATE_OPERATIONS.latest,
],
Copy link
Contributor

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

Comment on lines +65 to +69
if (
COUNT_AGGREGATE_OPERATION_OPTIONS.includes(
aggregateOperation as AGGREGATE_OPERATIONS,
)
) {
Copy link
Contributor

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

Comment on lines +141 to +149
const convertedViewFieldAggregateOperation = isDefined(
viewField.aggregateOperation,
)
? convertAggregateOperationToExtendedAggregateOperation(
viewField.aggregateOperation,
viewFieldMetadataType,
)
: viewField.aggregateOperation;

Copy link
Contributor

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

Comment on lines +2 to +3
earliest = 'EARLIEST',
latest = 'LATEST',
Copy link
Contributor

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

Comment on lines 19 to 20
if (isDefined(allAggregations[field.name])) {
Object.keys(allAggregations[field.name]).forEach((aggregation) => {
Copy link
Contributor

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) {
Copy link
Contributor

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

Comment on lines 12 to 17
if (aggregateOperation === AGGREGATE_OPERATIONS.min) {
return 'EARLIEST';
return DATE_AGGREGATE_OPERATIONS.earliest;
}
if (aggregateOperation === AGGREGATE_OPERATIONS.max) {
return 'LATEST';
return DATE_AGGREGATE_OPERATIONS.latest;
}
Copy link
Contributor

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

Comment on lines +33 to +36
type StyledHeaderDivProps = {
isUnfolded?: boolean;
isActive?: boolean;
};
Copy link
Contributor

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';
Copy link
Contributor

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

Copy link
Member

@Weiko Weiko left a 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 = () => {
}
Copy link
Member

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?

Copy link
Collaborator Author

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

@ijreilly ijreilly enabled auto-merge (squash) January 10, 2025 18:48
@charlesBochet charlesBochet merged commit 2e0169b into main Jan 10, 2025
31 of 33 checks passed
@charlesBochet charlesBochet deleted the aggregate-follow-up-4 branch January 10, 2025 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants