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:
Piotr Sarnacki 2015-11-11 17:38:47 +01:00
parent 35f95739c7
commit d636369daa
2 changed files with 13 additions and 9 deletions

View File

@ -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: ->

View File

@ -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')