From 201a37aa7051336019c95d79fdb8a9b4613dff1e Mon Sep 17 00:00:00 2001 From: Lisa P Date: Tue, 17 Nov 2015 17:51:30 +0100 Subject: [PATCH] refactor accounts, pt1 --- app/components/org-item.coffee | 29 +++++++++++++++ app/controllers/accounts.coffee | 6 ---- app/routes/accounts.coffee | 7 ++++ app/templates/account.hbs | 23 +++++++++--- app/templates/components/org-item.hbs | 27 ++++++++++++++ app/templates/profile/accounts.hbs | 49 ++++++------------------- app/views/accounts-list.coffee | 52 +++++++++++++-------------- app/views/profile.coffee | 5 +-- 8 files changed, 120 insertions(+), 78 deletions(-) create mode 100644 app/components/org-item.coffee create mode 100644 app/templates/components/org-item.hbs diff --git a/app/components/org-item.coffee b/app/components/org-item.coffee new file mode 100644 index 00000000..34b6a84f --- /dev/null +++ b/app/components/org-item.coffee @@ -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` diff --git a/app/controllers/accounts.coffee b/app/controllers/accounts.coffee index 90b871bd..d778bd6d 100644 --- a/app/controllers/accounts.coffee +++ b/app/controllers/accounts.coffee @@ -7,10 +7,4 @@ Controller = Ember.ArrayController.extend @get('user.name') || @get('user.login') ).property('user.login', 'user.name') - - actions: - tokenVisibility: () -> - @toggleProperty('isVisible') - return false - `export default Controller` diff --git a/app/routes/accounts.coffee b/app/routes/accounts.coffee index 7753daba..dba38215 100644 --- a/app/routes/accounts.coffee +++ b/app/routes/accounts.coffee @@ -18,4 +18,11 @@ Route = TravisRoute.extend @render 'profile_accounts', outlet: 'left', into: 'profile' + organizations: -> + model.filterBy('type', 'organization') + + user: -> + model.filterBy('type', 'user')[0] + + `export default Route` diff --git a/app/templates/account.hbs b/app/templates/account.hbs index 790fc909..558189bc 100644 --- a/app/templates/account.hbs +++ b/app/templates/account.hbs @@ -1,10 +1,25 @@ {{#if allHooks.isLoaded}}
- - {{#if config.billingEndpoint}} - {{subscribe-button account=subscribeButtonInfo}} + {{#if config.billingEndpoint}} +
+ {{#if view.subscribed}} + + Subscription active! + + {{else}} + {{#if view.education}} + + Educational account! + + {{else}} + + Sign up this account! + + {{/if}} {{/if}} +
+ {{/if}}

{{accountName}}

@@ -111,5 +126,3 @@ {{else}} {{loading-indicator}} {{/if}} - - diff --git a/app/templates/components/org-item.hbs b/app/templates/components/org-item.hbs new file mode 100644 index 00000000..850ac31a --- /dev/null +++ b/app/templates/components/org-item.hbs @@ -0,0 +1,27 @@ +
+ {{#if avatarUrl}} + avatar + {{else}} +
+ {{/if}} +
+
+ {{#link-to "account" account.login}} +

{{account.login}}

+

Repositories {{reposCount}}

+ {{/link-to}} + + {{#if isUser}} +

Token: + {{#if tokenIsVisible}} + {{auth.currentUser.token}} + {{/if}} + + + {{#if tokenIsVisible}}hide token{{else}}show token{{/if}} + + {{eye-icon}} + +

+ {{/if}} +
diff --git a/app/templates/profile/accounts.hbs b/app/templates/profile/accounts.hbs index 36e66626..66767295 100644 --- a/app/templates/profile/accounts.hbs +++ b/app/templates/profile/accounts.hbs @@ -1,46 +1,17 @@ -