Fix sidebar repos list
We need this list to update with pusher, so filtering is better than using store.query.
This commit is contained in:
parent
35f95739c7
commit
d636369daa
|
@ -87,14 +87,12 @@ Controller = Ember.Controller.extend
|
||||||
|
|
||||||
viewOwned: ->
|
viewOwned: ->
|
||||||
@set('isLoaded', false);
|
@set('isLoaded', false);
|
||||||
if login = @get('currentUser.login')
|
@get('currentUser._rawPermissions').then (data) =>
|
||||||
repos = Repo.accessibleBy(@store, login).then( (reposRecordArray) =>
|
repos = Repo.accessibleBy(@store, data.pull).then( (reposRecordArray) =>
|
||||||
@set('isLoaded', true)
|
@set('isLoaded', true)
|
||||||
@set('repos', reposRecordArray)
|
@set('repos', reposRecordArray)
|
||||||
)
|
)
|
||||||
# TODO: handle error
|
# TODO: handle error
|
||||||
else
|
|
||||||
@set('repos', [])
|
|
||||||
|
|
||||||
viewRunning: ->
|
viewRunning: ->
|
||||||
|
|
||||||
|
|
|
@ -118,16 +118,22 @@ Repo.reopenClass
|
||||||
recent: ->
|
recent: ->
|
||||||
@find()
|
@find()
|
||||||
|
|
||||||
accessibleBy: (store, login) ->
|
accessibleBy: (store, reposIds) ->
|
||||||
# this fires only for authenticated users and with API v3 that means getting
|
# this fires only for authenticated users and with API v3 that means getting
|
||||||
# only repos of currently logged in owner, but in the future it would be
|
# only repos of currently logged in owner, but in the future it would be
|
||||||
# nice to not use that as it may change in the future
|
# nice to not use that as it may change in the future
|
||||||
repos = store.query('repo', { 'repository.active': 'true' })
|
repos = store.filter('repo', (repo) ->
|
||||||
|
reposIds.indexOf(parseInt(repo.get('id'))) != -1
|
||||||
|
)
|
||||||
|
|
||||||
repos.then () ->
|
promise = new Ember.RSVP.Promise (resolve, reject) ->
|
||||||
repos.set('isLoaded', true)
|
store.query('repo', { 'repository.active': 'true' }).then( ->
|
||||||
|
resolve(repos)
|
||||||
|
, ->
|
||||||
|
reject()
|
||||||
|
)
|
||||||
|
|
||||||
repos
|
promise
|
||||||
|
|
||||||
search: (store, query) ->
|
search: (store, query) ->
|
||||||
promise = store.query('repo', search: query, orderBy: 'name')
|
promise = store.query('repo', search: query, orderBy: 'name')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user