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

fix: record group issues #8854

Merged
merged 4 commits into from
Dec 4, 2024
Merged

fix: record group issues #8854

merged 4 commits into from
Dec 4, 2024

Conversation

magrinj
Copy link
Member

@magrinj magrinj commented Dec 3, 2024

This PR is fixing the following issues with record groups:

  • [Backend] - Only update view groups when a field is edited if this one already has view groups
  • [Backend] - Editing a Select field metadata option brake view groups
  • [Frontend] - Changing the group by field from one to another brake record group and doesn't remove the previous ones
  • [Frontend & Backend] - Mark kanbanFieldMetadataId as deprecated in favour of viewGroups.fieldMetadataId

Also the following has been checked:

  • Properly displayed a table with only one view groups
  • Properly displayed a table without view groups

@magrinj magrinj force-pushed the fix/record-group-issues branch from 6200f28 to 7a8fa12 Compare December 3, 2024 16:04
@magrinj magrinj requested a review from charlesBochet December 3, 2024 16:06
@Weiko Weiko marked this pull request as ready for review December 4, 2024 14:37
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 addresses record group functionality issues by deprecating kanbanFieldMetadataId and implementing proper group field handling across frontend and backend.

  • Added transaction support in field-metadata-related-records.service.ts for data consistency
  • Improved view group cleanup in useHandleRecordGroupField.ts when switching group-by fields
  • Added skip logic for views without groups in field-metadata-related-records.service.ts
  • Fixed Select field metadata option handling to prevent view group breakage
  • Marked kanbanFieldMetadataId as deprecated across types with proper JSDoc comments

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

@@ -18,6 +18,9 @@ export type View = {
viewFilters: ViewFilter[];
viewFilterGroups?: ViewFilterGroup[];
viewSorts: ViewSort[];
/**
* @deprecated Use `viewGroups.fieldMetadataId` instead.
*/
kanbanFieldMetadataId: string;
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 making kanbanFieldMetadataId optional since it's deprecated

@@ -84,6 +84,9 @@ export class ViewWorkspaceEntity extends BaseWorkspaceEntity {
label: 'kanbanfieldMetadataId',
Copy link
Contributor

Choose a reason for hiding this comment

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

style: label should be 'Kanban Field Metadata Id' to match standard casing

Comment on lines 94 to +102
const valuesToDelete = deleted.map((option) => option.value);

await viewGroupRepository.delete({
fieldMetadataId: newFieldMetadata.id,
fieldValue: In(valuesToDelete),
});
await viewGroupRepository.delete(
{
fieldMetadataId: newFieldMetadata.id,
fieldValue: In(valuesToDelete),
},
transactionManager,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

style: check if valuesToDelete is empty before performing delete operation to avoid unnecessary database calls

Comment on lines +76 to +78
const viewGroupsToDelete = view.viewGroups.filter(
(group) => group.fieldMetadataId !== fieldMetadataItem.id,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: this filter removes all groups from other fields, which means switching back to a previous field will lose any customizations made to those groups

Comment on lines 80 to +86
if (viewGroupsToCreate.length > 0) {
await createViewGroupRecords(viewGroupsToCreate, view);
}

if (viewGroupsToDelete.length > 0) {
await deleteViewGroupRecords(viewGroupsToDelete);
}
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 order of operations here could cause a brief visual flicker - consider deleting old groups before creating new ones

@charlesBochet
Copy link
Member

LGTM!

@charlesBochet charlesBochet merged commit 2fa5fb7 into main Dec 4, 2024
11 of 18 checks passed
@charlesBochet charlesBochet deleted the fix/record-group-issues branch December 4, 2024 15:03
mdrazak2001 pushed a commit to mdrazak2001/twenty that referenced this pull request Dec 4, 2024
This PR is fixing the following issues with record groups:

- [x] [Backend] - Only update view groups when a field is edited if this
one already has view groups
- [x] [Backend] - Editing a Select field metadata option brake view
groups
- [x] [Frontend] - Changing the group by field from one to another brake
record group and doesn't remove the previous ones
- [x] [Frontend & Backend] - Mark `kanbanFieldMetadataId` as deprecated
in favour of `viewGroups.fieldMetadataId`

Also the following has been checked:

- [x] Properly displayed a table with only one view groups
- [x] Properly displayed a table without view groups
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants