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

[2.x] Rename NavItem fields to normalize its API #1600

Merged
merged 5 commits into from
Mar 1, 2024

Conversation

caendesilva
Copy link
Member

@caendesilva caendesilva commented Mar 1, 2024

Changes

Makes some breaking changes to the NavItem class.

Rename protected $destination property to $route

Breaking: Rename NavItem method getDestination to getRoute

Since the destination property in v2 is normalized to always be a route it no longer makes sense to have a divergent name for it.

Breaking: Rename NavItem method isCurrent to isActive

While the method is implemented by using the currentRoute helper, the actual end usage is to compare active state, so it makes more sense for this to use that in the name.

Breaking: Rename NavItem method getGroup to getGroupIdentifier

Renames getGroup() to getGroupIdentifier() to clarify the purpose of the method.

Breaking: Rename NavItem method getLink to getUrl

Renames getLink() to getUrl() for clarity on what the method returns.

Since the destination property in v2 is normalized to always be a route it no longer makes sense to have a divergent name for it.
Copy link

codecov bot commented Mar 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.95%. Comparing base (3d4f837) to head (f17a412).

❗ Current head f17a412 differs from pull request most recent head 9646b5b. Consider uploading reports for the commit 9646b5b to get more accurate results

Additional details and impacted files
@@                       Coverage Diff                        @@
##             improved-navigation-internals    #1600   +/-   ##
================================================================
  Coverage                            99.95%   99.95%           
  Complexity                            1775     1775           
================================================================
  Files                                  183      183           
  Lines                                 4801     4801           
================================================================
  Hits                                  4799     4799           
  Misses                                   2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

While the method is implemented by using the `currentRoute` helper, the actual end usage is to compare active state, so it makes more sense for this to use that in the name.

   - `isActive()` is more common and may be more intuitive to other developers, as it explicitly suggests that the method is checking if the item is active.
   - `isCurrent()` is also clear, but it might be slightly less common in this context. It still conveys the intended meaning effectively.
@caendesilva caendesilva marked this pull request as ready for review March 1, 2024 14:40
Renames `getGroup()` to `getGroupIdentifier()` to clarify the purpose of the method.
Renames `getLink()` to `getUrl()` for clarity on what the method returns.
@caendesilva caendesilva merged commit 3bc2e1c into improved-navigation-internals Mar 1, 2024
6 checks passed
@caendesilva caendesilva deleted the rename-navitem-fields branch March 1, 2024 20:09
@caendesilva caendesilva mentioned this pull request Jun 27, 2024
74 tasks
@caendesilva caendesilva added this to the v2 milestone Jul 9, 2024
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