From c11fdb0459202d39d99faead0178d767913e66f9 Mon Sep 17 00:00:00 2001 From: danielgrippi Date: Sun, 8 Jan 2012 23:42:58 -0800 Subject: [PATCH] put 'Admin' back in #user_menu for admins. this fixes #2595 [ci skip] --- app/views/layouts/application.html.haml | 6 +++++- app/views/templates/header.jst | 3 +++ config/locales/javascript/javascript.en.yml | 1 + public/javascripts/app/views/content_view.js | 1 - spec/javascripts/app/views/header_view_spec.js | 14 ++++++++++++++ 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index d33dc87b8..376dd0e6a 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -80,7 +80,11 @@ - if current_user :javascript app.user({ - current_user: _.extend(#{current_user.person.as_api_response(:backbone).to_json}, {notifications_count : #{@notification_count}, unread_messages_count : #{@unread_message_count}}) + current_user: _.extend(#{current_user.person.as_api_response(:backbone).to_json}, { + notifications_count : #{@notification_count}, + unread_messages_count : #{@unread_message_count}, + admin : #{current_user.admin?} + }) }); = yield(:head) diff --git a/app/views/templates/header.jst b/app/views/templates/header.jst index 83845c375..91da3cef1 100644 --- a/app/views/templates/header.jst +++ b/app/views/templates/header.jst @@ -87,6 +87,9 @@
  • <%= Diaspora.I18n.t("header.profile") %>
  • <%= Diaspora.I18n.t("header.contacts") %>
  • <%= Diaspora.I18n.t("header.settings") %>
  • + <% if(current_user.admin) { %> +
  • <%= Diaspora.I18n.t("header.admin") %>
  • + <% } %>
  • <%= Diaspora.I18n.t("header.log_out") %>
  • diff --git a/config/locales/javascript/javascript.en.yml b/config/locales/javascript/javascript.en.yml index ebf27c377..c70aa09f4 100644 --- a/config/locales/javascript/javascript.en.yml +++ b/config/locales/javascript/javascript.en.yml @@ -107,6 +107,7 @@ en: profile: "Profile" contacts: "Contacts" settings: "Settings" + admin: "Admin" log_out: "Log out" notifications: "Notifications" diff --git a/public/javascripts/app/views/content_view.js b/public/javascripts/app/views/content_view.js index df70f9070..c4a25691d 100644 --- a/public/javascripts/app/views/content_view.js +++ b/public/javascripts/app/views/content_view.js @@ -38,7 +38,6 @@ app.views.Content = app.views.StreamObject.extend({ return "" + fullName + "" }) - return text } function urlify(text) { diff --git a/spec/javascripts/app/views/header_view_spec.js b/spec/javascripts/app/views/header_view_spec.js index 09ba258d7..5430ea025 100644 --- a/spec/javascripts/app/views/header_view_spec.js +++ b/spec/javascripts/app/views/header_view_spec.js @@ -37,6 +37,20 @@ describe("app.views.Header", function() { expect(this.view.$("#message_inbox_badge .badge_count").hasClass('hidden')).toBe(true); }) }) + + context("admin link", function(){ + it("displays if the current user is an admin", function(){ + window.current_user = _.extend(window.current_user, {admin : true}) + this.view.render(); + expect(this.view.$("#user_menu").html()).toContain("/admins"); + }) + + it("does not display if the current user is not an admin", function(){ + window.current_user = _.extend(window.current_user, {admin : false}) + this.view.render(); + expect(this.view.$("#user_menu").html()).not.toContain("/admins"); + }) + }) }) describe("#toggleDropdown", function() {