Module: GroupsHelper
- Included in:
- GroupEntity
- Defined in:
- app/helpers/groups_helper.rb
Instance Method Summary collapse
- #can_change_group_visibility_level?(group) ⇒ Boolean
- #can_change_share_with_group_lock?(group) ⇒ Boolean
- #can_disable_group_emails?(group) ⇒ Boolean
- #can_update_default_branch_protection?(group) ⇒ Boolean
- #group_container_registry_nav? ⇒ Boolean
- #group_icon_url(group, options = {}) ⇒ Object
- #group_issues_count(state:) ⇒ Object
- #group_lfs_status(group) ⇒ Object
- #group_merge_requests_count(state:) ⇒ Object
- #group_overview_nav_link_paths ⇒ Object
- #group_packages_list_nav? ⇒ Boolean
- #group_packages_nav? ⇒ Boolean
- #group_packages_nav_link_paths ⇒ Object
- #group_settings_nav_link_paths ⇒ Object
- #group_sidebar_link?(link) ⇒ Boolean
- #group_sidebar_links ⇒ Object
- #group_title(group, name = nil, url = nil) ⇒ Object
- #parent_group_options(current_group) ⇒ Object
- #projects_lfs_status(group) ⇒ Object
- #remove_group_message(group) ⇒ Object
- #share_with_group_lock_help_text(group) ⇒ Object
- #show_invite_banner?(group) ⇒ Boolean
Instance Method Details
#can_change_group_visibility_level?(group) ⇒ Boolean
49 50 51 |
# File 'app/helpers/groups_helper.rb', line 49 def can_change_group_visibility_level?(group) can?(current_user, :change_visibility_level, group) end |
#can_change_share_with_group_lock?(group) ⇒ Boolean
57 58 59 |
# File 'app/helpers/groups_helper.rb', line 57 def can_change_share_with_group_lock?(group) can?(current_user, :change_share_with_group_lock, group) end |
#can_disable_group_emails?(group) ⇒ Boolean
61 62 63 |
# File 'app/helpers/groups_helper.rb', line 61 def can_disable_group_emails?(group) can?(current_user, :set_emails_disabled, group) && !group.parent&.emails_disabled? end |
#can_update_default_branch_protection?(group) ⇒ Boolean
53 54 55 |
# File 'app/helpers/groups_helper.rb', line 53 def can_update_default_branch_protection?(group) can?(current_user, :update_default_branch_protection, group) end |
#group_container_registry_nav? ⇒ Boolean
36 37 38 39 |
# File 'app/helpers/groups_helper.rb', line 36 def group_container_registry_nav? Gitlab.config.registry.enabled && can?(current_user, :read_container_image, @group) end |
#group_icon_url(group, options = {}) ⇒ Object
79 80 81 82 83 84 85 |
# File 'app/helpers/groups_helper.rb', line 79 def group_icon_url(group, = {}) if group.is_a?(String) group = Group.find_by_full_path(group) end group.try(:avatar_url) || ActionController::Base.helpers.image_path('no_group_avatar.png') end |
#group_issues_count(state:) ⇒ Object
65 66 67 68 69 70 |
# File 'app/helpers/groups_helper.rb', line 65 def group_issues_count(state:) IssuesFinder .new(current_user, group_id: @group.id, state: state, non_archived: true, include_subgroups: true) .execute .count end |
#group_lfs_status(group) ⇒ Object
124 125 126 127 128 129 130 |
# File 'app/helpers/groups_helper.rb', line 124 def group_lfs_status(group) status = group.lfs_enabled? ? 'enabled' : 'disabled' content_tag(:span, class: "lfs-#{status}") do "#{status.humanize} #{projects_lfs_status(group)}" end end |
#group_merge_requests_count(state:) ⇒ Object
72 73 74 75 76 77 |
# File 'app/helpers/groups_helper.rb', line 72 def group_merge_requests_count(state:) MergeRequestsFinder .new(current_user, group_id: @group.id, state: state, non_archived: true, include_subgroups: true) .execute .count end |
#group_overview_nav_link_paths ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'app/helpers/groups_helper.rb', line 4 def group_overview_nav_link_paths %w[ groups#show groups#details groups#activity groups#subgroups ] end |
#group_packages_list_nav? ⇒ Boolean
166 167 168 |
# File 'app/helpers/groups_helper.rb', line 166 def group_packages_list_nav? @group.packages_feature_enabled? end |
#group_packages_nav? ⇒ Boolean
161 162 163 164 |
# File 'app/helpers/groups_helper.rb', line 161 def group_packages_nav? group_packages_list_nav? || group_container_registry_nav? end |
#group_packages_nav_link_paths ⇒ Object
29 30 31 32 33 34 |
# File 'app/helpers/groups_helper.rb', line 29 def group_packages_nav_link_paths %w[ groups/packages#index groups/container_registries#index ] end |
#group_settings_nav_link_paths ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/helpers/groups_helper.rb', line 13 def group_settings_nav_link_paths %w[ groups#projects groups#edit badges#index repository#show ci_cd#show integrations#index integrations#edit ldap_group_links#index hooks#index audit_events#index pipeline_quota#index ] end |
#group_sidebar_link?(link) ⇒ Boolean
45 46 47 |
# File 'app/helpers/groups_helper.rb', line 45 def (link) .include?(link) end |
#group_sidebar_links ⇒ Object
41 42 43 |
# File 'app/helpers/groups_helper.rb', line 41 def @group_sidebar_links ||= end |
#group_title(group, name = nil, url = nil) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'app/helpers/groups_helper.rb', line 87 def group_title(group, name = nil, url = nil) @has_group_title = true full_title = [] group.ancestors.reverse.each_with_index do |parent, index| if index > 0 (group_title_link(parent, hidable: false, show_avatar: true, for_dropdown: true), location: :before) else full_title << (group_title_link(parent, hidable: false)) end end full_title << render("layouts/nav/breadcrumbs/collapsed_dropdown", location: :before, title: _("Show parent subgroups")) full_title << (group_title_link(group)) full_title << ' · '.html_safe + link_to(simple_sanitize(name), url, class: 'group-path breadcrumb-item-text js-breadcrumb-item-text') if name full_title.join.html_safe end |
#parent_group_options(current_group) ⇒ Object
151 152 153 154 155 156 157 158 159 |
# File 'app/helpers/groups_helper.rb', line 151 def (current_group) exclude_groups = current_group.self_and_descendants.pluck_primary_key exclude_groups << current_group.parent_id if current_group.parent_id groups = GroupsFinder.new(current_user, min_access_level: Gitlab::Access::OWNER, exclude_group_ids: exclude_groups).execute.sort_by(&:human_name).map do |group| { id: group.id, text: group.human_name } end groups.to_json end |
#projects_lfs_status(group) ⇒ Object
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'app/helpers/groups_helper.rb', line 107 def projects_lfs_status(group) lfs_status = if group.lfs_enabled? group.projects.select(&:lfs_enabled?).size else group.projects.reject(&:lfs_enabled?).size end size = group.projects.size if lfs_status == size 'for all projects' else "for #{lfs_status} out of #{pluralize(size, 'project')}" end end |
#remove_group_message(group) ⇒ Object
132 133 134 135 |
# File 'app/helpers/groups_helper.rb', line 132 def (group) _("You are going to remove %{group_name}, this will also delete all of its subgroups and projects. Removed groups CANNOT be restored! Are you ABSOLUTELY sure?") % { group_name: group.name } end |
#share_with_group_lock_help_text(group) ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'app/helpers/groups_helper.rb', line 137 def share_with_group_lock_help_text(group) return default_help unless group.parent&.share_with_group_lock? if group.share_with_group_lock? if can?(current_user, :change_share_with_group_lock, group.parent) ancestor_locked_but_you_can_override(group) else ancestor_locked_so_ask_the_owner(group) end else ancestor_locked_and_has_been_overridden(group) end end |