Commit 389fb420 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Moved push rules and mirror repository options to the repository option

Fixed the repository_helper not using instance variables, also
added the repository shorcut handler inside the dispatcher
parent 9ad419c5
...@@ -392,7 +392,7 @@ const UserCallout = require('./user_callout'); ...@@ -392,7 +392,7 @@ const UserCallout = require('./user_callout');
case 'builds': case 'builds':
case 'hooks': case 'hooks':
case 'services': case 'services':
case 'protected_branches': case 'repository':
shortcut_handler = new ShortcutsNavigation(); shortcut_handler = new ShortcutsNavigation();
} }
} }
......
...@@ -4,6 +4,7 @@ class Admin::PushRulesController < Admin::ApplicationController ...@@ -4,6 +4,7 @@ class Admin::PushRulesController < Admin::ApplicationController
respond_to :html respond_to :html
def show def show
redirect_to namespace_project_settings_repository_path(@project.namespace, @project)
end end
def update def update
......
...@@ -2,11 +2,12 @@ class Projects::MirrorsController < Projects::ApplicationController ...@@ -2,11 +2,12 @@ class Projects::MirrorsController < Projects::ApplicationController
# Authorize # Authorize
before_action :authorize_admin_project!, except: [:update_now] before_action :authorize_admin_project!, except: [:update_now]
before_action :authorize_push_code!, only: [:update_now] before_action :authorize_push_code!, only: [:update_now]
before_action :remote_mirror, only: [:show, :update] before_action :remote_mirror, only: [:update]
layout "project_settings" layout "project_settings"
def show def show
redirect_to namespace_project_settings_repository_path(@project.namespace, @project)
end end
def update def update
......
...@@ -5,6 +5,8 @@ module Projects ...@@ -5,6 +5,8 @@ module Projects
before_action :authorize_admin_project! before_action :authorize_admin_project!
before_action :load_protected_branches, only: [:show] before_action :load_protected_branches, only: [:show]
before_action :push_rule, only: [:show]
before_action :remote_mirror, only: [:show]
def show def show
@deploy_keys = DeployKeysPresenter @deploy_keys = DeployKeysPresenter
...@@ -21,7 +23,15 @@ module Projects ...@@ -21,7 +23,15 @@ module Projects
def define_protected_branches_controller def define_protected_branches_controller
@protected_branch = @project.protected_branches.new @protected_branch = @project.protected_branches.new
load_gon_index(@project) load_gon_index
end
def push_rule
@push_rule ||= PushRule.find_or_create_by(is_sample: true)
end
def remote_mirror
@remote_mirror = @project.remote_mirrors.first_or_initialize
end end
end end
end end
......
module RepositoryHelper module RepositoryHelper
def access_levels_options def access_levels_options
{ {
push_access_levels: ProtectedBranch::PushAccessLevel.human_access_levels.map { |id, text| { id: id, text: text, before_divider: true } }, push_access_levels: ProtectedBranch::PushAccessLevel.human_access_levels.map { |id, text| { id: id, text: text } },
merge_access_levels: ProtectedBranch::MergeAccessLevel.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 } },
selected_merge_access_levels: @protected_branch.merge_access_levels.map { |access_level| access_level.user_id || access_level.access_level },
selected_push_access_levels: @protected_branch.push_access_levels.map { |access_level| access_level.user_id || access_level.access_level }
} }
end end
def load_gon_index(project) def load_gon_index
params = { open_branches: project.open_branches.map { |br| { text: br.name, id: br.name, title: br.name } } } params = { open_branches: @project.open_branches.map { |br| { text: br.name, id: br.name, title: br.name } } }
params.merge!(current_project_id: @project.id) if @project
gon.push(params.merge(access_levels_options)) gon.push(params.merge(access_levels_options))
end end
end end
...@@ -18,14 +18,6 @@ ...@@ -18,14 +18,6 @@
= link_to namespace_project_settings_ci_cd_path(@project.namespace, @project), title: 'CI/CD Pipelines' do = link_to namespace_project_settings_ci_cd_path(@project.namespace, @project), title: 'CI/CD Pipelines' do
%span %span
CI/CD Pipelines CI/CD Pipelines
= nav_link(controller: :push_rules) do
= link_to namespace_project_push_rules_path(@project.namespace, @project), title: "Push Rules" do
%span
Push Rules
= nav_link(controller: :mirrors) do
= link_to namespace_project_mirror_path(@project.namespace, @project), title: 'Mirror Repository', data: {placement: 'right'} do
%span
Mirror Repository
= nav_link(controller: :pages) do = nav_link(controller: :pages) do
= link_to namespace_project_pages_path(@project.namespace, @project), title: 'Pages', data: {placement: 'right'} do = link_to namespace_project_pages_path(@project.namespace, @project), title: 'Pages', data: {placement: 'right'} do
%span %span
......
- page_title "Mirror Repository"
.row .row
= form_errors(@project) = form_errors(@project)
.row.prepend-top-default.append-bottom-default .row.prepend-top-default.append-bottom-default
...@@ -34,7 +32,7 @@ ...@@ -34,7 +32,7 @@
.form-group .form-group
= f.label :import_url, "Git repository URL", class: "label-light" = f.label :import_url, "Git repository URL", class: "label-light"
= f.text_field :import_url, class: 'form-control', placeholder: 'https://username:password@gitlab.company.com/group/project.git' = f.text_field :import_url, class: 'form-control', placeholder: 'https://username:password@gitlab.company.com/group/project.git'
= render "instructions" = render "projects/mirrors/instructions"
.form-group .form-group
= f.label :mirror_user_id, "Mirror user", class: "label-light" = f.label :mirror_user_id, "Mirror user", class: "label-light"
= users_select_tag("project[mirror_user_id]", class: 'input-large', selected: @project.mirror_user_id || current_user.id, = users_select_tag("project[mirror_user_id]", class: 'input-large', selected: @project.mirror_user_id || current_user.id,
...@@ -79,7 +77,7 @@ ...@@ -79,7 +77,7 @@
.form-group.has-feedback .form-group.has-feedback
= rm_form.label :url, "Git repository URL", class: "label-light" = rm_form.label :url, "Git repository URL", class: "label-light"
= rm_form.text_field :url, class: "form-control", placeholder: 'https://username:password@gitlab.company.com/group/project.git' = rm_form.text_field :url, class: "form-control", placeholder: 'https://username:password@gitlab.company.com/group/project.git'
= render "instructions" = render "projects/mirrors/instructions"
.form-group .form-group
= rm_form.label :sync_time, "Synchronization time", class: "label-light append-bottom-0" = rm_form.label :sync_time, "Synchronization time", class: "label-light append-bottom-0"
= rm_form.select :sync_time, options_for_select(mirror_sync_time_options, @remote_mirror.sync_time), {}, class: 'form-control remote-mirror-sync-time' = rm_form.select :sync_time, options_for_select(mirror_sync_time_options, @remote_mirror.sync_time), {}, class: 'form-control remote-mirror-sync-time'
......
- page_title "Repository" - page_title "Repository"
= render @deploy_keys = render @deploy_keys
= render "projects/push_rules/index"
= render "projects/mirrors/show"
= render "projects/protected_branches/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