Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/views/protected_branches')
-rw-r--r--app/views/protected_branches/_branches_list.html.haml6
-rw-r--r--app/views/protected_branches/_create_protected_branch.html.haml2
-rw-r--r--app/views/protected_branches/_index.html.haml6
-rw-r--r--app/views/protected_branches/_protected_branch.html.haml2
-rw-r--r--app/views/protected_branches/shared/_branches_list.html.haml6
-rw-r--r--app/views/protected_branches/shared/_create_protected_branch.html.haml15
-rw-r--r--app/views/protected_branches/shared/_index.html.haml3
-rw-r--r--app/views/protected_branches/shared/_protected_branch.html.haml26
8 files changed, 38 insertions, 28 deletions
diff --git a/app/views/protected_branches/_branches_list.html.haml b/app/views/protected_branches/_branches_list.html.haml
index 82eac348f16..2b0160f98e7 100644
--- a/app/views/protected_branches/_branches_list.html.haml
+++ b/app/views/protected_branches/_branches_list.html.haml
@@ -1,4 +1,4 @@
-- can_admin_project = can?(current_user, :admin_project, @project)
+- can_admin_entity = protected_branch_can_admin_entity?(protected_branch_entity)
-= render layout: 'protected_branches/shared/branches_list', locals: { can_admin_project: can_admin_project } do
- = render partial: 'protected_branches/protected_branch', collection: @protected_branches
+= render layout: 'protected_branches/shared/branches_list', locals: { can_admin_entity: can_admin_entity, protected_branch_entity: protected_branch_entity } do
+ = render partial: 'protected_branches/protected_branch', collection: @protected_branches, locals: { protected_branch_entity: protected_branch_entity }
diff --git a/app/views/protected_branches/_create_protected_branch.html.haml b/app/views/protected_branches/_create_protected_branch.html.haml
index 22a49ba9c7e..b4765ab49c2 100644
--- a/app/views/protected_branches/_create_protected_branch.html.haml
+++ b/app/views/protected_branches/_create_protected_branch.html.haml
@@ -11,4 +11,4 @@
dropdown_class: 'dropdown-menu-selectable capitalize-header', dropdown_qa_selector: 'allowed_to_push_dropdown_content' , dropdown_testid: 'allowed-to-push-dropdown',
data: { field_name: 'protected_branch[push_access_levels_attributes][0][access_level]', input_id: 'push_access_levels_attributes', qa_selector: 'allowed_to_push_dropdown' }})
-= render 'protected_branches/shared/create_protected_branch'
+= render 'protected_branches/shared/create_protected_branch', protected_branch_entity: protected_branch_entity
diff --git a/app/views/protected_branches/_index.html.haml b/app/views/protected_branches/_index.html.haml
index 4beca4845b8..84a221555ab 100644
--- a/app/views/protected_branches/_index.html.haml
+++ b/app/views/protected_branches/_index.html.haml
@@ -1,7 +1,7 @@
- content_for :create_protected_branch do
- = render 'protected_branches/create_protected_branch'
+ = render 'protected_branches/create_protected_branch', protected_branch_entity: protected_branch_entity
- content_for :branches_list do
- = render "protected_branches/branches_list"
+ = render "protected_branches/branches_list", protected_branch_entity: protected_branch_entity
-= render 'protected_branches/shared/index'
+= render 'protected_branches/shared/index', protected_branch_entity: protected_branch_entity
diff --git a/app/views/protected_branches/_protected_branch.html.haml b/app/views/protected_branches/_protected_branch.html.haml
index 423d7f23eb5..acd62968b09 100644
--- a/app/views/protected_branches/_protected_branch.html.haml
+++ b/app/views/protected_branches/_protected_branch.html.haml
@@ -1,2 +1,2 @@
-= render layout: 'protected_branches/shared/protected_branch', locals: { protected_branch: protected_branch } do
+= render layout: 'protected_branches/shared/protected_branch', locals: { protected_branch: protected_branch, protected_branch_entity: protected_branch_entity } do
= render_if_exists 'protected_branches/update_protected_branch', protected_branch: protected_branch
diff --git a/app/views/protected_branches/shared/_branches_list.html.haml b/app/views/protected_branches/shared/_branches_list.html.haml
index d041f9c5b48..c35895e000c 100644
--- a/app/views/protected_branches/shared/_branches_list.html.haml
+++ b/app/views/protected_branches/shared/_branches_list.html.haml
@@ -13,7 +13,7 @@
%col{ width: "20%" }
%col{ width: "10%" }
%col{ width: "10%" }
- - if can_admin_project
+ - if can_admin_entity
%col
%thead
%tr
@@ -28,9 +28,9 @@
%span.has-tooltip{ data: { container: 'body' }, title: s_('ProtectedBranch|Allow all users with push access to force push.'), 'aria-hidden': 'true' }
= sprite_icon('question', size: 16, css_class: 'gl-text-gray-500')
- = render_if_exists 'protected_branches/ee/code_owner_approval_table_head'
+ = render_if_exists 'protected_branches/ee/code_owner_approval_table_head', protected_branch_entity: protected_branch_entity
- - if can_admin_project
+ - if can_admin_entity
%th
%tbody
= yield
diff --git a/app/views/protected_branches/shared/_create_protected_branch.html.haml b/app/views/protected_branches/shared/_create_protected_branch.html.haml
index 6b4a143df69..315daa5e029 100644
--- a/app/views/protected_branches/shared/_create_protected_branch.html.haml
+++ b/app/views/protected_branches/shared/_create_protected_branch.html.haml
@@ -1,4 +1,4 @@
-= gitlab_ui_form_for [@project, @protected_branch], html: { class: 'new-protected-branch js-new-protected-branch' } do |f|
+= gitlab_ui_form_for [protected_branch_entity, @protected_branch], html: { class: 'new-protected-branch js-new-protected-branch' } do |f|
%input{ type: 'hidden', name: 'update_section', value: 'js-protected-branches-settings' }
= render Pajamas::CardComponent.new(card_options: { class: "gl-mb-5" }) do |c|
- c.header do
@@ -8,11 +8,18 @@
.form-group.row
= f.label :name, s_('ProtectedBranch|Branch:'), class: 'col-sm-12'
.col-sm-12
- = render partial: "protected_branches/shared/dropdown", locals: { f: f, toggle_classes: 'gl-w-full! gl-form-input-lg' }
+ - if protected_branch_entity.is_a?(Group)
+ = f.text_field :name, placeholder: 'prod*', class: 'form-control gl-w-full! gl-form-input-lg'
+ - else
+ = render partial: "protected_branches/shared/dropdown", locals: { f: f, toggle_classes: 'gl-w-full! gl-form-input-lg' }
.form-text.text-muted
- wildcards_url = help_page_url('user/project/protected_branches', anchor: 'configure-multiple-protected-branches-by-using-a-wildcard')
- wildcards_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: wildcards_url }
- = (s_("ProtectedBranch|%{wildcards_link_start}Wildcards%{wildcards_link_end} such as %{code_tag_start}*-stable%{code_tag_end} or %{code_tag_start}production/*%{code_tag_end} are supported.") % { wildcards_link_start: wildcards_link_start, wildcards_link_end: '</a>', code_tag_start: '<code>', code_tag_end: '</code>' }).html_safe
+ - placeholders = { wildcards_link_start: wildcards_link_start, wildcards_link_end: '</a>', code_tag_start: '<code>', code_tag_end: '</code>' }
+ - if protected_branch_entity.is_a?(Group)
+ = (s_("ProtectedBranch|Only %{wildcards_link_start}Wildcards%{wildcards_link_end} such as %{code_tag_start}*-stable%{code_tag_end} or %{code_tag_start}production/*%{code_tag_end} are supported.") % placeholders).html_safe
+ - else
+ = (s_("ProtectedBranch|%{wildcards_link_start}Wildcards%{wildcards_link_end} such as %{code_tag_start}*-stable%{code_tag_end} or %{code_tag_start}production/*%{code_tag_end} are supported.") % placeholders).html_safe
.form-group.row
= f.label :merge_access_levels_attributes, s_("ProtectedBranch|Allowed to merge:"), class: 'col-sm-12'
.col-sm-12
@@ -30,6 +37,6 @@
- force_push_docs_url = help_page_url('topics/git/git_rebase', anchor: 'force-push')
- force_push_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: force_push_docs_url }
= (s_("ProtectedBranch|Allow all users with push access to %{tag_start}force push%{tag_end}.") % { tag_start: force_push_link_start, tag_end: '</a>' }).html_safe
- = render_if_exists 'protected_branches/ee/code_owner_approval_form', f: f
+ = render_if_exists 'protected_branches/ee/code_owner_approval_form', f: f, protected_branch_entity: protected_branch_entity
- c.footer do
= f.submit s_('ProtectedBranch|Protect'), disabled: true, data: { qa_selector: 'protect_button' }, pajamas_button: true
diff --git a/app/views/protected_branches/shared/_index.html.haml b/app/views/protected_branches/shared/_index.html.haml
index c204508d355..d0e21e38429 100644
--- a/app/views/protected_branches/shared/_index.html.haml
+++ b/app/views/protected_branches/shared/_index.html.haml
@@ -1,3 +1,4 @@
+- can_admin_entity = protected_branch_can_admin_entity?(protected_branch_entity)
- expanded = expanded_by_default?
%section.settings.no-animate#js-protected-branches-settings{ class: ('expanded' if expanded), data: { qa_selector: 'protected_branches_settings_content' } }
@@ -14,7 +15,7 @@
= s_("ProtectedBranch|By default, protected branches restrict who can modify the branch.")
= link_to s_("ProtectedBranch|Learn more."), help_page_path("user/project/protected_branches", anchor: "who-can-modify-a-protected-branch")
- - if can? current_user, :admin_project, @project
+ - if can_admin_entity
= content_for :create_protected_branch
= content_for :branches_list
diff --git a/app/views/protected_branches/shared/_protected_branch.html.haml b/app/views/protected_branches/shared/_protected_branch.html.haml
index 5dea85aaa41..b4fd7a24b41 100644
--- a/app/views/protected_branches/shared/_protected_branch.html.haml
+++ b/app/views/protected_branches/shared/_protected_branch.html.haml
@@ -1,23 +1,25 @@
-- can_admin_project = can?(current_user, :admin_project, @project)
+- can_admin_entity = protected_branch_can_admin_entity?(protected_branch_entity)
+- url = protected_branch_path_by_entity(protected_branch, protected_branch_entity)
-%tr.js-protected-branch-edit-form{ data: { url: namespace_project_protected_branch_path(@project.namespace, @project, protected_branch), testid: 'protected-branch' } }
+%tr.js-protected-branch-edit-form{ data: { url: url, testid: 'protected-branch' } }
%td
%span.ref-name= protected_branch.name
- - if @project.root_ref?(protected_branch.name)
+ - if protected_branch_entity.is_a?(Project) && protected_branch_entity.root_ref?(protected_branch.name)
= gl_badge_tag s_('ProtectedBranch|default'), variant: :info
- %div
- - if protected_branch.wildcard?
- - matching_branches = protected_branch.matching(repository.branch_names)
- = link_to pluralize(matching_branches.count, "matching branch"), namespace_project_protected_branch_path(@project.namespace, @project, protected_branch)
- - elsif !protected_branch.commit
- %span.text-muted Branch was deleted.
+ - if protected_branch_entity.is_a?(Project)
+ %div
+ - if protected_branch.wildcard?
+ - matching_branches = protected_branch.matching(repository.branch_names)
+ = link_to pluralize(matching_branches.count, "matching branch"), namespace_project_protected_branch_path(@project.namespace, @project, protected_branch)
+ - elsif !protected_branch.commit
+ %span.text-muted= s_('ProtectedBranch|Branch does not exist.')
= yield
- = render_if_exists 'protected_branches/ee/code_owner_approval_table', protected_branch: protected_branch
+ = render_if_exists 'protected_branches/ee/code_owner_approval_table', protected_branch: protected_branch, protected_branch_entity: protected_branch_entity
- - if can_admin_project
+ - if can_admin_entity
%td
- = link_to s_('ProtectedBranch|Unprotect'), [@project, protected_branch, { update_section: 'js-protected-branches-settings' }], disabled: local_assigns[:disabled], aria: { label: s_('ProtectedBranch|Unprotect branch') }, data: { confirm: s_('ProtectedBranch|Branch will be writable for developers. Are you sure?'), confirm_btn_variant: 'danger' }, method: :delete, class: "btn gl-button btn-danger btn-sm"
+ = link_to s_('ProtectedBranch|Unprotect'), [protected_branch_entity, protected_branch, { update_section: 'js-protected-branches-settings' }], disabled: local_assigns[:disabled], aria: { label: s_('ProtectedBranch|Unprotect branch') }, data: { confirm: s_('ProtectedBranch|Branch will be writable for developers. Are you sure?'), confirm_btn_variant: 'danger' }, method: :delete, class: "btn gl-button btn-danger btn-sm"