From 49e62d47c974dfc001183433850f24a57d9f62e1 Mon Sep 17 00:00:00 2001 From: Fabrice Bellingard Date: Wed, 21 Nov 2012 16:13:02 +0100 Subject: [PATCH] SONAR-2342 Create a user panel to gather information --- .../resources/org/sonar/l10n/core.properties | 9 ++-- .../app/views/layouts/_layout.html.erb | 9 +--- .../views/layouts/_resource_history.html.erb | 24 ---------- .../app/views/layouts/_user_panel.html.erb | 47 +++++++++++++++++++ .../main/webapp/javascripts/recent-history.js | 45 +++++++++--------- .../src/main/webapp/stylesheets/layout.css | 34 ++++++++------ 6 files changed, 96 insertions(+), 72 deletions(-) delete mode 100644 sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_resource_history.html.erb create mode 100644 sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_user_panel.html.erb diff --git a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties index 18cdbac7b8f..f23df0c35cb 100644 --- a/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties +++ b/plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties @@ -294,9 +294,12 @@ layout.plugins=Plugins layout.evaluation=Embedded database should be used for evaluation purpose only layout.ie6_warn=Your web browser is outdated. This website may not display correctly. layout.dashboards=Dashboards -layout.recent_history.link=Recent history -layout.recent_history.clear=Clear -layout.recent_history.no_history_yet=No history yet +layout.user_panel.my_profile=My profile +layout.user_panel.recent_history.title=Recent history +layout.user_panel.recent_history.clear=Clear +layout.user_panel.me=Me +layout.user_panel.anonymous_user=Anonymous +layout.user_panel.non_authenticated_user=Unauthenticated user sidebar.project_settings=Configuration sidebar.security=Security diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb index 5aaed32bc8b..45e0122883e 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb @@ -25,16 +25,11 @@
  • <%= message('layout.print') -%>
  • - <% if logged_in? %> -
  • - <%= current_user.name(true) -%> - » <%= message('layout.logout') -%> -
  • - <% else %> + <% unless logged_in? %>
  • <%= message('layout.login') -%>
  • <% end %> + <%= render 'layouts/user_panel' -%>
  • <%= message('layout.configuration') -%>
  • - <%= render 'layouts/resource_history' -%> diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_resource_history.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_resource_history.html.erb deleted file mode 100644 index ae8dfd5f849..00000000000 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_resource_history.html.erb +++ /dev/null @@ -1,24 +0,0 @@ - - - - - \ No newline at end of file diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_user_panel.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_user_panel.html.erb new file mode 100644 index 00000000000..5b30784d87b --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_user_panel.html.erb @@ -0,0 +1,47 @@ + + +
  • + <%= current_user ? current_user.name(true) : message('layout.user_panel.me') -%> + + + +
  • + + \ No newline at end of file diff --git a/sonar-server/src/main/webapp/javascripts/recent-history.js b/sonar-server/src/main/webapp/javascripts/recent-history.js index ad734f5ce0b..6d4da0f0635 100644 --- a/sonar-server/src/main/webapp/javascripts/recent-history.js +++ b/sonar-server/src/main/webapp/javascripts/recent-history.js @@ -21,8 +21,6 @@ Sonar.RecentHistory.prototype.getRecentHistory = function() { Sonar.RecentHistory.prototype.clear = function () { localStorage.clear(); - $("sonar_recent_history_dropdown").hide(); - this.populateRecentHistoryDropDown(); }; Sonar.RecentHistory.prototype.add = function (resourceKey, resourceName, resourceQualifier) { @@ -47,29 +45,28 @@ Sonar.RecentHistory.prototype.add = function (resourceKey, resourceName, resourc } }; -Sonar.RecentHistory.prototype.populateRecentHistoryDropDown = function () { - var dropdown = $j('#sonar_recent_history_dropdown'); - dropdown.empty(); - - var recentHistory = this.getRecentHistory(); - - recentHistory.forEach(function (resource) { - dropdown.append('
  • ' - + resource['name'] - + '
  • '); - }); +Sonar.RecentHistory.prototype.populateRecentHistoryPanel = function () { + var historyLinksList = $j('#sonar-recent-history-list'); + historyLinksList.empty(); + var recentHistory = this.getRecentHistory(); if (recentHistory.length == 0) { - dropdown.append('
  • ' + this.translations['no_history_yet'] + '
  • '); - } else { - dropdown.append('
  • ' + this.translations['clear'] + '
  • '); + $j("#sonar-recent-history").hide(); + } else { + recentHistory.forEach(function (resource) { + historyLinksList.append('
  • ' + + resource['name'] + + '
  • '); + }); + historyLinksList.append('
  • ' + this.translations['clear'] + '
  • '); + $j("#sonar-recent-history").show(); } }; diff --git a/sonar-server/src/main/webapp/stylesheets/layout.css b/sonar-server/src/main/webapp/stylesheets/layout.css index af735aeb47c..bd5ef65a259 100644 --- a/sonar-server/src/main/webapp/stylesheets/layout.css +++ b/sonar-server/src/main/webapp/stylesheets/layout.css @@ -148,28 +148,34 @@ body, a { padding: 0 5px 0 0; } -#sonar_recent_history_dropdown { - max-width: none !important; +#user-panel { + position: absolute; + float: right; + min-width: 200px; + top: 30px; + right: 180px; + background-color: #fff; + border: 1px solid #ccc; + box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.5); + z-index: 999999; + line-height: 18px; + color: #000; } -#sonar_recent_history_dropdown a { - color: #000 !important; - display: inline !important; - padding-left: 5px !important; +#user-panel > div { + padding: 10px; } -#sonar_recent_history_dropdown li:hover a { - color: #fff !important; +#user-panel a { + color: #000; } -#sonar_recent_history_dropdown li.clear_list { - background-color: #EFEFEF !important; - border-top: 1px solid #CCCCCC !important; - color: #EFEFEF !important; +#sonar-recent-history { + border-top: 1px solid #ccc; } -#sonar_recent_history_dropdown li.clear_list:hover a { - color: #000 !important; +#sonar-recent-history li { + padding-left: 10px; } #nonav { -- 2.39.5