-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.js
45 lines (39 loc) · 1.03 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { hash } from 'rsvp';
import { assign } from '@ember/polyfills';
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
export default Route.extend({
can: service(),
model(params) {
let repositoryId = this.modelFor('repositories/show').get('id');
params = assign(params, {
page: {
number: params.page,
size: params.size,
},
'repository-id': repositoryId,
});
return hash({
repository: this.store.findRecord('repository', repositoryId),
'repository-prefixes': this.store.query('repository-prefix', params).then(function(result) {
return result;
}).catch(function(reason) {
console.debug(reason);
return [];
}),
});
},
afterModel() {
if (this.can.cannot('read repository', this.modelFor('repositories/show'))) {
this.transitionTo('index');
}
},
actions: {
queryParamsDidChange() {
this.refresh();
},
refreshCurrentRoute() {
this.refresh();
},
},
});