diff --git a/app/components/builds-item.coffee b/app/components/builds-item.coffee new file mode 100644 index 00000000..1cdd1e8e --- /dev/null +++ b/app/components/builds-item.coffee @@ -0,0 +1,12 @@ +`import Ember from 'ember'` +`import { gravatarImage } from 'travis/utils/urls'` + +BuildsItemComponent = Ember.Component.extend + classNameBindings: ['build.state'] + classNames: ['tile', 'tile--small', 'tile--build', 'row'] + + urlAuthorGravatarImage: (-> + gravatarImage(@get('build.commit.authorEmail'), 40) + ).property('build.commit.authorEmail') + +`export default BuildsItemComponent` diff --git a/app/components/requests-item.coffee b/app/components/requests-item.coffee new file mode 100644 index 00000000..a80b0d74 --- /dev/null +++ b/app/components/requests-item.coffee @@ -0,0 +1,41 @@ +`import Ember from 'ember'` +`import config from 'travis/config/environment'` + +RequestsItemComponent = Ember.Component.extend + classNames: ['tile', 'tile--jobs', 'row'] + classNameBindings: ['requestClass'] + tagName: 'li' + + requestClass: (-> + if @get('request.isAccepted') + 'accepted' + else + 'rejected' + ).property('content.isAccepted') + + type: (-> + if @get('request.isPullRequest') + 'pull_request' + else + 'push' + ).property('request.isPullRequest') + + status: (-> + if @get('request.isAccepted') + 'Accepted' + else + 'Rejected' + ).property('request.isAccepted') + + message: (-> + message = @get('request.message') + if config.pro && message == "private repository" + '' + else if !message + 'Build created successfully ' + else + message + ).property('request.message') + + +`export default RequestsItemComponent` diff --git a/app/controllers/account.coffee b/app/controllers/account.coffee index f060c8da..a922a5a8 100644 --- a/app/controllers/account.coffee +++ b/app/controllers/account.coffee @@ -1,9 +1,9 @@ `import Ember from 'ember'` -Controller = Ember.ObjectController.extend +Controller = Ember.Controller.extend allHooks: [] needs: ['currentUser'] - userBinding: 'controllers.currentUser' + userBinding: 'controllers.currentUser.model' init: -> @_super.apply this, arguments @@ -21,7 +21,7 @@ Controller = Ember.ObjectController.extend hook.toggle() reloadHooks: -> - if login = @get('login') + if login = @get('model.login') hooks = @store.find('hook', all: true, owner_name: login) hooks.then () -> @@ -49,7 +49,7 @@ Controller = Ember.ObjectController.extend billingUrl: (-> id = if @get('model.type') == 'user' then 'user' else @get('model.login') - "#{@get('config').billingEndpoint}/subscriptions/#{id}" + "#{@config.billingEndpoint}/subscriptions/#{id}" ).property('model.login', 'model.type') `export default Controller` diff --git a/app/controllers/build.coffee b/app/controllers/build.coffee index 4e868705..b25d61b1 100644 --- a/app/controllers/build.coffee +++ b/app/controllers/build.coffee @@ -3,10 +3,10 @@ `import GithubUrlPropertievs from 'travis/mixins/github-url-properties'` Controller = Ember.Controller.extend GithubUrlPropertievs, - needs: ['repo'] + needs: ['repo', 'currentUser'] repoBinding: 'controllers.repo.repo' commitBinding: 'build.commit' - currentUserBinding: 'controllers.repo.currentUser' + currentUserBinding: 'controllers.currentUser.model' tabBinding: 'controllers.repo.tab' sendFaviconStateChanges: true diff --git a/app/controllers/builds-item.coffee b/app/controllers/builds-item.coffee deleted file mode 100644 index 5373764b..00000000 --- a/app/controllers/builds-item.coffee +++ /dev/null @@ -1,20 +0,0 @@ -`import Ember from 'ember'` -`import { colorForState } from 'travis/utils/helpers'` -`import GithubUrlProperties from 'travis/mixins/github-url-properties'` -`import { gravatarImage } from 'travis/utils/urls'` - -Controller = Ember.ObjectController.extend(GithubUrlProperties, - needs: ['builds'] - isPullRequestsListBinding: 'controllers.builds.isPullRequestsList' - buildBinding: 'model' - - color: (-> - colorForState(@get('build.state')) - ).property('build.state') - - urlAuthorGravatarImage: (-> - gravatarImage(@get('build.commit.committerEmail'), 40) - ).property('build.commit.authorEmail') -) - -`export default Controller` diff --git a/app/controllers/builds.coffee b/app/controllers/builds.coffee index 325d7565..7bd25ad8 100644 --- a/app/controllers/builds.coffee +++ b/app/controllers/builds.coffee @@ -1,8 +1,6 @@ `import Ember from 'ember'` Controller = Ember.ArrayController.extend - isPullRequestsList: false - sortAscending: false sortProperties: ['number'] diff --git a/app/controllers/caches-by-branch.coffee b/app/controllers/caches-by-branch.coffee deleted file mode 100644 index 34f01be2..00000000 --- a/app/controllers/caches-by-branch.coffee +++ /dev/null @@ -1,25 +0,0 @@ -`import Ember from 'ember'` -`import Ajax from 'travis/utils/ajax'` - -Controller = Ember.ObjectController.extend - isDeleting: false - needs: ['repo', 'caches'] - repo: Ember.computed.alias('controllers.repo.repo') - - actions: - delete: -> - return if @get('isDeleting') - - if confirm('Are you sure?') - @set('isDeleting', true) - - data = { branch: @get('branch') } - - deletingDone = => @set('isDeleting', false) - - repo = @get('repo') - Ajax.ajax("/repos/#{repo.get('id')}/caches", "DELETE", data: data).then(deletingDone, deletingDone).then => - model = @get('model') - @get('controllers.caches').removeObject(model) - -`export default Controller` diff --git a/app/controllers/caches-item.coffee b/app/controllers/caches-item.coffee deleted file mode 100644 index ef14fea2..00000000 --- a/app/controllers/caches-item.coffee +++ /dev/null @@ -1,27 +0,0 @@ -`import Ember from 'ember'` -`import Ajax from 'travis/utils/ajax'` - -Controller = Ember.ObjectController.extend - isDeleting: false - needs: ['repo', 'caches'] - repo: Ember.computed.alias('controllers.repo.repo') - - actions: - delete: -> - return if @get('isDeleting') - - if confirm('Are you sure?') - @set('isDeleting', true) - - data = { branch: @get('branch'), match: @get('slug') } - - deletingDone = => @set('isDeleting', false) - - repo = @get('repo') - Ajax.ajax("/repos/#{repo.get('id')}/caches", "DELETE", data: data).then(deletingDone, deletingDone).then => - model = @get('model') - @get('parent.caches').removeObject(model) - if @get('parent.caches.length') == 0 - @get('controllers.caches').removeObject(@get('parent')) - -`export default Controller` diff --git a/app/controllers/current-user.coffee b/app/controllers/current-user.coffee index af7231f6..b6b5d130 100644 --- a/app/controllers/current-user.coffee +++ b/app/controllers/current-user.coffee @@ -1,4 +1,4 @@ -Controller = Ember.ObjectController.extend +Controller = Ember.Controller.extend sync: -> @get('model').sync() diff --git a/app/controllers/first-sync.coffee b/app/controllers/first-sync.coffee index bc9e94a5..6ca0d82b 100644 --- a/app/controllers/first-sync.coffee +++ b/app/controllers/first-sync.coffee @@ -2,7 +2,7 @@ Controller = Ember.Controller.extend needs: ['currentUser'] - user: Ember.computed.alias('controllers.currentUser') + user: Ember.computed.alias('controllers.currentUser.model') isSyncing: Ember.computed.alias('user.isSyncing') diff --git a/app/controllers/flash.coffee b/app/controllers/flash.coffee index dff32821..650d2081 100644 --- a/app/controllers/flash.coffee +++ b/app/controllers/flash.coffee @@ -4,7 +4,7 @@ Controller = Ember.ArrayController.extend needs: ['currentUser'] - currentUserBinding: 'controllers.currentUser' + currentUserBinding: 'controllers.currentUser.model' init: -> @_super.apply this, arguments diff --git a/app/controllers/job.coffee b/app/controllers/job.coffee index f262a0e4..fb45da9c 100644 --- a/app/controllers/job.coffee +++ b/app/controllers/job.coffee @@ -2,12 +2,12 @@ `import { githubCommit } from 'travis/utils/urls'` Controller = Ember.Controller.extend - needs: ['repo'] + needs: ['repo', 'currentUser'] repoBinding: 'controllers.repo.repo' commitBinding: 'job.commit' annotationsBinding: 'job.annotations' - currentUserBinding: 'controllers.repo.currentUser' + currentUserBinding: 'controllers.currentUser.model' tabBinding: 'controllers.repo.tab' currentItemBinding: 'job' diff --git a/app/controllers/profile.coffee b/app/controllers/profile.coffee index 4686516a..d5dd0c5d 100644 --- a/app/controllers/profile.coffee +++ b/app/controllers/profile.coffee @@ -4,8 +4,8 @@ Controller = Ember.Controller.extend name: 'profile' needs: ['currentUser', 'accounts', 'account'] - userBinding: 'controllers.currentUser' - accountBinding: 'controllers.account' + userBinding: 'controllers.currentUser.model' + accountBinding: 'controllers.account.model' activate: (action, params) -> this["view_#{action}".camelize()]() diff --git a/app/controllers/repo.coffee b/app/controllers/repo.coffee index e8b616ec..6ae60aa3 100644 --- a/app/controllers/repo.coffee +++ b/app/controllers/repo.coffee @@ -2,12 +2,11 @@ `import { githubRepo } from 'travis/utils/urls'` Controller = Ember.Controller.extend - needs: ['repos', 'currentUser', 'build', 'request', 'job'] - currentUserBinding: 'controllers.currentUser' + needs: ['repos', 'currentUser', 'build', 'job'] + currentUserBinding: 'controllers.currentUser.model' build: Ember.computed.alias('controllers.build.build') job: Ember.computed.alias('controllers.job.job') - request: Ember.computed.alias('controllers.request.model') slug: (-> @get('repo.slug') ).property('repo.slug') isLoading: (-> @get('repo.isLoading') ).property('repo.isLoading') diff --git a/app/controllers/repos.coffee b/app/controllers/repos.coffee index 42a7e613..bce174fa 100644 --- a/app/controllers/repos.coffee +++ b/app/controllers/repos.coffee @@ -31,7 +31,7 @@ Controller = Ember.ArrayController.extend isLoadedBinding: 'content.isLoaded' needs: ['currentUser', 'repo', 'runningJobs', 'queue'] - currentUserBinding: 'controllers.currentUser' + currentUserBinding: 'controllers.currentUser.model' selectedRepo: (-> # we need to observe also repo.content here, because we use # ObjectProxy in repo controller diff --git a/app/controllers/request.coffee b/app/controllers/request.coffee deleted file mode 100644 index 59173b06..00000000 --- a/app/controllers/request.coffee +++ /dev/null @@ -1,35 +0,0 @@ -`import Ember from 'ember'` - -Controller = Ember.ObjectController.extend - requestClass: (-> - if @get('content.isAccepted') - 'accepted' - else - 'rejected' - ).property('content.isAccepted') - - type: (-> - if @get('isPullRequest') - 'pull_request' - else - 'push' - ).property('isPullRequest') - - status: (-> - if @get('isAccepted') - 'Accepted' - else - 'Rejected' - ).property('isAccepted') - - message: (-> - message = @get('model.message') - if @config.pro && message == "private repository" - '' - else if !message - 'Build created successfully ' - else - message - ).property('model.message') - -`export default Controller` diff --git a/app/controllers/settings/index.coffee b/app/controllers/settings/index.coffee index 40656ffa..ca04a09b 100644 --- a/app/controllers/settings/index.coffee +++ b/app/controllers/settings/index.coffee @@ -1,6 +1,6 @@ `import Ember from 'ember'` -Controller = Ember.ObjectController.extend +Controller = Ember.Controller.extend settings: Ember.computed.alias('model.settings') settingsChanged: (-> diff --git a/app/controllers/top.coffee b/app/controllers/top.coffee index d70f1f6c..7ef3d5be 100644 --- a/app/controllers/top.coffee +++ b/app/controllers/top.coffee @@ -2,7 +2,7 @@ Controller = Ember.Controller.extend needs: ['currentUser'] - userBinding: 'controllers.currentUser' + userBinding: 'controllers.currentUser.model' userName: (-> @get('user.name') || @get('user.login') diff --git a/app/routes/accounts/index.coffee b/app/routes/accounts/index.coffee index 7cb2c715..b3f39679 100644 --- a/app/routes/accounts/index.coffee +++ b/app/routes/accounts/index.coffee @@ -5,7 +5,7 @@ Route = TravisRoute.extend # TODO: setting accounts model in ProfileRoute is wrong, but # at this stage it's better than what we had before accounts = @modelFor('accounts') - login = @controllerFor('currentUser').get('login') + login = @controllerFor('currentUser').get('model.login') account = accounts.find (account) -> account.get('login') == login @replaceWith 'account', account diff --git a/app/routes/pull-requests.coffee b/app/routes/pull-requests.coffee index 4253f7c0..4f07d233 100644 --- a/app/routes/pull-requests.coffee +++ b/app/routes/pull-requests.coffee @@ -2,16 +2,6 @@ Route = AbstractBuildsRoute.extend( contentType: 'pull_requests' - - # TODO: it would be better to have separate controller for branches and PRs list - setupController: (controller, model) -> - @_super(controller, model) - - this.controllerFor('builds').set('isPullRequestsList', true) - - deactivate: -> - @_super.apply(this, arguments) - this.controllerFor('builds').set('isPullRequestsList', false) ) `export default Route` diff --git a/app/templates/builds.hbs b/app/templates/builds.hbs index ed386250..ec885c71 100644 --- a/app/templates/builds.hbs +++ b/app/templates/builds.hbs @@ -1,56 +1,7 @@ {{#if content.isLoaded}} {{!--