Merge branch 'master' into branches-redux
This commit is contained in:
commit
6d0067bdb0
|
@ -16,8 +16,8 @@ matrix:
|
|||
|
||||
fast_finish: true
|
||||
|
||||
addons:
|
||||
sauce_connect: true
|
||||
#addons:
|
||||
# sauce_connect: true
|
||||
|
||||
sudo: false
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ AddSshKeyComponent = Ember.Component.extend
|
|||
).observes('value')
|
||||
|
||||
addErrorsFromResponse: (errArr) ->
|
||||
error = errArr[0]
|
||||
error = errArr[0].detail
|
||||
if error.code == 'not_a_private_key'
|
||||
this.set('valueError', 'This key is not a private key.')
|
||||
else if error.code == 'key_with_a_passphrase'
|
||||
|
|
|
@ -1,58 +1,15 @@
|
|||
`import Ember from 'ember'`
|
||||
`import LimitedArray from 'travis/utils/limited-array'`
|
||||
|
||||
FlashDisplayComponent = Ember.Component.extend
|
||||
auth: Ember.inject.service()
|
||||
store: Ember.inject.service()
|
||||
currentUserBinding: 'auth.currentUser'
|
||||
flashes: Ember.inject.service()
|
||||
|
||||
classNames: ['flash']
|
||||
tagName: 'ul'
|
||||
|
||||
init: ->
|
||||
@_super.apply this, arguments
|
||||
@set('flashes', LimitedArray.create(limit: 1, content: []))
|
||||
|
||||
messages: (->
|
||||
broadcasts = @get('unseenBroadcasts')
|
||||
flashes = @get('flashes')
|
||||
model = []
|
||||
model.pushObjects(broadcasts) if broadcasts
|
||||
model.pushObjects(flashes.toArray().reverse()) if flashes
|
||||
model.uniq()
|
||||
).property('unseenBroadcasts.[]', 'flashes.[]', 'unseenBroadcasts.length', 'flashes.length')
|
||||
|
||||
unseenBroadcasts: (->
|
||||
@get('broadcasts').filter (broadcast) ->
|
||||
!broadcast.get('isSeen')
|
||||
).property('broadcasts.[]', 'broadcasts.length')
|
||||
|
||||
broadcasts: (->
|
||||
broadcasts = Ember.ArrayProxy.create(content: [])
|
||||
|
||||
if @get('currentUser.id')
|
||||
@get('store').find('broadcast').then (result) ->
|
||||
broadcasts.pushObjects(result.toArray())
|
||||
|
||||
broadcasts
|
||||
).property('currentUser.id')
|
||||
|
||||
loadFlashes: (msgs) ->
|
||||
for msg in msgs
|
||||
type = Object.keys(msg)[0]
|
||||
msg = { type: type, message: msg[type] }
|
||||
@get('flashes').unshiftObject(msg)
|
||||
Ember.run.later(this, (-> @get('flashes.content').removeObject(msg)), 15000)
|
||||
|
||||
close: (msg) ->
|
||||
if msg.constructor.modelName == "broadcast"
|
||||
msg.setSeen()
|
||||
@notifyPropertyChange('unseenBroadcasts')
|
||||
else
|
||||
@get('flashes').removeObject(msg)
|
||||
messagesBinding: 'flashes.messages'
|
||||
|
||||
actions:
|
||||
closeMessage: (msg) ->
|
||||
@close(msg)
|
||||
@get('flashes').close(msg)
|
||||
|
||||
`export default FlashDisplayComponent`
|
||||
|
|
5
app/controllers/error.coffee
Normal file
5
app/controllers/error.coffee
Normal file
|
@ -0,0 +1,5 @@
|
|||
`import Ember from 'ember'`
|
||||
|
||||
Controller = Ember.Controller.extend()
|
||||
|
||||
`export default Controller`
|
9
app/controllers/flash.js
Normal file
9
app/controllers/flash.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
flashes: Ember.inject.service(),
|
||||
|
||||
loadFlashes() {
|
||||
return this.get('flashes').loadFlashes(...arguments);
|
||||
}
|
||||
});
|
|
@ -8,6 +8,7 @@ initialize = (container, app) ->
|
|||
app.inject('controller', 'auth', 'auth:main')
|
||||
app.inject('application', 'auth', 'auth:main')
|
||||
app.inject('component', 'auth', 'auth:main')
|
||||
app.inject('service:flashes', 'auth', 'auth:main')
|
||||
|
||||
app.inject('auth', 'store', 'service:store')
|
||||
|
||||
|
|
|
@ -54,6 +54,12 @@ User = Model.extend
|
|||
permissions
|
||||
).property()
|
||||
|
||||
# TODO: permissions are loading asynchronously at the moment, so this should
|
||||
# be the way to return them for all types:
|
||||
pushPermissionsPromise: (->
|
||||
@get('_rawPermissions').then (data) => data.pull
|
||||
).property()
|
||||
|
||||
hasAccessToRepo: (repo) ->
|
||||
id = if repo.get then repo.get('id') else repo
|
||||
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
`import Ember from 'ember'`
|
||||
|
||||
Route = Ember.Route.extend
|
||||
activate: ->
|
||||
if @routeName != 'error'
|
||||
@controllerFor('error').set('layoutName', null)
|
||||
return @_super.apply(this, arguments)
|
||||
|
||||
beforeModel: (transition) ->
|
||||
@auth.autoSignIn() unless @signedIn()
|
||||
|
||||
|
|
10
app/routes/error.js
Normal file
10
app/routes/error.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
import TravisRoute from 'travis/routes/basic';
|
||||
|
||||
export default TravisRoute.extend({
|
||||
resetController(controller, isExiting, transition) {
|
||||
if (isExiting) {
|
||||
controller.set('message', null);
|
||||
controller.set('layoutName', null);
|
||||
}
|
||||
}
|
||||
});
|
|
@ -4,7 +4,6 @@
|
|||
`import config from 'travis/config/environment'`
|
||||
|
||||
Route = TravisRoute.extend
|
||||
|
||||
deactivate: ->
|
||||
@controllerFor('loading').set('layoutName', null)
|
||||
|
||||
|
@ -19,4 +18,17 @@ Route = TravisRoute.extend
|
|||
|
||||
@_super.apply(this, arguments)
|
||||
|
||||
actions:
|
||||
error: (error, transition, originRoute) ->
|
||||
login = transition.params.owner.owner
|
||||
message = if error.status == 404
|
||||
"Couldn't find an owner with login \"#{login}\""
|
||||
else
|
||||
"There was an error while loading data, please try again."
|
||||
|
||||
@controllerFor('error').set('layoutName', 'simple')
|
||||
@controllerFor('error').set('message', message)
|
||||
|
||||
return true
|
||||
|
||||
`export default Route`
|
||||
|
|
|
@ -43,10 +43,11 @@ Route = TravisRoute.extend
|
|||
);
|
||||
|
||||
hasPushAccess: ->
|
||||
repoId = parseInt @modelFor('repo').get('id')
|
||||
repoId = parseInt(@modelFor('repo').get('id'))
|
||||
|
||||
@auth.get('currentUser').get('pushPermissions').filter (item) ->
|
||||
item == repoId
|
||||
@auth.get('currentUser').get('pushPermissionsPromise').then (permissions) ->
|
||||
permissions.filter (item) ->
|
||||
item == repoId
|
||||
|
||||
model: () ->
|
||||
return Ember.RSVP.hash({
|
||||
|
|
51
app/services/flashes.coffee
Normal file
51
app/services/flashes.coffee
Normal file
|
@ -0,0 +1,51 @@
|
|||
`import Ember from 'ember'`
|
||||
`import LimitedArray from 'travis/utils/limited-array'`
|
||||
|
||||
FlashesService = Ember.Service.extend
|
||||
store: Ember.inject.service()
|
||||
|
||||
currentUserBinding: 'auth.currentUser'
|
||||
|
||||
init: ->
|
||||
@_super.apply this, arguments
|
||||
@set('flashes', LimitedArray.create(limit: 1, content: []))
|
||||
|
||||
messages: (->
|
||||
broadcasts = @get('unseenBroadcasts')
|
||||
flashes = @get('flashes')
|
||||
model = []
|
||||
model.pushObjects(broadcasts) if broadcasts
|
||||
model.pushObjects(flashes.toArray().reverse()) if flashes
|
||||
model.uniq()
|
||||
).property('unseenBroadcasts.[]', 'flashes.[]', 'unseenBroadcasts.length', 'flashes.length')
|
||||
|
||||
unseenBroadcasts: (->
|
||||
@get('broadcasts').filter (broadcast) ->
|
||||
!broadcast.get('isSeen')
|
||||
).property('broadcasts.[]', 'broadcasts.length')
|
||||
|
||||
broadcasts: (->
|
||||
broadcasts = Ember.ArrayProxy.create(content: [])
|
||||
|
||||
if @get('currentUser.id')
|
||||
@get('store').find('broadcast').then (result) ->
|
||||
broadcasts.pushObjects(result.toArray())
|
||||
|
||||
broadcasts
|
||||
).property('currentUser.id')
|
||||
|
||||
loadFlashes: (msgs) ->
|
||||
for msg in msgs
|
||||
type = Object.keys(msg)[0]
|
||||
msg = { type: type, message: msg[type] }
|
||||
@get('flashes').unshiftObject(msg)
|
||||
Ember.run.later(this, (-> @get('flashes.content').removeObject(msg)), 15000)
|
||||
|
||||
close: (msg) ->
|
||||
if msg.constructor.modelName == "broadcast"
|
||||
msg.setSeen()
|
||||
@notifyPropertyChange('unseenBroadcasts')
|
||||
else
|
||||
@get('flashes').removeObject(msg)
|
||||
|
||||
`export default FlashesService`
|
5
app/templates/error.hbs
Normal file
5
app/templates/error.hbs
Normal file
|
@ -0,0 +1,5 @@
|
|||
{{#if message}}
|
||||
{{message}}
|
||||
{{else}}
|
||||
There was an error, please try again.
|
||||
{{/if}}
|
|
@ -1 +0,0 @@
|
|||
|
1
app/templates/owner/error.hbs
Normal file
1
app/templates/owner/error.hbs
Normal file
|
@ -0,0 +1 @@
|
|||
foo
|
9
app/views/error.coffee
Normal file
9
app/views/error.coffee
Normal file
|
@ -0,0 +1,9 @@
|
|||
`import Ember from 'ember'`
|
||||
|
||||
View = Ember.View.extend
|
||||
layoutName: (->
|
||||
if name = @get('controller.layoutName')
|
||||
'layouts/' + name
|
||||
).property('controller.layoutName')
|
||||
|
||||
`export default View`
|
|
@ -2,8 +2,6 @@
|
|||
"framework": "qunit",
|
||||
"test_page": "tests/index.html?hidepassed",
|
||||
"launch_in_ci": [
|
||||
"SL_chrome",
|
||||
"SL_firefox",
|
||||
"PhantomJS"
|
||||
],
|
||||
"launch_in_dev": [
|
||||
|
|
Loading…
Reference in New Issue
Block a user