add make owner page sorta kinda work

This commit is contained in:
Lisa Passing 2015-04-30 17:22:53 +02:00
parent 1760168d45
commit 4ac5841a6d
7 changed files with 102 additions and 37 deletions

View File

@ -0,0 +1,20 @@
`import Ember from 'ember'`
OwnerRepoTileComponent = Ember.Component.extend
tagName: 'li'
classNames: ['tile', 'tile--small', 'row']
classNameBindings: ['repo.default_branch.last_build.state']
ownerName: (->
@get('repo.slug').split(/\//)[0]
).property('repo.slug')
repoName: (->
@get('repo.slug').split(/\//)[1]
).property('repo.slug')
`export default OwnerRepoTileComponent`

View File

@ -16,7 +16,29 @@ Controller = Ember.Controller.extend
).property()
owner: (->
@get('model')
data = @get('model')
console.log(data)
{
login: data.login
name: data.name
isSyncing: data.is_syncing
avatarUrl: data.avatar_url
syncedAt: data.synced_at
}
).property('model')
repos: (->
data = @get('model')
repos = data.repositories.filter (item, index) ->
if item.active && item.default_branch.last_build != null
item.active
console.log(repos)
repos
).property('model')
`export default Controller`

View File

@ -9,10 +9,8 @@ Route = TravisRoute.extend
model: (params) ->
owner = {}
$.get("https://api.travis-ci.org/v3/owner/#{params.owner}?include=user.repositories,organization.repositories").then( (data) ->
owner = data
owner
$.get("https://api-staging.travis-ci.org/v3/owner/#{params.owner}?include=user.repositories,organization.repositories,build.commit").then( (data) ->
data
)
`export default Route`

View File

@ -0,0 +1,30 @@
{{#if repo.private }}
<div class="tile-lock"><span class="icon icon-lock"></span></div>
{{/if}}
<div class="tile-status">
<span {{bind-attr class=":icon :icon-status repo.default_branch.last_build.state"}}></span>
<span {{bind-attr class=":icon :request-kind repo.default_branch.last_build.event_type"}}></span>
</div>
<div class="tile-main tile-header column medium-3">
<h3>{{ownerName}}</h3>
<h2>{{#link-to "repo" ownerName repoName }}{{repoName}}{{/link-to}}</h2>
</div>
<div class="tile-single column medium-9 end">
{{#if repo.default_branch.last_build}}
<p class="tile-job build-status column medium-3 small-6"><span class="icon icon-hash"></span>
{{#link-to "build" ownerName repoName repo.default_branch.last_build.number}}
{{!-- {{repo.last_build.number}} {{repo.last_build.state}} --}}
{{repo.default_branch.last_build.number}} {{repo.default_branch.last_build.state}}
{{/link-to}}</p>
<p class="tile-commit column medium-3 small-6">
<span class="icon icon-github"></span><a {{bind-attr href="repo.default_branch.last_build.commit.compare_url"}}>{{format-sha repo.default_branch.last_build.commit.sha}}</a></p>
<p class="tile-timeago column medium-3 small-6">
<span class="icon icon-clock"></span>
{{format-duration repo.default_branch.last_build.duration}}</p>
<p class="tile-timeago column medium-2 small-6">
<span class="icon icon-cal"></span>
{{format-time repo.default_branch.last_build.finished_at}}</p>
{{else}}
<p>there is no build</p>
{{/if}}
</div>

View File

@ -1,5 +1,5 @@
<div class="sync-button">
{{#if owner.is_syncing }}
{{#if owner.isSyncing }}
<p>
<button class="button" disabled="disabled">
<span class="sync-spinner"><i></i><i></i><i></i></span>Syncing
@ -10,6 +10,6 @@
<button {{action sync}} class="button">
<span class="icon icon-sync"></span>Sync account</button>
</p>
<p class="sync-last">last synced {{format-time owner.synced_at}}</p>
<p class="sync-last">last synced {{format-time owner.syncedAt}}</p>
{{/if}}
</div>

View File

@ -3,13 +3,14 @@
<header class="owner-header row">
<section class="columns small-10 medium-5">
<div class="owner-avatar">
<img {{bind-attr src="avatarURL"}} alt="">
<img {{bind-attr src="owner.avatarUrl"}} alt="" width="125" height="125">
</div>
<div class="owner-info">
<h1 class="owner-title">{{owner.name}}</h1>
{{!-- TODO: only sync btn if user part of org --}}
<p class="owner-handle"><a {{bind-attr href="githubProfile"}} title=""><span class="icon icon--github-circle"></span> {{owner.login}}</a></p>
{{owner-sync-button owner=owner}}
<p class="owner-handle"><a {{bind-attr href="githubProfile"}} title=""><span class="icon icon--github-circle"></span> {{owner.login}}</a></p>
{{owner-sync-button owner=owner}}
</div>
</section>
</header>
@ -27,32 +28,9 @@
<section role="tabpanel">
<ul class="owner-tiles">
<li {{bind-attr class=":tile :tile--small :row repo.last_build.state :passed"}}>
{{#if repo.private }}
<div class="tile-lock"><span class="icon icon-lock"></span></div>
{{/if}}
<div class="tile-status">
<span {{bind-attr class=":icon :icon-status repo.last_build.state :passed"}}></span>
<span {{bind-attr class=":icon :request-kind repo.last_build.state :push"}}></span>
</div>
<div class="tile-main tile-header column medium-3">
<h3>owner</h3>
<h2>{{#link-to "repo" repo.owner.login repo.name}}repo namerepo namerepo namerepo namerepo namerepo namerepo name{{/link-to}}</h2>
</div>
<div class="tile-single column medium-9 end">
<p class="tile-job build-status column medium-3 small-6"><span class="icon icon-hash"></span>
{{#link-to "build" repo.owner.login repo.name repo.last_build.id}}
{{!-- {{repo.last_build.number}} {{repo.last_build.state}} --}}
1234 passed
{{/link-to}}</p>
<p class="tile-commit column medium-3 small-6">
<span class="icon icon-github"></span><a href="#">394348a</a></p>
<p class="tile-timeago column medium-3 small-6">
<span class="icon icon-clock"></span>ran for 3 min 23 sec</p>
<p class="tile-timeago column medium-2 small-6">
<span class="icon icon-cal"></span>3 days ago{{!-- {{format-time repo.last_build.finished_at}} --}}</p>
</div>
</li>
{{#each repo in repos}}
{{owner-repo-tile repo=repo}}
{{/each}}
</ul>
</section>

View File

@ -0,0 +1,17 @@
`import { test, moduleForComponent } from 'ember-qunit'`
moduleForComponent 'owner-repo-tile', 'OwnerRepoTileComponent', {
# specify the other units that are required for this test
# needs: ['component:foo', 'helper:bar']
}
test 'it renders', ->
expect 2
# creates the component instance
component = @subject()
equal component._state, 'preRender'
# appends the component to the page
@append()
equal component._state, 'inDOM'