]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6425 Links to project page extensions do not exist in the navigation
authorStas Vilchik <vilchiks@gmail.com>
Thu, 16 Apr 2015 10:16:20 +0000 (12:16 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Thu, 16 Apr 2015 15:17:49 +0000 (17:17 +0200)
(cherry picked from commit 8e95c83)

server/sonar-web/src/main/hbs/nav/nav-context-navbar.hbs
server/sonar-web/src/main/js/nav/context-navbar-view.js
server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_navbar_conf_context.html.erb

index b0b106f1fd65b96ae2b070741d7fc10bdbdc9365..58881d8e9b8f84ea18409b89f8294eb66577fa19 100644 (file)
             <a href="{{link '/comparison/index?resource=' contextKey}}">{{t 'comparison.page'}}</a>
           </li>
         {{/if}}
+        {{#each contextExtensions}}
+          <li>
+            <a href="{{link url}}">{{label}}</a>
+          </li>
+        {{/each}}
       </ul>
     </li>
   </ul>
index 6107a4276a24b080a8e5e17b43af1b7f85d5dbe9..dd31145c4ceffe6ca23cdd308820a46477c1adf8 100644 (file)
@@ -22,8 +22,8 @@ define([
 ], function () {
 
   var $ = jQuery,
-      OVERVIEW_URLS = [
-          '/design', '/libraries', '/dashboards'
+      MORE_URLS = [
+          '/design', '/libraries', '/dashboards', '/plugins/resource'
       ],
       SETTINGS_URLS = [
         '/project/settings', '/project/profile', '/project/qualitygate', '/manual_measures/index',
@@ -61,14 +61,13 @@ define([
     serializeData: function () {
       var href = window.location.href,
           search = window.location.search,
-          isMoreActive = _.some(OVERVIEW_URLS, function (url) {
+          isMoreActive = _.some(MORE_URLS, function (url) {
             return href.indexOf(url) !== -1;
           }) || (href.indexOf('/dashboard') !== -1 && search.indexOf('did=') !== -1),
           isSettingsActive = _.some(SETTINGS_URLS, function (url) {
             return href.indexOf(url) !== -1;
           }),
           isOverviewActive = !isMoreActive && href.indexOf('/dashboard') !== -1 && search.indexOf('did=') === -1;
-
       return _.extend(Marionette.Layout.prototype.serializeData.apply(this, arguments), {
         canManageContextDashboards: !!window.SS.user,
         contextKeyEncoded: encodeURIComponent(this.model.get('contextKey')),
index e1e92313c2b4e3634660c6d0e8e1774b6775f6eb..cbd190fe575947f52bbff5cd722504c666ec6935 100644 (file)
         name: '<%= escape_javascript active_dashboard.dashboard.name(true) -%>'
       }<% if index < dashboards.size - 1 -%>, <% end %>
       <% end %>
+    ],
+    contextExtensions: [
+      <% project_metrics = @project.last_snapshot.metric_keys.to_java(:string) if @project.last_snapshot
+         pages = controller.java_facade.getPages(Navigation::SECTION_RESOURCE.key, @project.scope, @project.qualifier, @project.language, project_metrics)
+         pages.each_with_index do |page, index|
+           page_url = (page.isController() ? "#{page.getId()}?id=#{@project.id}" : "/plugins/resource/#{@project.id}?page=#{page.getId()}")
+      %>
+      {
+        url: '<%= page_url -%>',
+        label: '<%= escape_javascript message(page.getId() + '.page', :default => page.getTitle()) -%>'
+      }<% if index < pages.size - 1 -%>, <% end %>
+      <% end %>
     ]
   });