Skip to content

Commit 83e1880

Browse files
author
root
committed
Improve RepositoryGitConfigKey::GitConfig form
1 parent f93bd22 commit 83e1880

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Diff for: app/controllers/repository_git_config_keys_controller.rb

+5-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def index
1616

1717

1818
def new
19-
@git_config_key = @repository.git_keys.new
19+
@git_config_key = @repository.send(key_type).new
2020
end
2121

2222

@@ -51,10 +51,11 @@ def destroy
5151

5252

5353
def key_type
54-
case params[:repository_git_config_key][:type]
55-
when 'RepositoryGitConfigKey::GitConfig'
54+
type = params[:type] || params[:repository_git_config_key][:type]
55+
case type
56+
when 'RepositoryGitConfigKey::GitConfig', 'git_config'
5657
:git_config_keys
57-
when 'RepositoryGitConfigKey::Option'
58+
when 'RepositoryGitConfigKey::Option', 'git_option'
5859
:git_option_keys
5960
else
6061
:git_keys

Diff for: app/views/repository_git_config_keys/index.html.haml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
%div
22

33
- if User.current.git_allowed_to?(:create_repository_git_config_keys, @repository)
4-
.contextual= link_to l(:label_git_config_key_add), new_repository_git_config_key_path(@repository), class: 'icon icon-add modal-box'
4+
.contextual= link_to l(:label_git_config_key_add), new_repository_git_config_key_path(@repository, type: 'git_config'), class: 'icon icon-add modal-box'
55

66
%h3
77
= l(:label_git_config_keys)
88
= link_to "(#{l(:label_gitolite_documentation)})", 'http://gitolite.com/gitolite/git-config.html', target: '_blank'
99

1010
= render 'config_keys', git_config_keys: @repository_git_config_keys
1111

12+
1213
- if User.current.git_allowed_to?(:create_repository_git_config_keys, @repository)
13-
.contextual= link_to l(:label_git_option_key_add), new_repository_git_config_key_path(@repository), class: 'icon icon-add modal-box'
14+
.contextual= link_to l(:label_git_option_key_add), new_repository_git_config_key_path(@repository, type: 'git_option'), class: 'icon icon-add modal-box'
1415

1516
%h3
1617
= l(:label_git_option_keys)
1718
= link_to "(#{l(:label_gitolite_documentation)})", 'http://gitolite.com/gitolite/options.html', target: '_blank'
19+
1820
= render 'config_keys', git_config_keys: @repository_git_option_keys

0 commit comments

Comments
 (0)