Skip to content

Commit 9816e49

Browse files
committed
models/crate: Add defaultVersion property
1 parent bbca6ef commit 9816e49

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

app/models/crate.js

+15
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ export default class Crate extends Model {
3131
@hasMany('categories', { async: true }) categories;
3232
@hasMany('dependency', { async: true }) reverse_dependencies;
3333

34+
/**
35+
* This is the default version that will be shown when visiting the crate
36+
* details page. Note that this can be `undefined` if all versions of the crate
37+
* have been yanked.
38+
* @return {string}
39+
*/
40+
get defaultVersion() {
41+
if (this.max_stable_version) {
42+
return this.max_stable_version;
43+
}
44+
if (this.max_version && this.max_version !== '0.0.0') {
45+
return this.max_version;
46+
}
47+
}
48+
3449
follow = memberAction({ type: 'PUT', path: 'follow' });
3550
unfollow = memberAction({ type: 'DELETE', path: 'follow' });
3651

0 commit comments

Comments
 (0)