summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorJose Ivan Vargas <jvargas@gitlab.com>2017-01-23 18:28:40 -0600
committerJose Ivan Vargas <jvargas@gitlab.com>2017-03-06 09:47:43 -0600
commit0b74ae849d3f87564e789673ecf67aa54ec7cd8a (patch)
tree2bf4220555d8953d16cbc378923f4edf8617bdb3 /app
parentc51d72036698c6d53602c58f09d5ddd3ed8d225b (diff)
downloadgitlab-ce-0b74ae849d3f87564e789673ecf67aa54ec7cd8a.tar.gz
Created the gear settings entry and created a way to initialize both sections with one controller
Changed views to partials, created the repository view, created a repository_helper to further aid the creation of variables across different controllers
Diffstat (limited to 'app')
-rw-r--r--app/controllers/projects/deploy_keys_controller.rb9
-rw-r--r--app/controllers/projects/protected_branches_controller.rb7
-rw-r--r--app/controllers/projects/settings/repository_controller.rb36
-rw-r--r--app/helpers/repository_helper.rb13
-rw-r--r--app/views/layouts/nav/_project_settings.html.haml10
-rw-r--r--app/views/projects/deploy_keys/_index.html.haml (renamed from app/views/projects/deploy_keys/index.html.haml)6
-rw-r--r--app/views/projects/protected_branches/_branches_list.html.haml2
-rw-r--r--app/views/projects/protected_branches/_create_protected_branch.html.haml2
-rw-r--r--app/views/projects/protected_branches/_index.html.haml (renamed from app/views/projects/protected_branches/index.html.haml)4
-rw-r--r--app/views/projects/settings/repository/show.html.haml6
10 files changed, 68 insertions, 27 deletions
diff --git a/app/controllers/projects/deploy_keys_controller.rb b/app/controllers/projects/deploy_keys_controller.rb
index b094491e006..07410afd99a 100644
--- a/app/controllers/projects/deploy_keys_controller.rb
+++ b/app/controllers/projects/deploy_keys_controller.rb
@@ -7,12 +7,11 @@ class Projects::DeployKeysController < Projects::ApplicationController
layout "project_settings"
def index
- @key = DeployKey.new
- set_index_vars
+ redirect_to namespace_project_settings_repository_path(@project.namespace, @project)
end
def new
- redirect_to namespace_project_deploy_keys_path(@project.namespace, @project)
+ redirect_to namespace_project_settings_repository_path(@project.namespace, @project)
end
def create
@@ -20,7 +19,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
set_index_vars
if @key.valid? && @project.deploy_keys << @key
- redirect_to namespace_project_deploy_keys_path(@project.namespace, @project)
+ redirect_to namespace_project_settings_repository_path(@project.namespace, @project)
else
render "index"
end
@@ -29,7 +28,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
def enable
Projects::EnableDeployKeyService.new(@project, current_user, params).execute
- redirect_to namespace_project_deploy_keys_path(@project.namespace, @project)
+ redirect_to namespace_project_settings_repository_path(@project.namespace, @project)
end
def disable
diff --git a/app/controllers/projects/protected_branches_controller.rb b/app/controllers/projects/protected_branches_controller.rb
index 2f422d352ed..18d25f91c96 100644
--- a/app/controllers/projects/protected_branches_controller.rb
+++ b/app/controllers/projects/protected_branches_controller.rb
@@ -8,14 +8,13 @@ class Projects::ProtectedBranchesController < Projects::ApplicationController
layout "project_settings"
def index
- @protected_branch = @project.protected_branches.new
- load_gon_index
+ redirect_to namespace_project_settings_repository_path(@project.namespace, @project)
end
def create
@protected_branch = ::ProtectedBranches::CreateService.new(@project, current_user, protected_branch_params).execute
if @protected_branch.persisted?
- redirect_to namespace_project_protected_branches_path(@project.namespace, @project)
+ redirect_to namespace_project_settings_repository_path(@project.namespace, @project)
else
load_protected_branches
load_gon_index
@@ -45,7 +44,7 @@ class Projects::ProtectedBranchesController < Projects::ApplicationController
@protected_branch.destroy
respond_to do |format|
- format.html { redirect_to namespace_project_protected_branches_path }
+ format.html { redirect_to namespace_project_settings_repository_path }
format.js { head :ok }
end
end
diff --git a/app/controllers/projects/settings/repository_controller.rb b/app/controllers/projects/settings/repository_controller.rb
index 1c2eab682e0..3b04eb04ae0 100644
--- a/app/controllers/projects/settings/repository_controller.rb
+++ b/app/controllers/projects/settings/repository_controller.rb
@@ -1,8 +1,42 @@
module Projects
module Settings
class RepositoryController < Projects::ApplicationController
+ include RepositoryHelper
+
+ before_action :authorize_admin_project!
+ before_action :load_protected_branches, only: [:show]
+
def show
-
+ define_deploy_keys_variables
+ define_protected_branches_controller
+ end
+
+ def load_protected_branches
+ @protected_branches = @project.protected_branches.order(:name).page(params[:page])
+ end
+
+ def set_index_vars
+ @enabled_keys ||= @project.deploy_keys
+
+ @available_keys ||= current_user.accessible_deploy_keys - @enabled_keys
+ @available_project_keys ||= current_user.project_deploy_keys - @enabled_keys
+ @available_public_keys ||= DeployKey.are_public - @enabled_keys
+
+ # Public keys that are already used by another accessible project are already
+ # in @available_project_keys.
+ @available_public_keys -= @available_project_keys
+ end
+
+ private
+
+ def define_deploy_keys_variables
+ @key = DeployKey.new
+ set_index_vars
+ end
+
+ def define_protected_branches_controller
+ @protected_branch = @project.protected_branches.new
+ load_gon_index(@project)
end
end
end
diff --git a/app/helpers/repository_helper.rb b/app/helpers/repository_helper.rb
new file mode 100644
index 00000000000..fb9d9b26950
--- /dev/null
+++ b/app/helpers/repository_helper.rb
@@ -0,0 +1,13 @@
+module RepositoryHelper
+ def access_levels_options
+ {
+ push_access_levels: ProtectedBranch::PushAccessLevel.human_access_levels.map { |id, text| { id: id, text: text, before_divider: true } },
+ merge_access_levels: ProtectedBranch::MergeAccessLevel.human_access_levels.map { |id, text| { id: id, text: text, before_divider: true } }
+ }
+ end
+
+ def load_gon_index(project)
+ params = { open_branches: project.open_branches.map { |br| { text: br.name, id: br.name, title: br.name } } }
+ gon.push(params.merge(access_levels_options))
+ end
+end
diff --git a/app/views/layouts/nav/_project_settings.html.haml b/app/views/layouts/nav/_project_settings.html.haml
index 665725f6862..6f2777d1be6 100644
--- a/app/views/layouts/nav/_project_settings.html.haml
+++ b/app/views/layouts/nav/_project_settings.html.haml
@@ -4,18 +4,14 @@
%span
Members
- if can_edit
- = nav_link(controller: :deploy_keys) do
- = link_to namespace_project_deploy_keys_path(@project.namespace, @project), title: 'Deploy Keys' do
+ = nav_link(controller: :repository) do
+ = link_to namespace_project_settings_repository_path(@project.namespace, @project), title: 'Repository' do
%span
- Deploy Keys
+ Repository
= nav_link(controller: :integrations) do
= link_to namespace_project_settings_integrations_path(@project.namespace, @project), title: 'Integrations' do
%span
Integrations
- = nav_link(controller: :protected_branches) do
- = link_to namespace_project_protected_branches_path(@project.namespace, @project), title: 'Protected Branches' do
- %span
- Protected Branches
- if @project.feature_available?(:builds, current_user)
= nav_link(controller: :ci_cd) do
diff --git a/app/views/projects/deploy_keys/index.html.haml b/app/views/projects/deploy_keys/_index.html.haml
index 04fbb37d93f..57de5be89cc 100644
--- a/app/views/projects/deploy_keys/index.html.haml
+++ b/app/views/projects/deploy_keys/_index.html.haml
@@ -1,15 +1,13 @@
-- page_title "Deploy Keys"
-
.row.prepend-top-default
.col-lg-3.profile-settings-sidebar
%h4.prepend-top-0
- = page_title
+ Deploy Keys
%p
Deploy keys allow read-only access to your repository. Deploy keys can be used for CI, staging or production servers. You can create a deploy key or add an existing one.
.col-lg-9
%h5.prepend-top-0
Create a new deploy key for this project
- = render "form"
+ = render "projects/deploy_keys/form"
.col-lg-9.col-lg-offset-3
%hr
.col-lg-9.col-lg-offset-3.append-bottom-default.deploy-keys
diff --git a/app/views/projects/protected_branches/_branches_list.html.haml b/app/views/projects/protected_branches/_branches_list.html.haml
index 04b19a8c5a7..cf0db943865 100644
--- a/app/views/projects/protected_branches/_branches_list.html.haml
+++ b/app/views/projects/protected_branches/_branches_list.html.haml
@@ -23,6 +23,6 @@
- if can_admin_project
%th
%tbody
- = render partial: @protected_branches, locals: { can_admin_project: can_admin_project }
+ = render partial: 'projects/protected_branches/protected_branch', collection: @protected_branches, locals: { can_admin_project: can_admin_project}
= paginate @protected_branches, theme: 'gitlab'
diff --git a/app/views/projects/protected_branches/_create_protected_branch.html.haml b/app/views/projects/protected_branches/_create_protected_branch.html.haml
index e95a3b1b4c3..b8e885b4d9a 100644
--- a/app/views/projects/protected_branches/_create_protected_branch.html.haml
+++ b/app/views/projects/protected_branches/_create_protected_branch.html.haml
@@ -10,7 +10,7 @@
= f.label :name, class: 'col-md-2 text-right' do
Branch:
.col-md-10
- = render partial: "dropdown", locals: { f: f }
+ = render partial: "projects/protected_branches/dropdown", locals: { f: f }
.help-block
= link_to 'Wildcards', help_page_path('user/project/protected_branches', anchor: 'wildcard-protected-branches')
such as
diff --git a/app/views/projects/protected_branches/index.html.haml b/app/views/projects/protected_branches/_index.html.haml
index b3b419bd92d..010ba5a24a7 100644
--- a/app/views/projects/protected_branches/index.html.haml
+++ b/app/views/projects/protected_branches/_index.html.haml
@@ -17,6 +17,6 @@
%p.append-bottom-0 Read more about #{link_to "protected branches", help_page_path("user/project/protected_branches"), class: "underlined-link"} and #{link_to "project permissions", help_page_path("user/permissions"), class: "underlined-link"}.
.col-lg-9
- if can? current_user, :admin_project, @project
- = render 'create_protected_branch'
+ = render 'projects/protected_branches/create_protected_branch'
- = render "branches_list"
+ = render "projects/protected_branches/branches_list"
diff --git a/app/views/projects/settings/repository/show.html.haml b/app/views/projects/settings/repository/show.html.haml
index 428a6f4b2a0..88291653d84 100644
--- a/app/views/projects/settings/repository/show.html.haml
+++ b/app/views/projects/settings/repository/show.html.haml
@@ -1,2 +1,4 @@
-%h1
- Hello World
+- page_title "Repository"
+
+= render "projects/deploy_keys/index"
+= render "projects/protected_branches/index"