1、如果没有新增版本库,点击链接跳至配置--新增

2、已创建过gitlab项目则跳至gitlab 版本库
This commit is contained in:
huang 2015-11-02 15:04:17 +08:00
parent eb3c65f1c6
commit 83486c745e
5 changed files with 85 additions and 76 deletions

View File

@ -215,11 +215,11 @@ update
end
end
unless @repository.gitlab?
# redirect_to to_gitlab_project_repository_path(@project, @repository)
render :to_gitlab
return
end
# unless @repository.gitlab?
# # redirect_to to_gitlab_project_repository_path(@project, @repository)
# render :to_gitlab
# return
# end
#if( !User.current.member_of?(@project) || @project.hidden_repo)
@repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty?

View File

@ -609,6 +609,12 @@ module ApplicationHelper
return @result
end
# 判断版本库是否初始为gitlab
def rep_is_gitlab?(project)
rep = Repository.where("project_id =? and type =?", project, "Repository::Gitlab")
return rep.blank? ? true :false
end
# 判断当前用户是否为项目管理员
def is_project_manager?(user_id, project_id)
@result = false

View File

@ -117,12 +117,6 @@ module ProjectsHelper
end
end
# 判断版本库是否初始为gitlab
def rep_is_gitlab?(project)
rep = Repository.where("project_id =? and type =?", project, "Repository::Gitlab")
return rep.blank? ? true :false
end
# 获取新增gitlab版本库
def rep_gitlab(project)
rep = Repository.where("project_id =? and type =?", project, "Repository::Gitlab")

View File

@ -41,10 +41,14 @@
<%# --版本库被设置成私有、module中设置不显示、没有创建版本库 三种情况不显示-- %>
<% if visible_repository?(@project) %>
<div class="subNav">
<%= link_to l(:project_module_repository), {:controller => 'repositories', :action => 'show', :id => @project.id, to: 'gitlab'}, :class => "f14 c_blue02" %>
<% if rep_is_gitlab?(@project) %>
<%= link_to l(:project_module_repository), {:controller => 'projects', :action => 'settings', :id => @project.id, :tab=>'repositories'}, :class => "f14 c_blue02" %>
<% else %>
<%= link_to l(:project_module_repository), {:controller => 'repositories', :action => 'show', :id => @project.id }, :class => "f14 c_blue02" %>
<% end %>
<a class="subnav_num">(<%= @project.repositories.count %>)</a>
<% if (User.current.admin? || User.current.allowed_to?({:controller => 'projects', :action => 'settings'}, @project)) && rep_is_gitlab?(@project) %>
<%= link_to "+"+l(:project_module_create_repository), url_for(:controller => 'projects', :action => 'settings', :id => @project.id,:tab=>'repositories') , :class => "subnav_green" %>
<%= link_to "+"+l(:project_module_create_repository), url_for(:controller => 'projects', :action => 'settings', :id => @project.id, :tab=>'repositories') , :class => "subnav_green" %>
<% end %>
</div>
<% end %>

View File

