]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3676 Improve Links page
authorFabrice Bellingard <fabrice.bellingard@sonarsource.com>
Fri, 5 Oct 2012 13:33:52 +0000 (15:33 +0200)
committerFabrice Bellingard <fabrice.bellingard@sonarsource.com>
Fri, 5 Oct 2012 13:33:52 +0000 (15:33 +0200)
sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/views/project/links.html.erb

index 5e59296c6e3f882cdc32c3f7aadb467303516f9a..adcabe47bd48237d07fe78b6cf03e036a6d9d0e2 100644 (file)
@@ -206,7 +206,7 @@ class ProjectController < ApplicationController
   def set_links
     project = get_current_project(params[:project_id])
 
-    project.links.clear
+    project.custom_links.each {|link| link.delete}
 
     params.each_pair do |param_key, value|
       if (param_key.starts_with?('name_'))
index 47479d9c8fc1d220fef02b76ae1a4ceeee5edc86..e3bd566ee78ead5ed94e42ca0d5a86c3dfade351 100644 (file)
@@ -1,5 +1,16 @@
 <h1>Project Links</h1>
 <br/>
+
+<style>
+#widget_links td, #widget_links th {
+  white-space: nowrap;
+  vertical-align: top;
+  text-align: left;
+  padding-left: 20px;
+  padding-right: 20px;
+}
+</style>
+
 <div class="yui-g widget" id="widget_links">
 
 <% form_for( 'set_links', :url => { :action => 'set_links', :project_id => @project.id } ) do |form|
        links_by_key[link.link_type]=link  
      end
 %>
  <div class="yui-u first">
-  <table class="data">
-    <thead><tr><th>Title</th><th>URL</th></tr></thead>
+ <div class="yui-u first">
+   <table class="data">
+     <thead><tr><th >Title</th><th width="100%">URL</th></tr></thead>
 
-    <tr class="even">
-      <td align="left" nowrap width="1%">
-        <%= image_tag("links/homepage.png") -%> Home</td>
+     <tr class="even">
+      <td>
+        <%= image_tag("links/homepage.png") -%> <%= message('project_links.homepage') -%>
+        <br/>
+        <span class="note" style="margin-left: 20px">sonar.links.homepage</span>
+      </td>
         <td>
-            <input type="hidden" name="key_homepage" value="homepage" />
-            <input type="hidden" name="name_homepage" value="Home" />
-            <%= text_field_tag( "url_homepage", links_by_key['homepage'] ? links_by_key['homepage'].href : '', :readonly => true, :size => 30  ) -%>
+          <%
+            link = links_by_key['homepage'] ? links_by_key['homepage'].href : ''
+            if link.starts_with?("http")
+              link = "<a href=\"#{h link}\">#{h link}</a>"
+            end
+          %>        
+          <%= link -%>
         </td>
      </tr>
      <tr class="odd">
-      <td align="left" nowrap width="1%">
-        <%= image_tag("links/ci.png") -%> Continuous integration</td>
+      <td>
+        <%= image_tag("links/ci.png") -%> <%= message('project_links.ci') -%>
+        <br/>
+        <span class="note" style="margin-left: 20px">sonar.links.ci</span>        
+      </td>
         <td>
-           <input type="hidden" name="key_ci" value="ci" />
-           <input type="hidden" name="name_ci" value="Continuous integration" />
-            <%= text_field_tag( "url_ci", links_by_key['ci'] ? links_by_key['ci'].href : '', :readonly => true, :size => 30 ) -%>
+          <%
+            link = links_by_key['ci'] ? links_by_key['ci'].href : ''
+            if link.starts_with?("http")
+              link = "<a href=\"#{h link}\">#{h link}</a>"
+            end
+          %>        
+          <%= link -%>
         </td>
      </tr>
      <tr class="even">
