Commit 0b74ae84 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

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
parent c51d7203
...@@ -7,12 +7,11 @@ class Projects::DeployKeysController < Projects::ApplicationController ...@@ -7,12 +7,11 @@ class Projects::DeployKeysController < Projects::ApplicationController
layout "project_settings" layout "project_settings"
def index def index
@key = DeployKey.new redirect_to namespace_project_settings_repository_path(@project.namespace, @project)
set_index_vars
end end
def new def new
redirect_to namespace_project_deploy_keys_path(@project.namespace, @project) redirect_to namespace_project_settings_repository_path(@project.namespace, @project)
end end
def create def create
...@@ -20,7 +19,7 @@ class Projects::DeployKeysController < Projects::ApplicationController ...@@ -20,7 +19,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
set_index_vars set_index_vars
if @key.valid? && @project.deploy_keys << @key 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 else
render "index" render "index"
end end
...@@ -29,7 +28,7 @@ class Projects::DeployKeysController < Projects::ApplicationController ...@@ -29,7 +28,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
def enable def enable
Projects::EnableDeployKeyService.new(@project, current_user, params).execute 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 end
def disable def disable
......
...@@ -8,14 +8,13 @@ class Projects::ProtectedBranchesController < Projects::ApplicationController ...@@ -8,14 +8,13 @@ class Projects::ProtectedBranchesController < Projects::ApplicationController
layout "project_settings" layout "project_settings"
def index def index
@protected_branch = @project.protected_branches.new redirect_to namespace_project_settings_repository_path(@project.namespace, @project)
load_gon_index
end end
def create def create
@protected_branch = ::ProtectedBranches::CreateService.new(@project, current_user, protected_branch_params).execute @protected_branch = ::ProtectedBranches::CreateService.new(@project, current_user, protected_branch_params).execute
if @protected_branch.persisted? 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 else
load_protected_branches load_protected_branches
load_gon_index load_gon_index
...@@ -45,7 +44,7 @@ class Projects::ProtectedBranchesController < Projects::ApplicationController ...@@ -45,7 +44,7 @@ class Projects::ProtectedBranchesController < Projects::ApplicationController
@protected_branch.destroy @protected_branch.destroy
respond_to do |format| 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 } format.js { head :ok }
end end
end end
......
module Projects module Projects
module Settings module Settings
class RepositoryController < Projects::ApplicationController class RepositoryController < Projects::ApplicationController
include RepositoryHelper
before_action :authorize_admin_project!
before_action :load_protected_branches, only: [:show]
def 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 end
end end
......
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
...@@ -4,18 +4,14 @@ ...@@ -4,18 +4,14 @@
%span %span
Members Members
- if can_edit - if can_edit
= nav_link(controller: :deploy_keys) do = nav_link(controller: :repository) do
= link_to namespace_project_deploy_keys_path(@project.namespace, @project), title: 'Deploy Keys' do = link_to namespace_project_settings_repository_path(@project.namespace, @project), title: 'Repository' do
%span %span
Deploy Keys Repository
= nav_link(controller: :integrations) do = nav_link(controller: :integrations) do
= link_to namespace_project_settings_integrations_path(@project.namespace, @project), title: 'Integrations' do = link_to namespace_project_settings_integrations_path(@project.namespace, @project), title: 'Integrations' do
%span %span
Integrations 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) - if @project.feature_available?(:builds, current_user)
= nav_link(controller: :ci_cd) do = nav_link(controller: :ci_cd) do
......
- page_title "Deploy Keys"
.row.prepend-top-default .row.prepend-top-default
.col-lg-3.profile-settings-sidebar .col-lg-3.profile-settings-sidebar
%h4.prepend-top-0 %h4.prepend-top-0
= page_title Deploy Keys
%p %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. 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 .col-lg-9
%h5.prepend-top-0 %h5.prepend-top-0
Create a new deploy key for this project Create a new deploy key for this project
= render "form" = render "projects/deploy_keys/form"
.col-lg-9.col-lg-offset-3 .col-lg-9.col-lg-offset-3
%hr %hr
.col-lg-9.col-lg-offset-3.append-bottom-default.deploy-keys .col-lg-9.col-lg-offset-3.append-bottom-default.deploy-keys
......
...@@ -23,6 +23,6 @@ ...@@ -23,6 +23,6 @@
- if can_admin_project - if can_admin_project
%th %th
%tbody %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' = paginate @protected_branches, theme: 'gitlab'
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
= f.label :name, class: 'col-md-2 text-right' do = f.label :name, class: 'col-md-2 text-right' do
Branch: Branch:
.col-md-10 .col-md-10
= render partial: "dropdown", locals: { f: f } = render partial: "projects/protected_branches/dropdown", locals: { f: f }
.help-block .help-block
= link_to 'Wildcards', help_page_path('user/project/protected_branches', anchor: 'wildcard-protected-branches') = link_to 'Wildcards', help_page_path('user/project/protected_branches', anchor: 'wildcard-protected-branches')
such as such as
......
...@@ -17,6 +17,6 @@ ...@@ -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"}. %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 .col-lg-9
- if can? current_user, :admin_project, @project - 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"
%h1 - page_title "Repository"
Hello World
= render "projects/deploy_keys/index"
= render "projects/protected_branches/index"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment