diff options
Diffstat (limited to 'app/helpers')
26 files changed, 218 insertions, 206 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 512ba7e2a66..2a1652cf2ba 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -4,8 +4,6 @@ require 'digest/md5' require 'uri' module ApplicationHelper - include StartupCssHelper - # See https://docs.gitlab.com/ee/development/ee_features.html#code-in-appviews # rubocop: disable CodeReuse/ActiveRecord # We allow partial to be nil so that collection views can be passed in @@ -46,7 +44,7 @@ module ApplicationHelper # current_controller?('gitlab/application') # => false def current_controller?(*args) args.any? do |v| - v.to_s.downcase == controller.controller_name || v.to_s.downcase == controller.controller_path + Gitlab::Utils.safe_downcase!(v.to_s) == controller.controller_name || Gitlab::Utils.safe_downcase!(v.to_s) == controller.controller_path end end @@ -61,7 +59,7 @@ module ApplicationHelper # current_action?(:create) # => false # current_action?(:new, :create) # => true def current_action?(*args) - args.any? { |v| v.to_s.downcase == action_name } + args.any? { |v| Gitlab::Utils.safe_downcase!(v.to_s) == action_name } end def admin_section? @@ -250,11 +248,7 @@ module ApplicationHelper end def stylesheet_link_tag_defer(path) - if use_startup_css? - stylesheet_link_tag(path, media: "print", crossorigin: ActionController::Base.asset_host ? 'anonymous' : nil) - else - stylesheet_link_tag(path, media: "all") - end + stylesheet_link_tag(path, media: "print", crossorigin: ActionController::Base.asset_host ? 'anonymous' : nil) end def outdated_browser? diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb index 7866e3e3d9f..ed30adfabf0 100644 --- a/app/helpers/application_settings_helper.rb +++ b/app/helpers/application_settings_helper.rb @@ -242,6 +242,7 @@ module ApplicationSettingsHelper :housekeeping_incremental_repack_period, :html_emails_enabled, :import_sources, + :invisible_captcha_enabled, :max_artifacts_size, :max_attachment_size, :max_import_size, @@ -335,7 +336,8 @@ module ApplicationSettingsHelper :group_export_limit, :group_download_export_limit, :wiki_page_max_content_bytes, - :container_registry_delete_tags_service_timeout + :container_registry_delete_tags_service_timeout, + :rate_limiting_response_text ] end diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb index 0c5823894c5..bca53dfb88a 100644 --- a/app/helpers/blob_helper.rb +++ b/app/helpers/blob_helper.rb @@ -106,11 +106,12 @@ module BlobHelper return unless blob common_classes = "btn btn-#{btn_class}" + base_button = button_tag(label, class: "#{common_classes} disabled", disabled: true) if !on_top_of_branch?(project, ref) - button_tag label, class: "#{common_classes} disabled has-tooltip", title: "You can only #{action} files when you are on a branch", data: { container: 'body' } + modify_file_button_tooltip(base_button, _("You can only %{action} files when you are on a branch") % { action: action }) elsif blob.stored_externally? - button_tag label, class: "#{common_classes} disabled has-tooltip", title: "It is not possible to #{action} files that are stored in LFS using the web interface", data: { container: 'body' } + modify_file_button_tooltip(base_button, _("It is not possible to %{action} files that are stored in LFS using the web interface") % { action: action }) elsif can_modify_blob?(blob, project, ref) button_tag label, class: "#{common_classes}", 'data-target' => "#modal-#{modal_type}-blob", 'data-toggle' => 'modal' elsif can?(current_user, :fork_project, project) && can?(current_user, :create_merge_request_in, project) @@ -217,6 +218,10 @@ module BlobHelper @gitlab_ci_ymls ||= template_dropdown_names(TemplateFinder.build(:gitlab_ci_ymls, project).execute) end + def gitlab_ci_syntax_ymls(project) + @gitlab_ci_syntax_ymls ||= template_dropdown_names(TemplateFinder.build(:gitlab_ci_syntax_ymls, project).execute) + end + def metrics_dashboard_ymls(project) @metrics_dashboard_ymls ||= template_dropdown_names(TemplateFinder.build(:metrics_dashboard_ymls, project).execute) end @@ -360,7 +365,11 @@ module BlobHelper end def edit_disabled_button_tag(button_text, common_classes) - button_tag(button_text, class: "#{common_classes} disabled has-tooltip", title: _('You can only edit files when you are on a branch'), data: { container: 'body' }) + button = button_tag(button_text, class: "#{common_classes} disabled", disabled: true) + + # Disabled buttons with tooltips should have the tooltip attached + # to a wrapper element https://bootstrap-vue.org/docs/components/tooltip#disabled-elements + content_tag(:span, button, class: 'has-tooltip', title: _('You can only edit files when you are on a branch'), data: { container: 'body' }) end def edit_link_tag(link_text, edit_path, common_classes, data) @@ -397,4 +406,12 @@ module BlobHelper @path.to_s.end_with?(Ci::Pipeline::CONFIG_EXTENSION) || @path.to_s == @project.ci_config_path_or_default end + + private + + def modify_file_button_tooltip(button, tooltip_message) + # Disabled buttons with tooltips should have the tooltip attached + # to a wrapper element https://bootstrap-vue.org/docs/components/tooltip#disabled-elements + content_tag(:span, button, class: 'btn-group has-tooltip', title: tooltip_message, data: { container: 'body' }) + end end diff --git a/app/helpers/ci/pipelines_helper.rb b/app/helpers/ci/pipelines_helper.rb index 309aa477108..8a6f0821dbb 100644 --- a/app/helpers/ci/pipelines_helper.rb +++ b/app/helpers/ci/pipelines_helper.rb @@ -26,6 +26,10 @@ module Ci _("%{message} showing first %{warnings_displayed}") % { message: message, warnings_displayed: MAX_LIMIT } end + def has_gitlab_ci?(project) + project.has_ci? && project.builds_enabled? + end + private def warning_markdown(pipeline) diff --git a/app/helpers/triggers_helper.rb b/app/helpers/ci/triggers_helper.rb index 5cfdc0971f0..01555b6e2cc 100644 --- a/app/helpers/triggers_helper.rb +++ b/app/helpers/ci/triggers_helper.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -module TriggersHelper +module Ci::TriggersHelper def builds_trigger_url(project_id, ref: nil) if ref.nil? "#{Settings.gitlab.url}/api/v4/projects/#{project_id}/trigger/pipeline" diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index 02d48386e31..e6e2b5b128b 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -110,8 +110,16 @@ module CommitsHelper end end - def revert_commit_link(commit, continue_to_path, btn_class: nil, has_tooltip: true) - commit_action_link('revert', commit, continue_to_path, btn_class: btn_class, has_tooltip: has_tooltip) + def revert_commit_link(commit, continue_to_path, btn_class: nil, pajamas: false) + return unless current_user + + action = 'revert' + + if pajamas && can_collaborate_with_project?(@project) + tag(:div, data: { display_text: action.capitalize }, class: "js-revert-commit-trigger") + else + commit_action_link(action, commit, continue_to_path, btn_class: btn_class, has_tooltip: false) + end end def cherry_pick_commit_link(commit, continue_to_path, btn_class: nil, has_tooltip: true) diff --git a/app/helpers/dashboard_helper.rb b/app/helpers/dashboard_helper.rb index 195b3162039..08f357916b5 100644 --- a/app/helpers/dashboard_helper.rb +++ b/app/helpers/dashboard_helper.rb @@ -11,6 +11,10 @@ module DashboardHelper merge_requests_dashboard_path(assignee_username: current_user.username) end + def reviewer_mrs_dashboard_path + merge_requests_dashboard_path(reviewer_username: current_user.username) + end + def dashboard_nav_links @dashboard_nav_links ||= get_dashboard_nav_links end diff --git a/app/helpers/emails_helper.rb b/app/helpers/emails_helper.rb index 017981c8c8e..b58ff21b257 100644 --- a/app/helpers/emails_helper.rb +++ b/app/helpers/emails_helper.rb @@ -214,6 +214,29 @@ module EmailsHelper end end + def group_membership_expiration_changed_text(member, group) + if member.expires? + days = (member.expires_at - Date.today).to_i + days_formatted = pluralize(days, 'day') + + _('Your %{group} membership will now expire in %{days}.') % { group: group.human_name, days: days_formatted } + else + _('Your membership in %{group} no longer expires.') % { group: group.human_name } + end + end + + def group_membership_expiration_changed_link(member, group, format: nil) + url = group_group_members_url(group, search: member.user.username) + + case format + when :html + link_to = generate_link('group membership', url).html_safe + _('For additional information, review your %{link_to} or contact your group owner.').html_safe % { link_to: link_to } + else + _('For additional information, review your group membership: %{link_to} or contact your group owner.') % { link_to: url } + end + end + def instance_access_request_text(user, format: nil) gitlab_host = Gitlab.config.gitlab.host diff --git a/app/helpers/graph_helper.rb b/app/helpers/graph_helper.rb index 24072d1ab46..abb3c5a7af8 100644 --- a/app/helpers/graph_helper.rb +++ b/app/helpers/graph_helper.rb @@ -22,4 +22,10 @@ module GraphHelper ratio = (counts[:success].to_f / (counts[:success] + counts[:failed])) * 100 ratio.to_i end + + def should_render_deployment_frequency_charts + false + end end + +GraphHelper.prepend_if_ee('EE::GraphHelper') diff --git a/app/helpers/groups/group_members_helper.rb b/app/helpers/groups/group_members_helper.rb index adc9d85a384..a4159ed6b19 100644 --- a/app/helpers/groups/group_members_helper.rb +++ b/app/helpers/groups/group_members_helper.rb @@ -18,7 +18,7 @@ module Groups::GroupMembersHelper end def members_data_json(group, members) - members_data(group, members).to_json + MemberSerializer.new.represent(members, { current_user: current_user, group: group }).to_json end # Overridden in `ee/app/helpers/ee/groups/group_members_helper.rb` @@ -38,84 +38,6 @@ module Groups::GroupMembersHelper group_id: group.id } end - - private - - def members_data(group, members) - members.map do |member| - user = member.user - source = member.source - - data = { - id: member.id, - created_at: member.created_at, - expires_at: member.expires_at&.to_time, - requested_at: member.requested_at, - can_update: member.can_update?, - can_remove: member.can_remove?, - access_level: { - string_value: member.human_access, - integer_value: member.access_level - }, - source: { - id: source.id, - name: source.full_name, - web_url: Gitlab::UrlBuilder.build(source) - }, - valid_roles: member.valid_level_roles - }.merge(member_created_by_data(member.created_by)) - - if member.invite? - data[:invite] = member_invite_data(member) - elsif user.present? - data[:user] = member_user_data(user) - end - - data - end - end - - def member_created_by_data(created_by) - return {} unless created_by.present? - - { - created_by: { - name: created_by.name, - web_url: Gitlab::UrlBuilder.build(created_by) - } - } - end - - def member_user_data(user) - { - id: user.id, - name: user.name, - username: user.username, - web_url: Gitlab::UrlBuilder.build(user), - avatar_url: avatar_icon_for_user(user, AVATAR_SIZE), - blocked: user.blocked?, - two_factor_enabled: user.two_factor_enabled? - }.merge(member_user_status_data(user.status)) - end - - def member_user_status_data(status) - return {} unless status.present? - - { - status: { - emoji: status.emoji, - message_html: status.message_html - } - } - end - - def member_invite_data(member) - { - email: member.invite_email, - avatar_url: avatar_icon_for_email(member.invite_email, AVATAR_SIZE), - can_resend: member.can_resend_invite? - } - end end Groups::GroupMembersHelper.prepend_if_ee('EE::Groups::GroupMembersHelper') diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb index e8eb6a5d417..133d9d21a14 100644 --- a/app/helpers/groups_helper.rb +++ b/app/helpers/groups_helper.rb @@ -22,6 +22,7 @@ module GroupsHelper ldap_group_links#index hooks#index pipeline_quota#index + packages_and_registries#index ] end diff --git a/app/helpers/invite_members_helper.rb b/app/helpers/invite_members_helper.rb index cea28fd4611..a643fea6d5a 100644 --- a/app/helpers/invite_members_helper.rb +++ b/app/helpers/invite_members_helper.rb @@ -22,4 +22,34 @@ module InviteMembersHelper def invite_group_members?(group) experiment_enabled?(:invite_members_empty_group_version_a) && Ability.allowed?(current_user, :admin_group_member, group) end + + def dropdown_invite_members_link(form_model) + link_to invite_members_url(form_model), + data: { + 'track-event': 'click_link', + 'track-label': tracking_label(current_user), + 'track-property': experiment_tracking_category_and_group(:invite_members_new_dropdown, subject: current_user) + } do + invite_member_link_content + end + end + + private + + def invite_members_url(form_model) + case form_model + when Project + project_project_members_path(form_model) + when Group + group_group_members_path(form_model) + end + end + + def invite_member_link_content + text = s_('InviteMember|Invite members') + + return text unless experiment_enabled?(:invite_members_new_dropdown) + + "#{text} #{emoji_icon('shaking_hands', 'aria-hidden': true, class: 'gl-font-base gl-vertical-align-baseline')}".html_safe + end end diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index 15842dec3dd..da142cbed0e 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -442,7 +442,8 @@ module IssuablesHelper fullPath: issuable[:project_full_path], iid: issuable[:iid], severity: issuable[:severity], - timeTrackingLimitToHours: Gitlab::CurrentSettings.time_tracking_limit_to_hours + timeTrackingLimitToHours: Gitlab::CurrentSettings.time_tracking_limit_to_hours, + createNoteEmail: issuable[:create_note_email] } end diff --git a/app/helpers/jira_connect_helper.rb b/app/helpers/jira_connect_helper.rb new file mode 100644 index 00000000000..f1527b9b85a --- /dev/null +++ b/app/helpers/jira_connect_helper.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module JiraConnectHelper + def new_jira_connect_ui? + Feature.enabled?(:new_jira_connect_ui, type: :development, default_enabled: :yaml) + end + + def jira_connect_app_data + { + groups_path: api_v4_groups_path(params: { min_access_level: Gitlab::Access::MAINTAINER }) + } + end +end diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb index 37e701c1c2b..6ab5f499b9a 100644 --- a/app/helpers/merge_requests_helper.rb +++ b/app/helpers/merge_requests_helper.rb @@ -159,6 +159,36 @@ module MergeRequestsHelper issuable_path(issuable, { merge_request: { wip_event: wip_event } }) end + + def user_merge_requests_counts + @user_merge_requests_counts ||= begin + assigned_count = assigned_issuables_count(:merge_requests) + review_requested_count = review_requested_merge_requests_count + total_count = assigned_count + review_requested_count + + { + assigned: assigned_count, + review_requested: review_requested_count, + total: total_count + } + end + end + + def merge_request_reviewers_enabled? + Feature.enabled?(:merge_request_reviewers, default_enabled: :yaml) + end + + private + + def review_requested_merge_requests_count + return 0 unless merge_request_reviewers_enabled? + + current_user.review_requested_open_merge_requests_count + end + + def default_suggestion_commit_message + @project.suggestion_commit_message.presence || Gitlab::Suggestions::CommitMessage::DEFAULT_SUGGESTION_COMMIT_MESSAGE + end end MergeRequestsHelper.prepend_if_ee('EE::MergeRequestsHelper') diff --git a/app/helpers/page_layout_helper.rb b/app/helpers/page_layout_helper.rb index e3d82e7a091..8920133734c 100644 --- a/app/helpers/page_layout_helper.rb +++ b/app/helpers/page_layout_helper.rb @@ -159,7 +159,7 @@ module PageLayoutHelper end def user_status_properties(user) - default_properties = { current_emoji: '', current_message: '', can_set_user_availability: Feature.enabled?(:set_user_availability_status, user), default_emoji: UserStatus::DEFAULT_EMOJI } + default_properties = { current_emoji: '', current_message: '', can_set_user_availability: Feature.enabled?(:set_user_availability_status, user, default_enabled: :yaml), default_emoji: UserStatus::DEFAULT_EMOJI } return default_properties unless user&.status default_properties.merge({ diff --git a/app/helpers/preferences_helper.rb b/app/helpers/preferences_helper.rb index 5310aef5bad..c2a77abb9c9 100644 --- a/app/helpers/preferences_helper.rb +++ b/app/helpers/preferences_helper.rb @@ -82,7 +82,7 @@ module PreferencesHelper def integration_views [].tap do |views| - views << { name: 'gitpod', message: gitpod_enable_description, message_url: 'https://gitpod.io/', help_link: help_page_path('integration/gitpod.md') } if Gitlab::Gitpod.feature_and_settings_enabled? + views << { name: 'gitpod', message: gitpod_enable_description, message_url: 'https://gitpod.io/', help_link: help_page_path('integration/gitpod.md') } if Gitlab::CurrentSettings.gitpod_enabled views << { name: 'sourcegraph', message: sourcegraph_url_message, message_url: Gitlab::CurrentSettings.sourcegraph_url, help_link: help_page_path('user/profile/preferences.md', anchor: 'sourcegraph') } if Gitlab::Sourcegraph.feature_available? && Gitlab::CurrentSettings.sourcegraph_enabled end end diff --git a/app/helpers/projects/alert_management_helper.rb b/app/helpers/projects/alert_management_helper.rb index 997551d9659..58f1abb2818 100644 --- a/app/helpers/projects/alert_management_helper.rb +++ b/app/helpers/projects/alert_management_helper.rb @@ -34,5 +34,3 @@ module Projects::AlertManagementHelper ) end end - -Projects::AlertManagementHelper.prepend_if_ee('EE::Projects::AlertManagementHelper') diff --git a/app/helpers/projects/project_members_helper.rb b/app/helpers/projects/project_members_helper.rb new file mode 100644 index 00000000000..168526d2abb --- /dev/null +++ b/app/helpers/projects/project_members_helper.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +module Projects::ProjectMembersHelper + def can_manage_project_members?(project) + can?(current_user, :admin_project_member, project) + end + + def show_groups?(group_links) + group_links.exists? || groups_tab_active? + end + + def show_invited_members?(project, invited_members) + can_manage_project_members?(project) && invited_members.exists? + end + + def show_access_requests?(project, requesters) + can_manage_project_members?(project) && requesters.exists? + end + + def groups_tab_active? + params[:search_groups].present? + end + + def current_user_is_group_owner?(project) + return false if project.group.nil? + + project.group.has_owner?(current_user) + end +end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 80206654cd1..b21d3ca51db 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -150,13 +150,7 @@ module ProjectsHelper end def can_change_visibility_level?(project, current_user) - return false unless can?(current_user, :change_visibility_level, project) - - if project.fork_source - project.fork_source.visibility_level > Gitlab::VisibilityLevel::PRIVATE - else - true - end + can?(current_user, :change_visibility_level, project) end def can_disable_emails?(project, current_user) diff --git a/app/helpers/services_helper.rb b/app/helpers/services_helper.rb index 3516000e296..5f361e6653d 100644 --- a/app/helpers/services_helper.rb +++ b/app/helpers/services_helper.rb @@ -76,6 +76,8 @@ module ServicesHelper end def scoped_reset_integration_path(integration, group: nil) + return '' unless integration.persisted? + if group.present? reset_group_settings_integration_path(group, integration) else @@ -102,7 +104,7 @@ module ServicesHelper cancel_path: scoped_integrations_path, can_test: integration.can_test?.to_s, test_path: scoped_test_integration_path(integration), - reset_path: reset_integration?(integration, group: group) ? scoped_reset_integration_path(integration, group: group) : '' + reset_path: scoped_reset_integration_path(integration, group: group) } end @@ -126,10 +128,6 @@ module ServicesHelper !Gitlab.com? end - def reset_integration?(integration, group: nil) - integration.persisted? && Feature.enabled?(:reset_integrations, group, type: :development) - end - extend self private diff --git a/app/helpers/startup_css_helper.rb b/app/helpers/startup_css_helper.rb deleted file mode 100644 index b54e19bfc0d..00000000000 --- a/app/helpers/startup_css_helper.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -module StartupCssHelper - def use_startup_css? - (Feature.enabled?(:startup_css) || params[:startup_css] == 'true' || cookies['startup_css'] == 'true') && !Rails.env.test? - end -end diff --git a/app/helpers/tab_helper.rb b/app/helpers/tab_helper.rb index 6fbe2642056..e81986d4453 100644 --- a/app/helpers/tab_helper.rb +++ b/app/helpers/tab_helper.rb @@ -72,7 +72,8 @@ module TabHelper # Add our custom class into the html_options, which may or may not exist # and which may or may not already have a :class key o = options.delete(:html_options) || {} - o[:class] = [*o[:class], klass].join(' ').strip + o[:class] = [*o[:class], klass].join(' ') + o[:class].strip! if block_given? content_tag(:li, capture(&block), o) diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index a58f8a6f792..a5d4d6872df 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -3,7 +3,7 @@ module UsersHelper def admin_users_data_attributes(users) { - users: Admin::UserSerializer.new.represent(users).to_json, + users: Admin::UserSerializer.new.represent(users, { current_user: current_user }).to_json, paths: admin_users_paths.to_json } end diff --git a/app/helpers/visibility_level_helper.rb b/app/helpers/visibility_level_helper.rb index 0a37257e124..696f29164fd 100644 --- a/app/helpers/visibility_level_helper.rb +++ b/app/helpers/visibility_level_helper.rb @@ -26,76 +26,6 @@ module VisibilityLevelHelper end end - def project_visibility_level_description(level) - case level - when Gitlab::VisibilityLevel::PRIVATE - _("Project access must be granted explicitly to each user. If this project is part of a group, access will be granted to members of the group.") - when Gitlab::VisibilityLevel::INTERNAL - _("The project can be accessed by any logged in user except external users.") - when Gitlab::VisibilityLevel::PUBLIC - _("The project can be accessed without any authentication.") - end - end - - def group_visibility_level_description(level) - case level - when Gitlab::VisibilityLevel::PRIVATE - _("The group and its projects can only be viewed by members.") - when Gitlab::VisibilityLevel::INTERNAL - _("The group and any internal projects can be viewed by any logged in user except external users.") - when Gitlab::VisibilityLevel::PUBLIC - _("The group and any public projects can be viewed without any authentication.") - end - end - - # Note: these messages closely mirror the form validation strings found in the project - # model and any changes or additons to these may also need to be made there. - def disallowed_project_visibility_level_description(level, project) - level_name = Gitlab::VisibilityLevel.level_name(level).downcase - reasons = [] - instructions = [] - - unless project.visibility_level_allowed_as_fork?(level) - reasons << "the fork source project has lower visibility" - end - - unless project.visibility_level_allowed_by_group?(level) - errors = visibility_level_errors_for_group(project.group, level_name) - - reasons << errors[:reason] - instructions << errors[:instruction] - end - - reasons = reasons.any? ? ' because ' + reasons.to_sentence : '' - "This project cannot be #{level_name}#{reasons}.#{instructions.join}".html_safe - end - - # Note: these messages closely mirror the form validation strings found in the group - # model and any changes or additons to these may also need to be made there. - def disallowed_group_visibility_level_description(level, group) - level_name = Gitlab::VisibilityLevel.level_name(level).downcase - reasons = [] - instructions = [] - - unless group.visibility_level_allowed_by_projects?(level) - reasons << "it contains projects with higher visibility" - end - - unless group.visibility_level_allowed_by_sub_groups?(level) - reasons << "it contains sub-groups with higher visibility" - end - - unless group.visibility_level_allowed_by_parent?(level) - errors = visibility_level_errors_for_group(group.parent, level_name) - - reasons << errors[:reason] - instructions << errors[:instruction] - end - - reasons = reasons.any? ? ' because ' + reasons.to_sentence : '' - "This group cannot be #{level_name}#{reasons}.#{instructions.join}".html_safe - end - def visibility_icon_description(form_model) if form_model.respond_to?(:visibility_level_allowed_as_fork?) project_visibility_icon_description(form_model.visibility_level) @@ -104,14 +34,6 @@ module VisibilityLevelHelper end end - def group_visibility_icon_description(level) - "#{visibility_level_label(level)} - #{group_visibility_level_description(level)}" - end - - def project_visibility_icon_description(level) - "#{visibility_level_label(level)} - #{project_visibility_level_description(level)}" - end - def visibility_level_label(level) # The visibility level can be: # 'VisibilityLevel|Private', 'VisibilityLevel|Internal', 'VisibilityLevel|Public' @@ -203,11 +125,33 @@ module VisibilityLevelHelper current_level end - def visibility_level_errors_for_group(group, level_name) - group_name = link_to group.name, group_path(group) - change_visibility = link_to 'change the visibility', edit_group_path(group) + def project_visibility_level_description(level) + case level + when Gitlab::VisibilityLevel::PRIVATE + _("Project access must be granted explicitly to each user. If this project is part of a group, access will be granted to members of the group.") + when Gitlab::VisibilityLevel::INTERNAL + _("The project can be accessed by any logged in user except external users.") + when Gitlab::VisibilityLevel::PUBLIC + _("The project can be accessed without any authentication.") + end + end + + def group_visibility_level_description(level) + case level + when Gitlab::VisibilityLevel::PRIVATE + _("The group and its projects can only be viewed by members.") + when Gitlab::VisibilityLevel::INTERNAL + _("The group and any internal projects can be viewed by any logged in user except external users.") + when Gitlab::VisibilityLevel::PUBLIC + _("The group and any public projects can be viewed without any authentication.") + end + end - { reason: "the visibility of #{group_name} is #{group.visibility}", - instruction: " To make this group #{level_name}, you must first #{change_visibility} of the parent group." } + def project_visibility_icon_description(level) + "#{visibility_level_label(level)} - #{project_visibility_level_description(level)}" + end + + def group_visibility_icon_description(level) + "#{visibility_level_label(level)} - #{group_visibility_level_description(level)}" end end diff --git a/app/helpers/web_ide_button_helper.rb b/app/helpers/web_ide_button_helper.rb index 7aa0adc31bd..6c73d365e8e 100644 --- a/app/helpers/web_ide_button_helper.rb +++ b/app/helpers/web_ide_button_helper.rb @@ -26,7 +26,7 @@ module WebIdeButtonHelper end def show_gitpod_button? - show_web_ide_button? && Gitlab::Gitpod.feature_and_settings_enabled?(@project) + show_web_ide_button? && Gitlab::CurrentSettings.gitpod_enabled end def can_push_code? @@ -54,7 +54,7 @@ module WebIdeButtonHelper end def gitpod_url - return "" unless Gitlab::Gitpod.feature_and_settings_enabled?(@project) + return "" unless Gitlab::CurrentSettings.gitpod_enabled "#{Gitlab::CurrentSettings.gitpod_url}##{project_tree_url(@project, tree_join(@ref, @path || ''))}" end |