]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2342 Create a user panel to gather information
authorFabrice Bellingard <fabrice.bellingard@sonarsource.com>
Wed, 21 Nov 2012 15:13:02 +0000 (16:13 +0100)
committerFabrice Bellingard <fabrice.bellingard@sonarsource.com>
Wed, 21 Nov 2012 16:11:35 +0000 (17:11 +0100)
plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_resource_history.html.erb [deleted file]
sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_user_panel.html.erb [new file with mode: 0644]
sonar-server/src/main/webapp/javascripts/recent-history.js
sonar-server/src/main/webapp/stylesheets/layout.css

index 18cdbac7b8f4ef600014ba001fc1724944b6852b..f23df0c35cbda5b93f295875b3d0dbf045a3406e 100644 (file)
@@ -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
index 5aaed32bc8b3c5b436d80e01e816be5993f1f03e..45e0122883e9206d1800dd45f93d40299dc5d393 100644 (file)
       <li>
         <a href="javascript:window.print()"><img src="<%= ApplicationController.root_context -%>/images/print.gif" alt="<%= message('layout.print') -%>" title="<%= message('layout.print') -%>"/></a>
       </li>
-      <% if logged_in? %>
-        <li>
-          <img src="<%= ApplicationController.root_context -%>/images/user.gif"/><a href="<%= ApplicationController.root_context -%>/account/index"><%= current_user.name(true) -%></a>
-          &raquo; <a href="<%= ApplicationController.root_context -%>/sessions/logout"><%= message('layout.logout') -%></a>
-        </li>
-      <% else %>
+      <% unless logged_in? %>
         <li><a href="<%= ApplicationController.root_context -%>/sessions/new?return_to=<%= u (request.request_uri) -%>"><%= message('layout.login') -%></a></li>
       <% end %>
+      <%= render 'layouts/user_panel' -%>
       <li><a href="<%= ApplicationController.root_context -%>/profiles"><%= message('layout.configuration') -%></a></li>
