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

[9382][FRONT]: Compute highlighted object view using raw name plural #9394

Merged
merged 2 commits into from
Jan 7, 2025

Conversation

prastoin
Copy link
Contributor

@prastoin prastoin commented Jan 6, 2025

Introduction

Please find related ticket here #9382
To fix the issue the solution seems to be to stop searching for last viewed objectMetadata using their slugged version namePlural

Upcoming cleanup

After discussing with @charlesBochet it seems like a bad practice to slug the objectMetadata, in this way in a following PR we will suggest a cleanup of the remaining method that does within the useFilteredObjectMetadataItems.ts

Conclusion

As always any suggestions are welcomed !
Please let me know

closes #9382

@prastoin prastoin marked this pull request as ready for review January 6, 2025 14:58
@prastoin prastoin marked this pull request as draft January 6, 2025 14:58
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 modifies the object metadata lookup strategy to use direct plural names instead of slugified versions, fixing navigation highlighting issues for multi-word object names.

  • Added findActiveObjectMetadataItemByNamePlural in /packages/twenty-front/src/modules/object-metadata/hooks/useFilteredObjectMetadataItems.ts for direct name matching
  • Replaced slug-based lookups with findActiveObjectMetadataItemByNamePlural in /packages/twenty-front/src/modules/navigation/hooks/useLastVisitedView.ts
  • Maintains backward compatibility by keeping slug methods temporarily, with plans for future cleanup
  • Fixes active view highlighting when object names contain spaces (e.g., "Guillim's Board")

💡 (1/5) You can manually trigger the bot by mentioning @greptileai in a comment!

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

@prastoin
Copy link
Contributor Author

prastoin commented Jan 7, 2025

Note

I'm not sure on the way to handle this, maybe the issue isn't the slugification itself but more the fact that we use a findFromSlug method while not providing a slug argument.
In my opinion we could either:

  • Sluggify directly within the findActiveObjectMetadataItemBySlug
  • Fix findActiveObjectMetadataItemBySlug call that do not provide sluggified args.

For instance:

 const findActiveObjectMetadataItemBySlug = (slug: string) =>{
    console.log(slug, activeObjectMetadataItems.map(({namePlural}) => namePlural));
    return activeObjectMetadataItems.find(
      (activeObjectMetadataItem) =>
        getObjectSlug(activeObjectMetadataItem) === toKebabCase(slug),
    );}

In the other hand we might wanna just get rid of the whole slug mechanics for Objects as it's overkilled

EDIT:

=> We decided with @charlesBochet to get rid of sluggication completely regarding Object and Field

@prastoin prastoin marked this pull request as ready for review January 7, 2025 14:14
@prastoin prastoin self-assigned this Jan 7, 2025
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

(updates since last review)

No significant changes found since the last review. The core changes were already covered in the previous review, which accurately described the switch from slugified to direct plural name matching for object metadata lookups.

The remaining changes appear to be minor code formatting adjustments that don't impact functionality.

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

@charlesBochet charlesBochet merged commit 7b70f7d into main Jan 7, 2025
23 checks passed
@charlesBochet charlesBochet deleted the 9382-activite-object-highlight-slug branch January 7, 2025 14:21
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.

Active view highlight is not working when object name contains multiple words
2 participants