-
Notifications
You must be signed in to change notification settings - Fork 649
Add support for reverse dependencies. #69
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import Dependency from 'cargo/models/dependency'; | ||
|
||
export default Dependency; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may not be quite what we want because this means that the caches aren't shared, I'll comment above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does sharing the caches make sense, dependencies and reverse dependencies refer to different things? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More caching in the sense that if we've already fetched the information for dependency 5 there's no need to re-fetch the information just because it's a reverse dependency (it'll be the same information). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the information is slightly different: if (I'm almost certainly misunderstanding what you mean.) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import Ember from 'ember'; | ||
import Crate from 'cargo/models/crate'; | ||
|
||
export default Ember.Route.extend({ | ||
afterModel: function(data) { | ||
console.log("afterModel"); | ||
if (data instanceof Crate) { | ||
return data.get('reverse_dependencies'); | ||
} else { | ||
return data.crate.get('reverse_dependencies'); | ||
} | ||
}, | ||
|
||
setupController: function(controller, data) { | ||
if (data instanceof Crate) { | ||
data = {crate: data, reverse_dependencies: null}; | ||
} | ||
this._super(controller, data.crate); | ||
}, | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<div class='all-versions-back'> | ||
{{#link-to 'crate' this}}⬅ Back to Main Page{{/link-to}} | ||
</div> | ||
|
||
<div class='info'> | ||
<span class='small'> | ||
All <span class='num'>{{ reverse_dependencies.length }}</span> | ||
reverse dependencies of <span class='num'>{{ name }}</span> | ||
</span> | ||
</div> | ||
|
||
<div id='crate-all-reverse-dependencies' class='white-rows'> | ||
{{#each model.reverse_dependencies}} | ||
<div class='row'> | ||
<div> | ||
{{#link-to 'crate' crate_id}}{{crate_id}}{{/link-to}} requires {{req}} | ||
{{#link-to 'crate' this}}{{ num }}{{/link-to}} | ||
</div> | ||
{{#link-to 'crate' this class='arrow'}} | ||
<img src="/assets/right-arrow-all-versions.png"/> | ||
{{/link-to}} | ||
</div> | ||
{{/each}} | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here should should be able to reuse the same model like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I basically just poked at things until they worked, I started with that, but it didn't work, so I cargo-culted from the other files here. I don't yet know what I'm doing when it comes to Ember.
If I change to
reverse_dependencies: DS.hasMany('dependency', {async: true})
& delete the reverse dependencies model I get:If I leave the
reverse-dependency.js
model and just change this line I get:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting! (this may be out of my ember-knowledge territory)
The line above:
makes me think that this should work, but I'm not entirely sure why, I'll try to investigate.