From c7516b458e31489573b73fac282127eb9f6c9346 Mon Sep 17 00:00:00 2001
From: Piotr Sarnacki
Date: Tue, 18 Jun 2013 17:54:09 +0200
Subject: [PATCH] Show all accounts and hooks in profile
Previously we showed only accounts and repositories, to which you have
admin access. To improve usability, it's better to show all accounts and
all repositories, but explain why part of the repositories are not
manageable.
---
.../app/controllers/account_index.coffee | 2 ++
assets/scripts/app/controllers/profile.coffee | 10 ++++++-
assets/scripts/app/models/hook.coffee | 1 +
assets/scripts/app/routes.coffee | 2 +-
.../app/templates/profile/tabs/hooks.hbs | 27 +++++++++++++++++--
assets/styles/profile/hooks.sass | 10 ++++++-
6 files changed, 47 insertions(+), 5 deletions(-)
diff --git a/assets/scripts/app/controllers/account_index.coffee b/assets/scripts/app/controllers/account_index.coffee
index b5dda57a..0b721c8b 100644
--- a/assets/scripts/app/controllers/account_index.coffee
+++ b/assets/scripts/app/controllers/account_index.coffee
@@ -1,6 +1,8 @@
Travis.AccountIndexController = Em.Controller.extend
needs: ['profile', 'currentUser']
hooksBinding: 'controllers.profile.hooks'
+ allHooksBinding: 'controllers.profile.allHooks'
+ unAdminisetableHooksBinding: 'controllers.profile.unAdminisetableHooks'
userBinding: 'controllers.currentUser'
sync: ->
diff --git a/assets/scripts/app/controllers/profile.coffee b/assets/scripts/app/controllers/profile.coffee
index fbac998a..02800623 100644
--- a/assets/scripts/app/controllers/profile.coffee
+++ b/assets/scripts/app/controllers/profile.coffee
@@ -35,7 +35,15 @@ Travis.ProfileController = Travis.Controller.extend
@reloadHooks()
reloadHooks: ->
- @set('hooks', Travis.Hook.find(owner_name: @get('params.login') || @get('user.login')))
+ @set('allHooks', Travis.Hook.find(all: true, owner_name: @get('params.login') || @get('user.login')))
+
+ hooks: (->
+ @get('allHooks').filter (hook) -> hook.get('admin')
+ ).property('allHooks.length', 'allHooks')
+
+ unAdminisetableHooks: (->
+ @get('allHooks').filter (hook) -> !hook.get('admin')
+ ).property('allHooks.length', 'allHooks')
viewUser: ->
@connectTab('user')
diff --git a/assets/scripts/app/models/hook.coffee b/assets/scripts/app/models/hook.coffee
index 0e6cdc8e..13cc04d1 100644
--- a/assets/scripts/app/models/hook.coffee
+++ b/assets/scripts/app/models/hook.coffee
@@ -5,6 +5,7 @@ require 'travis/model'
ownerName: DS.attr('string')
description: DS.attr('string')
active: DS.attr('boolean')
+ admin: DS.attr('boolean')
account: (->
@get('slug').split('/')[0]
diff --git a/assets/scripts/app/routes.coffee b/assets/scripts/app/routes.coffee
index 60a27b49..93dda8af 100644
--- a/assets/scripts/app/routes.coffee
+++ b/assets/scripts/app/routes.coffee
@@ -328,7 +328,7 @@ Travis.ProfileRoute = Ember.Route.extend
setupController: ->
@container.lookup('controller:application').connectLayout('profile')
- @container.lookup('controller:accounts').set('content', Travis.Account.find())
+ @container.lookup('controller:accounts').set('content', Travis.Account.find(all: true))
renderTemplate: ->
$('body').attr('id', 'profile')
diff --git a/assets/scripts/app/templates/profile/tabs/hooks.hbs b/assets/scripts/app/templates/profile/tabs/hooks.hbs
index 4f41fde5..3387ab73 100644
--- a/assets/scripts/app/templates/profile/tabs/hooks.hbs
+++ b/assets/scripts/app/templates/profile/tabs/hooks.hbs
@@ -2,7 +2,7 @@
{{{t profiles.show.message.your_repos}}}
-{{#if hooks.isLoaded}}
+{{#if allHooks.isLoaded}}
{{#if user.isSyncing}}
Please wait while we sync from GitHub
@@ -35,10 +35,33 @@
{{else}}
- You do not seem to have any repositories that we could sync.
+ {{#if unAdminisetableHooks.length}}
+ You do not have any repositories, which you can manage
+ {{else}}
+ You do not seem to have any repositories that we could sync.
+ {{/if}}
{{/each}}
+
+ {{#if unAdminisetableHooks.length}}
+
+
Repositories without admin access
+
+
+ These are the repositories, which we synced, but you do not seem to have admin access for them.
+
+
+
+ {{#each hook in unAdminisetableHooks}}
+ -
+ {{hook.slug}}
+
{{hook.description}}
+
+ {{/each}}
+
+
+ {{/if}}
{{/if}}
{{else}}
diff --git a/assets/styles/profile/hooks.sass b/assets/styles/profile/hooks.sass
index f3e94f87..c1c4ef96 100644
--- a/assets/styles/profile/hooks.sass
+++ b/assets/styles/profile/hooks.sass
@@ -1,6 +1,14 @@
@import "_mixins/all"
-#hooks
+#profile
+ #unadministerable-hooks
+ margin-top: 15px
+ h3
+ font-size: $font-size-big
+ .tip
+ margin-top: 5px
+
+#hooks, #unadministerable-hooks
// @include list-base
margin-top: 10px