From 4e14448de2bd354b761c5abc73115efe72e2fa47 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 16 Apr 2015 12:16:20 +0200 Subject: [PATCH] SONAR-6425 Links to project page extensions do not exist in the navigation (cherry picked from commit 8e95c83) --- .../src/main/hbs/nav/nav-context-navbar.hbs | 5 +++++ .../sonar-web/src/main/js/nav/context-navbar-view.js | 7 +++---- .../app/views/layouts/_navbar_conf_context.html.erb | 12 ++++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/server/sonar-web/src/main/hbs/nav/nav-context-navbar.hbs b/server/sonar-web/src/main/hbs/nav/nav-context-navbar.hbs index b0b106f1fd6..58881d8e9b8 100644 --- a/server/sonar-web/src/main/hbs/nav/nav-context-navbar.hbs +++ b/server/sonar-web/src/main/hbs/nav/nav-context-navbar.hbs @@ -70,6 +70,11 @@ {{t 'comparison.page'}} {{/if}} + {{#each contextExtensions}} +
  • + {{label}} +
  • + {{/each}} diff --git a/server/sonar-web/src/main/js/nav/context-navbar-view.js b/server/sonar-web/src/main/js/nav/context-navbar-view.js index 6107a4276a2..dd31145c4ce 100644 --- a/server/sonar-web/src/main/js/nav/context-navbar-view.js +++ b/server/sonar-web/src/main/js/nav/context-navbar-view.js @@ -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')), diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_navbar_conf_context.html.erb b/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_navbar_conf_context.html.erb index e1e92313c2b..cbd190fe575 100644 --- a/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_navbar_conf_context.html.erb +++ b/server/sonar-web/src/main/webapp/WEB-INF/app/views/layouts/_navbar_conf_context.html.erb @@ -29,6 +29,18 @@ 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 %> ] }); -- 2.39.5