From 8c9f92062d48e470dc8164a9ea32437881690b8a Mon Sep 17 00:00:00 2001 From: Lisa P Date: Tue, 17 Nov 2015 15:42:41 +0100 Subject: [PATCH] refactor cta subscription button to component, remove deprecation --- app/components/subscribe-button.coffee | 8 +++++++ app/controllers/account.coffee | 10 ++++++++- app/styles/app/layouts/profile.sass | 3 +-- app/templates/account.hbs | 21 +++---------------- app/templates/components/subscribe-button.hbs | 15 +++++++++++++ 5 files changed, 36 insertions(+), 21 deletions(-) create mode 100644 app/components/subscribe-button.coffee create mode 100644 app/templates/components/subscribe-button.hbs diff --git a/app/components/subscribe-button.coffee b/app/components/subscribe-button.coffee new file mode 100644 index 00000000..cc808ff4 --- /dev/null +++ b/app/components/subscribe-button.coffee @@ -0,0 +1,8 @@ +`import Ember from 'ember'` +`import config from 'travis/config/environment'` + +SubscribeButtonComponent = Ember.Component.extend + + classNames: ['cta-btn'] + +`export default SubscribeButtonComponent` diff --git a/app/controllers/account.coffee b/app/controllers/account.coffee index 27aea603..c6195a19 100644 --- a/app/controllers/account.coffee +++ b/app/controllers/account.coffee @@ -50,9 +50,17 @@ Controller = Ember.Controller.extend @config.show_repos_hint == 'public' ).property() - billingUrl: (-> + billingUrl: ( -> id = if @get('model.type') == 'user' then 'user' else @get('model.login') "#{@config.billingEndpoint}/subscriptions/#{id}" + ).property('model.name', 'model.login') + + subscribeButtonInfo: (-> + { + billingUrl: @get('billingUrl') + subscribed: @get('model.subscribed') + education: @get('model.education') + } ).property('model.login', 'model.type') `export default Controller` diff --git a/app/styles/app/layouts/profile.sass b/app/styles/app/layouts/profile.sass index 5185780f..b9fcd4d6 100644 --- a/app/styles/app/layouts/profile.sass +++ b/app/styles/app/layouts/profile.sass @@ -25,7 +25,7 @@ color: $grey-light text-decoration: underline @media #{$medium-up} - .profile-header, .sync-button, .ember-view + .profile-header, .sync-button display: inline-block vertical-align: middle .sync-button @@ -138,7 +138,6 @@ p.profile-user-last li clear: both margin-bottom: .8em - // overflow: auto .profile-hooks width: grid-calc(10, 24) display: inline-block diff --git a/app/templates/account.hbs b/app/templates/account.hbs index 409c46d9..790fc909 100644 --- a/app/templates/account.hbs +++ b/app/templates/account.hbs @@ -1,25 +1,10 @@ {{#if allHooks.isLoaded}}
- {{#if config.billingEndpoint}} -
- {{#if view.subscribed}} - - Subscription active! - - {{else}} - {{#if view.education}} - - Educational account! - - {{else}} - - Sign up this account! - - {{/if}} + + {{#if config.billingEndpoint}} + {{subscribe-button account=subscribeButtonInfo}} {{/if}} -
- {{/if}}

{{accountName}}

diff --git a/app/templates/components/subscribe-button.hbs b/app/templates/components/subscribe-button.hbs new file mode 100644 index 00000000..d722bdf9 --- /dev/null +++ b/app/templates/components/subscribe-button.hbs @@ -0,0 +1,15 @@ +{{#if account.subscribed}} + + Subscription active! + +{{else}} + {{#if account.education}} + + Educational account! + + {{else}} + + Sign up this account! + + {{/if}} +{{/if}}