Skip to content
This repository has been archived by the owner on Nov 9, 2021. It is now read-only.

Use router infos for crumb generation to support resetNamespace #64

Conversation

ivanvanderbyl
Copy link
Contributor

This PR is potentially a breaking change.

Previously, using resetNamespace would break the crumb chain because we only checked the currentRouteName for tokens to generate crumbs from. The currentRouteName doesn't include anything before a resetNamespace.

To fix this I've used the router's handlerInfos to build a list of all active route names, then removed any which weren't part of the currentPath.

While implementing this change it occurred to me that the current implementation is possibly incorrect, to explain this let's assume we have the following route paths active:

[foo, foo.bar, foo.bar.baz]

In the current implementation is would look for an index route at the start by attempting a lookup on foo.index, if it's implemented. So the lookup paths are: [foo.index, foo.bar, foo.bar.baz]([see tests]%28https://github.com/poteto/ember-crumbly/blob/develop/tests/acceptance/integration-test.js#L148%29). This behaviour is unexpected because foo.index isn't active, but foo is.

I believe the correct lookup should be: [foo, foo.bar, foo.bar.baz.index], because we're in the index route.

Was there a design decision around this that I've missed completely?

This PR also includes the isTail and isHead functionality from #51

This allows customisation of first and last crumb, for specific cases where you might want to do things differently, i.e. make the last route a dropdown menu like on Google Drive.
@homu
Copy link
Collaborator

homu commented Feb 24, 2016

☔ The latest upstream changes (presumably #63) made this pull request unmergeable. Please resolve the merge conflicts.

# Conflicts:
#	addon/components/bread-crumbs.js
Refactored to use handler infos

Refactored to use handler infos for path generation

Refactored to declare index route only if entered

Fixed default title and reverted to using index on tail only

First route should not be index

Bar route should be linkable
@ivanvanderbyl ivanvanderbyl force-pushed the use-router-infos-for-crumb-generation branch from 62857ad to c318be0 Compare February 24, 2016 20:13
@ivanvanderbyl
Copy link
Contributor Author

I fixed those merge conflicts

@dguettler
Copy link
Collaborator

@ivanvanderbyl could you rebase this against master

@dguettler
Copy link
Collaborator

@ivanvanderbyl closing this PR to avoid future confusion about branches. Can you please reopen against master - Thank you

@dguettler dguettler closed this Oct 17, 2016
@cbou
Copy link

cbou commented Jan 23, 2019

This PR is quite old... Is resetNamespace supported by the plugin?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants