Commit 1bf01eaf authored by Rémy Coutable's avatar Rémy Coutable

[EE] Reduce CE/EE difference in app/views/projects/protected_tags/_protected_tag.html.haml

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 2497cd1e
......@@ -18,6 +18,11 @@ module ProtectedRefAccess
scope :master, -> { maintainer } # @deprecated
scope :maintainer, -> { where(access_level: Gitlab::Access::MAINTAINER) }
scope :developer, -> { where(access_level: Gitlab::Access::DEVELOPER) }
scope :by_user, -> (user) { where(user_id: user ) }
scope :by_group, -> (group) { where(group_id: group ) }
scope :for_role, -> { where(user_id: nil, group_id: nil) }
scope :for_user, -> { where.not(user_id: nil) }
scope :for_group, -> { where.not(group_id: nil) }
validates :access_level, presence: true, if: :role?, inclusion: {
in: ALLOWED_ACCESS_LEVELS
......
= render layout: 'projects/protected_tags/shared/protected_tag', locals: { protected_tag: protected_tag } do
= render partial: 'projects/protected_tags/ee/fallback_update_protected_tag', locals: { protected_tag: protected_tag }
%td
= render 'projects/protected_tags/protected_tag_create_access_levels', protected_tag: protected_tag, create_access_level: protected_tag.create_access_levels.for_role.first
= render_if_exists 'projects/protected_tags/protected_tag_extra_create_access_levels', protected_tag: protected_tag
- protected_tag = local_assigns.fetch(:protected_tag)
- create_access_level = local_assigns.fetch(:create_access_level)
- dropdown_label = create_access_level&.humanize || 'Select'
= hidden_field_tag "allowed_to_create_#{protected_tag.id}", create_access_level&.access_level
= dropdown_tag(dropdown_label,
options: { toggle_class: 'js-allowed-to-create', dropdown_class: 'dropdown-menu-selectable capitalize-header js-allowed-to-create-container',
data: { field_name: "allowed_to_create_#{protected_tag.id}", access_level_id: create_access_level&.id }})
%td
= hidden_field_tag "allowed_to_create_#{protected_tag.id}", protected_tag.create_access_levels.first.access_level
= dropdown_tag( (protected_tag.create_access_levels.first.humanize || 'Select') ,
options: { toggle_class: 'js-allowed-to-create', dropdown_class: 'dropdown-menu-selectable capitalize-header js-allowed-to-create-container',
data: { field_name: "allowed_to_create_#{protected_tag.id}", access_level_id: protected_tag.create_access_levels.first.id }})
......@@ -22,12 +22,6 @@ module EE
validates :group, :user,
absence: true,
unless: :protected_refs_for_users_required_and_available
scope :by_user, -> (user) { where(user: user ) }
scope :by_group, -> (group) { where(group: group ) }
scope :for_role, -> { where(user: nil, group: nil) }
scope :for_user, -> { where.not(user: nil) }
scope :for_group, -> { where.not(group: nil) }
end
def type
......
- protected_tag = local_assigns.fetch(:protected_tag)
- user_create_access_levels = protected_tag.create_access_levels.for_user
- group_create_access_levels = protected_tag.create_access_levels.for_group
- if user_create_access_levels.any?
%p.small
The following
= 'user'.pluralize(user_create_access_levels.size)
can also create tags:
= user_create_access_levels.map(&:humanize).to_sentence
- if group_create_access_levels.any?
%p.small
Members of
= group_create_access_levels.size > 1 ? 'these groups' : 'this group'
can also create tags:
= group_create_access_levels.map(&:humanize).to_sentence
- create_access_level = protected_tag.create_access_levels.for_role.first
- user_create_access_levels = protected_tag.create_access_levels.for_user
- group_create_access_levels =protected_tag.create_access_levels.for_group
%td
= hidden_field_tag "allowed_to_create_#{protected_tag.id}", create_access_level&.access_level
= dropdown_tag( (create_access_level&.humanize || 'Select') ,
options: { toggle_class: 'js-allowed-to-create', dropdown_class: 'dropdown-menu-selectable capitalize-header js-allowed-to-create-container',
data: { field_name: "allowed_to_create_#{protected_tag.id}", access_level_id: create_access_level&.id }})
- if user_create_access_levels.any?
%p.small
The following
#{ 'user'.pluralize(user_create_access_levels.size) }
can also create tags:
#{ user_create_access_levels.map(&:humanize).to_sentence }
- if group_create_access_levels.any?
%p.small
Members of
#{ group_create_access_levels.size > 1 ? 'these groups' : 'this group' }
can also create tags:
#{ group_create_access_levels.map(&:humanize).to_sentence }
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