@ -7,74 +7,79 @@
<%= str = error_messages_for 'repository' %>
<% project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT %>
<% ip = RepositoriesHelper::REPO_IP_ADDRESS %><!--Added by tanxianbo For formatting project's path-->
<% if @project.repositories.any? %>
<%= render :partial => 'projects/settings/rep_gitlab', :locals => {:project => @project, :ip => "ip", :project_path_cut => "project_path_cut" } %>
<%#= render :partial => 'projects/settings/rep_forge', :locals => {:project => @project, :ip => "ip", :project_path_cut => "project_path_cut" } %>
<div class="rep_history_title">历史版本库</div>
<table class="pro_table">
<tbody>
<% rep_forge(@project).sort.each do |repository| %>
<tr class="<%= cycle 'pro_table_on', '' %>">
<td class="w150"><span class="rep_history_grey" title="<%= repository.identifier %>">
<%# 新建版本库 %>
<div style="padding-bottom: 40px">
<% if @project.repositories.count == 0 || rep_is_gitlab?(@project) %>
<a href="javascript:viod(0)" class="pic_add fl mr5" onclick="pro_st_show_ku();"></a>
<a href="javascript:viod(0)" class="c_blue fl" onclick="pro_st_show_ku();">
<% course_tag = @project.project_type %>
<% if User.current.allowed_to?(:manage_repository, @project) %>
<!--newrepo_project_repository_path(@project, :course => course_tag) -->
<%= link_to l(:label_repository_new_repos),"#" , :onclick=>"pro_st_show_ku();", :class => 'c_blue fl' %></p>
<% end %>
</a>
<div class="cl"></div>
<%= labelled_form_for :repository, @repository, :url =>project_repositories_path(@project),:html => {:id => 'repository-form',:method=>"post",:autocomplete=>'off'} do |f| %>
<div id="pro_st_edit_ku" class="pro_st_edit_ku">
<ul>
<li >
<label class="label02"><%=l(:label_scm)%></label>
<%= select_tag('repository_scm',
options_for_select(["Git"],@repository.class.name.demodulize),
:data => {:remote => true, :method => 'get'})%>
<% if @repository && ! @repository.class.scm_available %>
<span class="c_grey"><%= l(:text_scm_command_not_available) %></span>
<% end %>
</li>
<li >
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
<label class="label02"><span class="c_red">*</span><%=l(:label_repository_name)%></label>
<%= f.text_field :identifier, :disabled =>@repository.nil? || @repository.identifier_frozen? ? true:false,:label=>"", :no_label => true %>
<% unless @repository.identifier_frozen? %>
<span class="c_grey"><%=l(:text_length_between,:min=>1,:max=>254)<<l(:text_project_identifier_info) %></span>
<% end %>
</li>
<div class="cl"></div>
</ul>
<a href="#" onclick="$('#repository-form').submit();" class="blue_btn fl ml110"><%=l(:button_save)%></a>
<a href="<%= settings_project_path(@project, :tab => 'repositories')%>" class="grey_btn fl ml10"><%=l(:button_cancel)%></a>
</div><!--pro_st_edit_issues end-->
<% end %>
<% end %>
</div>
<% if @project.repositories.any? %>
<%= render :partial => 'projects/settings/rep_gitlab', :locals => {:project => @project, :ip => "ip", :project_path_cut => "project_path_cut" } %>
<%#= render :partial => 'projects/settings/rep_forge', :locals => {:project => @project, :ip => "ip", :project_path_cut => "project_path_cut" } %>
<div class="rep_history_title">历史版本库</div>
<table class="pro_table">
<tbody>
<% rep_forge(@project).sort.each do |repository| %>
<tr class="<%= cycle 'pro_table_on', '' %>">
<td class="w150"><span class="rep_history_grey" title="<%= repository.identifier %>">
<%= repository.identifier %></span></td>
<td class="w150"><span class="rep_history_grey"><%=h repository.scm_name %></span></td>
<%if repository.scm_name=="Git"%>
<td class="w360" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" title="http://<%= repository.login.to_s %>_<%= repository.identifier.to_s%>@<%= ip %>
<td class="w150"><span class="rep_history_grey"><%=h repository.scm_name %></span></td>
<%if repository.scm_name=="Git"%>
<td class="w362" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" title="http://<%= repository.login.to_s %>_<%= repository.identifier.to_s%>@<%= ip %>
<%=h repository.url.slice(project_path_cut, repository.url.length) %>">
<span class="rep_history_grey">
<%=truncate( 'http://' << repository.login.to_s << '_'<< repository.identifier.to_s << '@'<< ip.to_s << h( repository.url.slice(project_path_cut, repository.url.length)),:length=>60) %>
</span>
</td><!--Modified by tanxianbo-->
<%else %>
<td class="w360" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" ><%=h truncate(repository.url,:length=>10) %></td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<p class="nodata"><%= l(:label_repository_no_data) %></p>
<% end %>
<%# 新建版本库 %>
<% if @project.repositories.count == 0 || rep_is_gitlab?(@project) %>
<a href="javascript:viod(0)" class="pic_add fl mr5" onclick="pro_st_show_ku();"></a>
<a href="javascript:viod(0)" class="c_blue fl" onclick="pro_st_show_ku();">
<% course_tag = @project.project_type %>
<% if User.current.allowed_to?(:manage_repository, @project) %>
<!--newrepo_project_repository_path(@project, :course => course_tag) -->
<%= link_to l(:label_repository_new_repos),"#" , :onclick=>"pro_st_show_ku();", :class => 'c_blue fl' %></p>
<% end %>
</a>
<div class="cl"></div>
<%= labelled_form_for :repository, @repository, :url =>project_repositories_path(@project),:html => {:id => 'repository-form',:method=>"post",:autocomplete=>'off'} do |f| %>
<div id="pro_st_edit_ku" class="pro_st_edit_ku">
<ul>
<li >
<label class="label02"><%=l(:label_scm)%></label>
<%= select_tag('repository_scm',
options_for_select(["Git"],@repository.class.name.demodulize),
:data => {:remote => true, :method => 'get'})%>
<% if @repository && ! @repository.class.scm_available %>
<span class="c_grey"><%= l(:text_scm_command_not_available) %></span>
</td><!--Modified by tanxianbo-->
<%else %>
<td class="w360" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" ><%=h truncate(repository.url,:length=>10) %></td>
<% end %>
</li>
<li >
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
<label class="label02"><span class="c_red">*</span><%=l(:label_repository_name)%></label>
<%= f.text_field :identifier, :disabled =>@repository.nil? || @repository.identifier_frozen? ? true:false,:label=>"", :no_label => true %>
<% unless @repository.identifier_frozen? %>
<span class="c_grey"><%=l(:text_length_between,:min=>1,:max=>254)<<l(:text_project_identifier_info) %></span>
<% end %>
</li>
<div class="cl"></div>
</ul>
<a href="#" onclick="$('#repository-form').submit();" class="blue_btn fl ml110"><%=l(:button_save)%></a>
<a href="<%= settings_project_path(@project, :tab => 'repositories')%>" class="grey_btn fl ml10"><%=l(:button_cancel)%></a>
</div><!--pro_st_edit_issues end-->
<% end %>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<p class="nodata"><%= l(:label_repository_no_data) %></p>
<% end %>
<% end %>