-      <%= render 'layouts/resource_history' -%>
     </ul>
   </div>
   <div id="searchResourcesResults" class="autocomplete" style="display:none"></div>
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 (file)
index ae8dfd5..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-<script>
-  if (supports_html5_storage()) {
-    var sonarRecentHistory = new Sonar.RecentHistory('<%= ApplicationController.root_context -%>')
-                                      .addTranslation('clear', '<%= message('layout.recent_history.clear') -%>')
-                                      .addTranslation('no_history_yet', '<%= message('layout.recent_history.no_history_yet') -%>');
-  }
-</script>
-
-<div class="dropdown" id="sonar_recent_history_div">
-  <a href="#" class="link-more" onclick="sonarRecentHistory.populateRecentHistoryDropDown(); $('sonar_recent_history_dropdown').toggle();return false;"><%= message('layout.recent_history.link') -%></a>
-  
-  <ul style="display: none" class="dropdown-menu" id="sonar_recent_history_dropdown" onmouseout="this.hide();" onmouseover="this.show();">
-  </ul>
-</div>
-
-<script>
-  if (sonarRecentHistory == null) {
-    $j('#sonar_recent_history_div').detach();
-  } else {
-    sonarRecentHistory.add('<%= @resource ? @resource.key : "" -%>', 
-                           '<%= @resource ? @resource.name(true) : "" -%>', 
-                           '<%= @resource ? @resource.qualifier : "" -%>');
-  }
-</script>
\ 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 (file)
index 0000000..5b30784
--- /dev/null
@@ -0,0 +1,47 @@
+<script>
+  if (supports_html5_storage()) {
+    var sonarRecentHistory = new Sonar.RecentHistory('<%= ApplicationController.root_context -%>')
+                                      .addTranslation('clear', '<%= message('layout.user_panel.recent_history.clear') -%>');
+  }
+</script>
+
+<li>
+  <a href="#" class="link-more" onclick="if (sonarRecentHistory) { sonarRecentHistory.populateRecentHistoryPanel(); }; $j('#user-panel').toggle(); return false;"><%= current_user ? current_user.name(true) : message('layout.user_panel.me') -%></a>
+  
+  <div id="user-panel" style="display: none" onmouseout="$j(this).hide();" onmouseover="$j(this).show();">
+    <div id="user-details">
+      <% if current_user %>
+        <b><%= current_user.name(true) -%></b>
+        <% if current_user.email %>
+          <br/>
+          <span class="note"><%= current_user.email -%></span>
+        <% end %>
+        <br/>
+        <a href="<%= ApplicationController.root_context -%>/account/index" class="link-action"><%= message('layout.user_panel.my_profile') -%></a>
+        &nbsp;–&nbsp;
+        <a href="<%= ApplicationController.root_context -%>/sessions/logout" class="link-action" onclick="if (sonarRecentHistory) { sonarRecentHistory.clear(); };"><%= message('layout.logout') -%></a>
+      <% else %>
+        <b><%= message('layout.user_panel.anonymous_user') -%></b>
+        <br/>
+        <span class="note"><%= message('layout.user_panel.non_authenticated_user') -%></span>
+      <% end %>
+    </div>
+    
+    <div id="sonar-recent-history" style="display: none">
+      <b><%= message('layout.user_panel.recent_history.title') -%></b>
+      <ul id="sonar-recent-history-list">
+      </ul>            
+    </div>
+  </div>
+  
+</li>
+
+<script>
+  if (sonarRecentHistory == null) {
+    $j('#sonar-recent-history').detach();
+  } else {
+    sonarRecentHistory.add('<%= @resource ? @resource.key : "" -%>', 
+                           '<%= @resource ? @resource.name(true) : "" -%>', 
+                           '<%= @resource ? @resource.qualifier : "" -%>');
+  }
+</script>
\ No newline at end of file
index ad734f5ce0b10dd0e18fde7ac6015395003a89df..6d4da0f0635e278345e5254d50496e0e687c2fc1 100644 (file)
@@ -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('<li><img width="16" height="16" src="'
-                          + sonarRecentHistory.appContext
-                          + '/images/q/'
-                          + resource['qualifier']
-                          + '.png"><a href="'
-                          + sonarRecentHistory.appContext
-                          + '/dashboard/index/'
-                          + resource['key']
-                          + '">' 
-                          + resource['name'] 
-                          + '</a></li>');
-  });
+Sonar.RecentHistory.prototype.populateRecentHistoryPanel = function () {
+  var historyLinksList = $j('#sonar-recent-history-list');
+  historyLinksList.empty();
   
+  var recentHistory = this.getRecentHistory();  
   if (recentHistory.length == 0) {
-    dropdown.append('<li style="color: #000 !important">' + this.translations['no_history_yet'] + '</li>');
-  } else {
-    dropdown.append('<li class="clear_list"><a href="#" onclick="sonarRecentHistory.clear(); return false;">' + this.translations['clear'] + '</a></li>');
+    $j("#sonar-recent-history").hide();
+  } else {    
+    recentHistory.forEach(function (resource) {
+      historyLinksList.append('<li><img width="16" height="16" src="'
+                            + sonarRecentHistory.appContext
+                            + '/images/q/'
+                            + resource['qualifier']
+                            + '.png"><a href="'
+                            + sonarRecentHistory.appContext
+                            + '/dashboard/index/'
+                            + resource['key']
+                            + '"> ' 
+                            + resource['name'] 
+                            + '</a></li>');
+    });
+    historyLinksList.append('<li><a href="#" onclick="sonarRecentHistory.clear(); sonarRecentHistory.populateRecentHistoryPanel(); return false;" style="color: #777777 !important;">' + this.translations['clear'] + '</a></li>');
+    $j("#sonar-recent-history").show();
   }
 };
index af735aeb47ca2c422d47f396b5cbc20999814c96..bd5ef65a2598c8cd6a43557daaf190a15cbe86db 100644 (file)
@@ -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 {