-      <td align="left" nowrap width="1%">
-        <%= image_tag("links/issue.png") -%> Issue tracker</td>
+      <td>
+        <%= image_tag("links/issue.png") -%> <%= message('project_links.issue') -%>
+        <br/>
+        <span class="note" style="margin-left: 20px">sonar.links.issue</span>        
+      </td>
         <td>
-           <input type="hidden" name="key_issue" value="issue" />
-           <input type="hidden" name="name_issue" value="Issues" />
-            <%= text_field_tag( "url_issue", links_by_key['issue'] ? links_by_key['issue'].href : '', :readonly => true, :size => 30  ) -%>
+          <%
+            link = links_by_key['issue'] ? links_by_key['issue'].href : ''
+            if link.starts_with?("http")
+              link = "<a href=\"#{h link}\">#{h link}</a>"
+            end
+          %>        
+          <%= link -%>
         </td>
      </tr>
      <tr class="odd">
-      <td align="left" nowrap width="1%">
-        <%= image_tag("links/scm.png") -%> Sources</td>
+      <td>
+        <%= image_tag("links/scm.png") -%> <%= message('project_links.scm') -%>
+        <br/>
+        <span class="note" style="margin-left: 20px">sonar.links.scm</span>        
+      </td>
         <td>
-           <input type="hidden" name="key_scm" value="scm" />
-           <input type="hidden" name="name_scm" value="Sources" />
-            <%= text_field_tag( "url_scm", links_by_key['scm'] ? links_by_key['scm'].href : '', :readonly => true, :size => 30  ) -%>
+          <%
+            link = links_by_key['scm'] ? links_by_key['scm'].href : ''
+            if link.starts_with?("http")
+              link = "<a href=\"#{h link}\">#{h link}</a>"
+            end
+          %>        
+          <%= link -%>
         </td>
      </tr>
      <tr class="even">
-      <td align="left" nowrap width="1%">
-        <%= image_tag("links/scm_dev.png") -%> Developer connection</td>
+      <td>
+        <%= image_tag("links/scm_dev.png") -%> <%= message('project_links.scm_dev') -%>
+        <br/>
+        <span class="note" style="margin-left: 20px">sonar.links.scm_dev</span>        
+      </td>
         <td>
-           <input type="hidden" name="key_scm_dev" value="scm_dev" />
-           <input type="hidden" name="name_scm_dev" value="Developer connection" />
-            <%= text_field_tag( "url_scm_dev", links_by_key['scm_dev'] ? links_by_key['scm_dev'].href : '', :readonly => true, :size => 30  ) -%>
+          <%
+            link = links_by_key['scm_dev'] ? links_by_key['scm_dev'].href : ''
+            if link.starts_with?("http")
+              link = "<a href=\"#{h link}\">#{h link}</a>"
+            end
+          %>        
+          <%= link -%>
         </td>
      </tr>
-   </table>
-   <br/>
-   <%= submit_tag( "Save links" ) %>
- </div>
-    <div class="yui-u">
-      <table class="data">
-        <thead><tr><th>Title</th><th>URL</th></tr></thead>
+
        <% index = 0
          @project.custom_links.each do |custom_link|
            index += 1 %>
-        <tr class="<%= cycle('even','odd') -%>">
+        <tr class="<%= cycle('odd','even') -%>">
           <td align="left">
             <%= image_tag("links/external.png") -%> <%= text_field_tag( "name_#{index}", h(custom_link.name), :size => 15 ) -%>
           </td>
       <% end %>
       <% index += 1
          for var in index..5 %>
-        <tr class="<%= cycle('even','odd') -%>">
+        <tr class="<%= cycle('odd','even') -%>">
             <td align="left"><%= image_tag("links/external.png") -%>  <%= text_field_tag( "name_#{var}", '', :size => 15) %></td>
             <td><%= text_field_tag( "url_#{var}", '', :size => 30 ) %></td>
         </tr>
       <% end %>
-      </table>
-    </div>
+   </table>
+   <br/>
+   <%= submit_tag( "Save links" ) %>
+ </div>
 <% end %>
 </div>
\ No newline at end of file