refactor accounts, pt1

This commit is contained in:
Lisa P 2015-11-17 17:51:30 +01:00 committed by Piotr Sarnacki
parent 8c9f92062d
commit 201a37aa70
8 changed files with 120 additions and 78 deletions

View File

@ -0,0 +1,29 @@
`import Ember from 'ember'`
OrgItemComponent = Ember.Component.extend
classNames: ['media', 'account']
tagName: 'li'
classNameBindings: ['type', 'selected']
typeBinding: 'account.type'
selectedBinding: 'account.selected'
tokenIsVisible: false
name: (->
@get('account.name') || @get('account.login')
).property('account')
avatarUrl: (->
console.log(@get('account'))
@get('account.avatarUrl') || false
).property('account')
isUser: (->
@get('account.type') == 'user'
).property('account')
actions:
tokenVisibility: () ->
@toggleProperty('tokenIsVisible')
`export default OrgItemComponent`

View File

@ -7,10 +7,4 @@ Controller = Ember.ArrayController.extend
@get('user.name') || @get('user.login') @get('user.name') || @get('user.login')
).property('user.login', 'user.name') ).property('user.login', 'user.name')
actions:
tokenVisibility: () ->
@toggleProperty('isVisible')
return false
`export default Controller` `export default Controller`

View File

@ -18,4 +18,11 @@ Route = TravisRoute.extend
@render 'profile_accounts', outlet: 'left', into: 'profile' @render 'profile_accounts', outlet: 'left', into: 'profile'
organizations: ->
model.filterBy('type', 'organization')
user: ->
model.filterBy('type', 'user')[0]
`export default Route` `export default Route`

View File

