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

Implemented CRUD for view filter group and removed old states #10590

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lucasbordeau
Copy link
Contributor

This PR implements CRUD for view filter groups with the new logic as already done for view filters and view sorts.

It also completely removes the old combined view filter group states and usage.

This PR is quite big but the impact is limited since it only changes advanced filters module, which is under feature flag at the moment, and it is already in a broken state so unusable, even if someone activates the feature flag.

- Removed useDeleteCombinedViewFilterGroup
- Removed useUpsertCombinedViewFilterGroup
- Removed useResetUnsavedViewStates
- Removed useGetViewFilterGroupsCombined
- Removed unsavedToDeleteViewFilterGroupIdsComponentFamilyState
- Removed unsavedToUpsertViewFilterGroupsComponentFamilyState
- Replaced useGetCurrentView by useGetCurrentViewOnly everywhere viewFilterGroup where used
- Renamed viewFilterGroup by recordFilterGroup everywhere view isn't relevant
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 refactors the advanced filter module by replacing view filter groups with record filter groups, creating a more consistent approach to filter management.

  • Renamed properties from viewFilterGroupId to recordFilterGroupId and positionInViewFilterGroup to positionInRecordFilterGroup across multiple components
  • Removed useUpsertCombinedViewFilterGroup and useDeleteCombinedViewFilterGroup hooks in favor of direct record filter operations
  • Added new useSaveRecordFilterGroupsToViewFilterGroups hook to handle saving record filter groups to view filter groups
  • Replaced useGetCurrentView with useGetCurrentViewOnly to simplify view access without combined filters and sorts
  • Removed old Recoil state management files like unsavedToDeleteViewFilterGroupIdsComponentFamilyState and unsavedToUpsertViewFilterGroupsComponentFamilyState

54 file(s) reviewed, 6 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +138 to 140
recordFilterGroupId: newRecordFilterGroupId,
positionInRecordFilterGroup: newPositionInRecordFilterGroup,
label: defaultFieldMetadataItem.label,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: positionInRecordFilterGroup is reused here with the same value as the parent filter group position. This might cause positioning issues if multiple filters are added to the same group.


return {
currentViewFilterGroup: viewFilterGroup,
currentViewFilterGroup: currentRecordFilterGroup,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Returning currentRecordFilterGroup as currentViewFilterGroup creates type inconsistency

@@ -156,16 +156,14 @@ export const ObjectFilterDropdownFilterSelect = ({
visibleColumnsFieldMetadataItems.length > 0 &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: There's a typo in the variable name 'shoudShowSeparator' (missing 'l')

Suggested change
visibleColumnsFieldMetadataItems.length > 0 &&
const shouldShowSeparator =
visibleColumnsFieldMetadataItems.length > 0 &&

currentViewWithCombinedFiltersAndSorts?.viewFilterGroups?.map(
(viewFilter) => viewFilter.id,
currentRecordFilterGroups?.map(
(recordFilterGroup) => recordFilterGroup.id,
) ?? [];

for (const viewFilterGroupId of viewFilterGroupIds) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Variable name viewFilterGroupId should be renamed to recordFilterGroupId for consistency with the new approach.

Comment on lines 6 to 8
const changeView = async (viewId: string) => {
setViewInUrl(viewId);
resetUnsavedViewStates(viewId);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: The function is still marked as async but no longer contains any awaited operations. Consider removing the async keyword.

Suggested change
const changeView = async (viewId: string) => {
setViewInUrl(viewId);
resetUnsavedViewStates(viewId);
};
const changeView = (viewId: string) => {
setViewInUrl(viewId);
};

Comment on lines +62 to +64
const viewFilterIdsToDelete = viewFilterGroupsToDelete.map(
(viewFilter) => viewFilter.id,
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syntax: Variable name viewFilter should be viewFilterGroup to match the actual type being mapped

Suggested change
const viewFilterIdsToDelete = viewFilterGroupsToDelete.map(
(viewFilter) => viewFilter.id,
);
const viewFilterIdsToDelete = viewFilterGroupsToDelete.map(
(viewFilterGroup) => viewFilterGroup.id,
);

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.

1 participant