Skip to content

Commit 7118d66

Browse files
committed
Refactor UX for well-known crate documentation route
1 parent c14d3b1 commit 7118d66

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

app/routes/crate/docs.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,17 @@ export default Ember.Route.extend({
1111
crate = data.crate;
1212
}
1313

14-
var documentation = crate.get('documentation'),
15-
self = this;
14+
var documentation = crate.get('documentation');
1615

17-
setTimeout(function() {
18-
if (documentation) {
19-
window.location = documentation;
20-
} else {
21-
// Redirect to the crate's main page if no documentation
22-
// URL is found.
23-
self.transitionTo('crate', crate);
24-
}
25-
}, 2500);
16+
if (documentation) {
17+
window.location = documentation;
18+
} else {
19+
// Redirect to the crate's main page and show a flash error if
20+
// no documentation is found
21+
var message = 'Crate does not supply a documentation URL';
22+
this.controllerFor('application').set('nextFlashError', message);
23+
this.replaceWith('crate', crate);
24+
}
2625

2726
this._super(controller, crate);
2827
},

app/templates/crate/docs.hbs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,5 @@
44
</div>
55

66
<p>
7-
{{#if documentation}}
8-
Redirecting you to <code>{{documentation}}</code>&#8230;
9-
{{else}}
10-
<strong>{{name}}</strong> is missing a documentation URL, returning to the crate main page&#8230;
11-
{{/if}}
7+
Redirecting you to <code>{{documentation}}</code>&#8230;
128
</p>

0 commit comments

Comments
 (0)