@ -1,10 +1,25 @@
{{#if allHooks.isLoaded}} {{#if allHooks.isLoaded}}
<header> <header>
{{#if config.billingEndpoint}}
{{#if config.billingEndpoint}} <div class="cta-btn">
{{subscribe-button account=subscribeButtonInfo}} {{#if view.subscribed}}
<a class="btn btn-activated" href={{billingUrl}}>
Subscription active!
</a>
{{else}}
{{#if view.education}}
<a class="btn btn-activated" href={{billingUrl}}>
Educational account!
</a>
{{else}}
<a class="btn btn-activate" href={{billingUrl}}>
Sign up this account!
</a>
{{/if}}
{{/if}} {{/if}}
</div>
{{/if}}
<div class="profile-header"> <div class="profile-header">
<h1>{{accountName}}</h1> <h1>{{accountName}}</h1>
@ -111,5 +126,3 @@
{{else}} {{else}}
{{loading-indicator}} {{loading-indicator}}
{{/if}} {{/if}}

View File

@ -0,0 +1,27 @@
<div class="media-elem">
{{#if avatarUrl}}
<img src={{avatarUrl}} alt="avatar">
{{else}}
<div class="default-avatar--profile"></div>
{{/if}}
</div>
<div class="media-body">
{{#link-to "account" account.login}}
<h2>{{account.login}}</h2>
<p>Repositories <strong>{{reposCount}}</strong></p>
{{/link-to}}
{{#if isUser}}
<p class="profile-user-last">Token:
{{#if tokenIsVisible}}
<strong>{{auth.currentUser.token}}</strong>
{{/if}}
<a {{action 'tokenVisibility' prevenDefault=true}} class="profile-token-toggle tooltip--profile {{if tokenIsVisible 'is-visible'}} dropdown">
<span class="tooltip-bubble">
{{#if tokenIsVisible}}hide token{{else}}show token{{/if}}
</span>
{{eye-icon}}
</a>
</p>
{{/if}}
</div>

View File

@ -1,46 +1,17 @@
<aside class="columns medium-4">
<section class="profile-user">
<div class="media">
<div class="media-elem">
<img src={{auth.gravatarUrl}} alt="">
</div>
<div class="media-body">
{{#link-to 'profile'}}
<h1>{{userName}}</h1>
<p>Repositories <strong>{{user.reposCount}}</strong></p>
{{/link-to}}
<p class="profile-user-last">Token:
{{#if isVisible}} <aside class="columns medium-4">
<strong>{{auth.currentUser.token}}</strong>
{{/if}}
<a {{action 'tokenVisibility'}} class="profile-token-toggle tooltip--profile {{if isVisible 'is-visible'}} dropdown">
<span class="tooltip-bubble">
{{#if isVisible}}hide token{{else}}show token{{/if}}
</span>
{{eye-icon}}
</a>
</p>
</div>
</div>
</section>
<section class="profile-orgs"> <section class="profile-orgs">
<ul>
{{org-item account=user}}
</ul>
<h1>Organizations</h1> <h1>Organizations</h1>
{{#collection "accounts-list" content="organizations"}} <ul>
{{#link-to "account" view.account class="name"}} {{#each organizations as |org|}}
<div class="media"> {{org-item account=org}}
<div class="media-elem">
<img src={{view.avatarUrl}} alt="">
</div>
<div class="media-body">
<h2>{{view.name}}</h2>
<p>Repositories <strong>{{view.account.reposCount}}</strong></p>
</div>
</div>
{{/link-to}}
{{else}} {{else}}
<p class="profile-text">You are not currently a member of <br> any organization.</p> <li class="profile-text">You are not currently a member of <br> any organization.</li>
{{/collection}} {{/each}}
</ul>
</section> </section>
{{#if config.githubOrgsOauthAccessSettingsUrl}} {{#if config.githubOrgsOauthAccessSettingsUrl}}
<section class="profile-additional"> <section class="profile-additional">

View File

@ -1,35 +1,35 @@
`import Ember from 'ember'` # `import Ember from 'ember'`
`import { account as accountUrl } from 'travis/utils/urls'` # `import { account as accountUrl } from 'travis/utils/urls'`
View = Ember.CollectionView.extend # View = Ember.CollectionView.extend
elementId: 'accounts' # elementId: 'accounts'
accountBinding: 'content' # accountBinding: 'content'
tagName: 'ul' # tagName: 'ul'
emptyView: Ember.View.extend # emptyView: Ember.View.extend
templateName: 'accounts-list/empty' # templateName: 'accounts-list/empty'
itemViewClass: Ember.View.extend # itemViewClass: Ember.View.extend
accountBinding: 'content' # accountBinding: 'content'
typeBinding: 'content.type' # typeBinding: 'content.type'
selectedBinding: 'account.selected' # selectedBinding: 'account.selected'
classNames: ['account'] # classNames: ['account']
classNameBindings: ['type', 'selected'] # classNameBindings: ['type', 'selected']
name: (-> # name: (->
@get('content.name') || @get('content.login') # @get('content.name') || @get('content.login')
).property('content.login', 'content.name') # ).property('content.login', 'content.name')
urlAccount: (-> # urlAccount: (->
accountUrl(@get('account.login')) # accountUrl(@get('account.login'))
).property('account.login') # ).property('account.login')
avatarUrl: (-> # avatarUrl: (->
@get('account.avatarUrl') || "//placehold.it/50x50" # @get('account.avatarUrl') || "//placehold.it/50x50"
).property('account.avatarUrl') # ).property('account.avatarUrl')
click: -> # click: ->
@get('controller').transitionToRoute("account", @get('account.login')) # @get('controller').transitionToRoute("account", @get('account.login'))
`export default View` # `export default View`

View File

@ -5,8 +5,9 @@ View = BasicView.extend
layoutName: 'layouts/profile' layoutName: 'layouts/profile'
classNames: ['profile-view'] classNames: ['profile-view']
accountBinding: 'controller.account' accountBinding: 'controller.account'
subscribedBinding: 'account.subscribed' # Can we remove these?
educationBinding: 'account.education' # subscribedBinding: 'account.subscribed'
# educationBinding: 'account.education'
name: (-> name: (->
@get('account.name') || @get('account.login') @get('account.name') || @get('account.login')