diff --git a/app/components/branch-row.coffee b/app/components/branch-row.coffee index cbdbb7fb..b9219ca7 100644 --- a/app/components/branch-row.coffee +++ b/app/components/branch-row.coffee @@ -9,7 +9,7 @@ BranchRowComponent = Ember.Component.extend tagName: 'li' classNameBindings: ['build.last_build.state'] classNames: ['branch-row'] - isLoading: true + isLoading: false urlGithubCommit: (-> githubCommitUrl(@get('build.repository.slug'), @get('build.last_build.commit.sha')) @@ -17,25 +17,37 @@ BranchRowComponent = Ember.Component.extend getLast5Builds: (-> - array = [{}, {}, {}, {}, {}] + lastBuilds = Ember.ArrayProxy.create( + content: [{}, {}, {}, {}, {}] + isLoading: true, + count: 0 + ) - if @get('build.last_build') == null - @set('isLoading', false) - array + if !@get('build.last_build') + lastBuilds.set('isLoading', false) else - array + apiEndpoint = config.apiEndpoint + repoId = @get('build.repository.id') + branchName = @get('build.name') - # apiEndpoint = config.apiEndpoint - # repoId = @get('build.repository.id') + options = {} + if @get('auth.signedIn') + options.headers = { Authorization: "token #{@auth.token()}" } - # options = {} - # if @get('auth.signedIn') - # options.headers = { Authorization: "token #{@auth.token()}" } + $.ajax("#{apiEndpoint}/v3/repo/#{repoId}/builds?branch.name=#{branchName}&limit=5&offset=1", options).then (response) -> + array = response.builds.map( (build) -> + Ember.Object.create(build) + ) + if array.length < 5 + for i in [1..5 - array.length] by 1 + array.push({}) - # $.ajax("#{apiEndpoint}/v3/repo/269284/builds?branch.name=master&limit=5", options).then (response) -> - # console.log(response) - # @set('isLoading', false) - ).property('build') + lastBuilds.set('count', response['@pagination'].count) + lastBuilds.set('content', array) + lastBuilds.set('isLoading', false) + + lastBuilds + ).property() actions: tiggerBuild: (branch) -> diff --git a/app/components/request-icon.coffee b/app/components/request-icon.coffee index a48846d9..6f377e49 100644 --- a/app/components/request-icon.coffee +++ b/app/components/request-icon.coffee @@ -4,22 +4,25 @@ RequestIconComponent = Ember.Component.extend tagName: 'span' classNames: ['icon-request'] - classNameBindings: ['build.last_build.state'] + classNameBindings: ['build.last_build.state', 'build.state'] isPush: (-> - @get('build.last_build.event_type') == 'push' + @get('build.last_build.event_type') == 'push' || + @get('build.event_type') == 'push' ).property('build.last_build') isPR: (-> - @get('build.last_build.event_type') == 'pull_request' + @get('build.last_build.event_type') == 'pull_request' || + @get('build.event_type') == 'pull_request' ).property('build.last_build') isAPI: (-> - @get('build.last_build.event_type') == 'api' + @get('build.last_build.event_type') == 'api' || + @get('build.event_type') == 'api' ).property('build.last_build') isEmpty: (-> - true if @get('build.last_build') == null + true if @get('build.last_build') == null || @get('build') == null ).property('build.last_build') diff --git a/app/components/status-icon.coffee b/app/components/status-icon.coffee index b784b08f..a19d9c0e 100644 --- a/app/components/status-icon.coffee +++ b/app/components/status-icon.coffee @@ -7,31 +7,44 @@ StatusIconComponent = Ember.Component.extend classNameBindings: ['build.last_build.state'] hasPassed: (-> - @get('build.last_build.state') == 'passed' - ).property('build.last_build.state') + @get('build.last_build.state') == 'passed' || + @get('build.state') == 'passed' + ).property('build') hasFailed: (-> - @get('build.last_build.state') == 'failed' - ).property('build.last_build.state') + @get('build.last_build.state') == 'failed' || + @get('build.state') == 'failed' + ).property('build') hasErrored: (-> - @get('build.last_build.state') == 'errored' - ).property('build.last_build.state') + @get('build.last_build.state') == 'errored' || + @get('build.state') == 'errored' + ).property('build') wasCanceled: (-> - @get('build.last_build.state') == 'canceled' - ).property('build.last_build.state') + @get('build.last_build.state') == 'canceled' || + @get('build.state') == 'canceled' + ).property('build') isRunning: (-> @get('build.last_build.state') == 'started' || @get('build.last_build.state') == 'queued' || @get('build.last_build.state') == 'booting' || @get('build.last_build.state') == 'received' || - @get('build.last_build.state') == 'created' - ).property('build.last_build.state') + @get('build.last_build.state') == 'created' || + @get('build.state') == 'started' || + @get('build.state') == 'queued' || + @get('build.state') == 'booting' || + @get('build.state') == 'received' || + @get('build.state') == 'created' + ).property('build') isEmpty: (-> - true if @get('build.last_build') == null - ).property('build.last_build') + if @get('build.@type') == 'branch' + true if @get('build.last_build.state') == null + else if @get('build.@type') == 'build' + false if @get('build.state') != '' + + ).property('build') `export default StatusIconComponent` diff --git a/app/controllers/branches.coffee b/app/controllers/branches.coffee index a0a0c96e..1a8bec3d 100644 --- a/app/controllers/branches.coffee +++ b/app/controllers/branches.coffee @@ -14,6 +14,9 @@ BranchesController = Ember.Controller.extend repos = @get('model') repos = repos.filter (item, index) -> item if item.exists_on_github == true + .sort (a, b) -> + return 0 + ).property('model') inactiveBranches: (-> diff --git a/app/styles/app/components/build-tile.sass b/app/styles/app/components/build-tile.sass index 7a1cdda4..3ee34ad8 100644 --- a/app/styles/app/components/build-tile.sass +++ b/app/styles/app/components/build-tile.sass @@ -28,6 +28,7 @@ display: inline-block height: 100% width: 18.8% + background-color: #F7F7F7 .status-icon position: absolute top: 0 @@ -36,7 +37,7 @@ left: 0 width: 2rem height: 2rem - margin: auto + margin: auto !important background-color: transparent .is-rotating width: 100% diff --git a/app/styles/app/layouts/branches.sass b/app/styles/app/layouts/branches.sass index 22597170..d5ba8e02 100644 --- a/app/styles/app/layouts/branches.sass +++ b/app/styles/app/layouts/branches.sass @@ -22,7 +22,7 @@ color: $grey-dark background: linear-gradient(to right, #CACECE 0%, #CACECE 9px, white 10px, white 100%) no-repeat - span + span[class*="icon"] width: 1.3em height: 1.3em margin-right: .2em diff --git a/app/templates/branches.hbs b/app/templates/branches.hbs index 9fed18f3..15cf2a0c 100644 --- a/app/templates/branches.hbs +++ b/app/templates/branches.hbs @@ -6,27 +6,27 @@ -
-

Active Branches

- -
+ {{#if activeBranches}} +
+

Active Branches

+ +
+ {{/if}} -
-

Inactive Branches

- -
+ {{#if inactiveBranches}} +
+

Inactive Branches

+ +
+ {{/if}} {{!-- {{#if content.isLoaded}} --}} diff --git a/app/templates/components/branch-row.hbs b/app/templates/components/branch-row.hbs index 2313b85f..5998addd 100644 --- a/app/templates/components/branch-row.hbs +++ b/app/templates/components/branch-row.hbs @@ -3,7 +3,7 @@

{{status-icon build=build}}{{build.name}}

-
+ +
@@ -42,7 +46,7 @@
- + diff --git a/app/templates/components/build-tile.hbs b/app/templates/components/build-tile.hbs index b96158db..6c493669 100644 --- a/app/templates/components/build-tile.hbs +++ b/app/templates/components/build-tile.hbs @@ -1,8 +1,8 @@ -{{#unless build}} - +{{#if build.number}} + {{#link-to "build" build.repository.slug build.id class="dropup-trigger"}} {{status-icon build=build}}
{{request-icon build=build}} #{{build.number}}
-
-{{/unless}} \ No newline at end of file + {{/link-to}} +{{/if}} \ No newline at end of file