Defect #33953

Repository Tab will not showing if no repository is set as "Main repository"

Added by Jethro Yu about 1 year ago. Updated 11 months ago.

Status:ConfirmedStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:SCM
Target version:Candidate for next major release
Resolution: Affected version:4.1.1

Description

I suggest that:

  • if there are any repositories in project, the "Repository Tab" button should show on main menu.
  • if no repository is set with "Main repository" and there is only one repository, the page should show the only repository by default.
  • if no repository is set with "Main repository" and there is multiple repositories, a blank page with Repositories sidebar should show.

fixed-33953.patch Magnifier (4.09 KB) Yuichi HARADA, 2020-11-06 08:27


Related issues

Related to Redmine - Defect #14506: Multiple repositories not visible if main repository is e... New

History

#1 Updated by Go MAEDA about 1 year ago

  • Category changed from UI to SCM
  • Status changed from New to Confirmed

#2 Updated by Go MAEDA about 1 year ago

  • Related to Defect #14506: Multiple repositories not visible if main repository is empty added

#3 Updated by Yuichi HARADA 12 months ago

This issue and #14506 need to be resolved together. I created the following patch.

diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index b0108d531..4ceeaf014 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -321,7 +321,7 @@ class RepositoriesController < ApplicationController
     if params[:repository_id].present?
       @repository = @project.repositories.find_by_identifier_param(params[:repository_id])
     else
-      @repository = @project.repository
+      @repository = @project.repository || @project.repositories.first
     end
     (render_404; return false) unless @repository
     @path = params[:path].is_a?(Array) ? params[:path].join('/') : params[:path].to_s
diff --git a/lib/redmine.rb b/lib/redmine.rb
index de2993e13..470b5ae41 100644
--- a/lib/redmine.rb
+++ b/lib/redmine.rb
@@ -346,7 +346,7 @@ Redmine::MenuManager.map :project_menu do |menu|
   menu.push :repository,
             {:controller => 'repositories', :action => 'show',
              :repository_id => nil, :path => nil, :rev => nil},
-            :if => Proc.new {|p| p.repository && !p.repository.new_record?}
+            :if => Proc.new {|p| p.repositories.any?{|r| !r.new_record?}}
   menu.push :settings, {:controller => 'projects', :action => 'settings'},
             :last => true
 end

#4 Updated by Go MAEDA 11 months ago

  • Target version set to Candidate for next major release

Also available in: Atom PDF