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/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/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}} {{!-- --}} - {{#each build in controller itemController="buildsItem"}} -
-
- - -
-
-

- {{#if isPullRequestsList}} - PR #{{build.pullRequestNumber}} - {{#link-to "build" build.repo build}} - {{{format-message build.pullRequestTitle short="true" repoBinding=build.repo}}} - {{/link-to}} - {{else}} - {{build.commit.branch}} - {{#link-to "build" build.repo build}} - {{{format-message build.commit.message short="true" repoBinding=build.repo}}} - {{/link-to}} - {{/if}} -

-

{{build.commit.committerName}} committed

-
-
-
-

- {{#if build.id}} - {{#link-to "build" build.repo build}} - - {{build.number}} {{build.state}} - {{/link-to}} - {{/if}} -

-

- - - {{format-sha build.commit.sha}} - -

-
-
-

- - {{format-duration build.duration}} -

-

- - {{format-time build.finishedAt}} -

-
-
-
+ {{#each controller as |build|}} + {{builds-item build=build}} {{/each}} {{#if displayShowMoreButton}}

diff --git a/app/templates/components/builds-item.hbs b/app/templates/components/builds-item.hbs new file mode 100644 index 00000000..519420f9 --- /dev/null +++ b/app/templates/components/builds-item.hbs @@ -0,0 +1,48 @@ +

+ + +
+
+

+ {{#if build.isPullRequest}} + PR #{{build.pullRequestNumber}} + {{#link-to "build" build.repo build}} + {{{format-message build.pullRequestTitle short="true" repoBinding=build.repo}}} + {{/link-to}} + {{else}} + {{build.commit.branch}} + {{#link-to "build" build.repo build}} + {{{format-message build.commit.message short="true" repoBinding=build.repo}}} + {{/link-to}} + {{/if}} +

+

{{build.commit.committerName}} committed

+
+
+
+

+ {{#if build.id}} + {{#link-to "build" build.repo build}} + + {{build.number}} {{build.state}} + {{/link-to}} + {{/if}} +

+

+ + + {{format-sha build.commit.sha}} + +

+
+
+

+ + {{format-duration build.duration}} +

+

+ + {{format-time build.finishedAt}} +

+
+
diff --git a/tests/unit/components/builds-item-test.coffee b/tests/unit/components/builds-item-test.coffee new file mode 100644 index 00000000..c6214df8 --- /dev/null +++ b/tests/unit/components/builds-item-test.coffee @@ -0,0 +1,17 @@ +`import { test, moduleForComponent } from 'ember-qunit'` + +moduleForComponent 'builds-item', { + # specify the other units that are required for this test + # needs: ['component:foo', 'helper:bar'] +} + +test 'it renders', (assert) -> + assert.expect 2 + + # creates the component instance + component = @subject() + assert.equal component._state, 'preRender' + + # renders the component to the page + @render() + assert.equal component._state, 'inDOM' diff --git a/tests/unit/components/jobs-item-test.coffee b/tests/unit/components/jobs-item-test.coffee index 39e91d80..9529c4f4 100644 --- a/tests/unit/components/jobs-item-test.coffee +++ b/tests/unit/components/jobs-item-test.coffee @@ -29,7 +29,7 @@ test 'it renders', -> ok component.$('.job-os').hasClass('linux'), 'OS class should be added for OS icon' equal component.$('.job-duration').text().trim(), '1 min 40 sec', 'duration should be displayed' -test 'ouputs info on not set properties', -> +test 'outputs info on not set properties', -> job = Ember.Object.create() component = @subject(job: job)