diff options
Diffstat (limited to 'app/helpers')
36 files changed, 279 insertions, 74 deletions
diff --git a/app/helpers/analytics/navbar_helper.rb b/app/helpers/analytics/navbar_helper.rb index ddf2655c887..bc0b5e7c74f 100644 --- a/app/helpers/analytics/navbar_helper.rb +++ b/app/helpers/analytics/navbar_helper.rb @@ -28,7 +28,7 @@ module Analytics private def navbar_sub_item(args) - NavbarSubItem.new(args) + NavbarSubItem.new(**args) end def cycle_analytics_navbar_link(project, current_user) diff --git a/app/helpers/analytics/unique_visits_helper.rb b/app/helpers/analytics/unique_visits_helper.rb index ded7f54e44e..4c709b2ed23 100644 --- a/app/helpers/analytics/unique_visits_helper.rb +++ b/app/helpers/analytics/unique_visits_helper.rb @@ -14,8 +14,7 @@ module Analytics end def track_visit(target_id) - return unless Feature.enabled?(:track_unique_visits) - return unless Gitlab::CurrentSettings.usage_ping_enabled? + return unless Feature.enabled?(:track_unique_visits, default_enabled: true) return unless visitor_id Gitlab::Analytics::UniqueVisits.new.track_visit(visitor_id, target_id) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a81225c8954..665184f268c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -8,8 +8,16 @@ module ApplicationHelper # See https://docs.gitlab.com/ee/development/ee_features.html#code-in-app-views # rubocop: disable CodeReuse/ActiveRecord - def render_if_exists(partial, locals = {}) - render(partial, locals) if partial_exists?(partial) + # We allow partial to be nil so that collection views can be passed in + # `render partial: 'some/view', collection: @some_collection` + def render_if_exists(partial = nil, **options) + return unless partial_exists?(partial || options[:partial]) + + if partial.nil? + render(**options) + else + render(partial, options) + end end def partial_exists?(partial) @@ -349,6 +357,12 @@ module ApplicationHelper } end + def add_page_specific_style(path) + content_for :page_specific_styles do + stylesheet_link_tag_defer path + end + end + def page_startup_api_calls @api_startup_calls end diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb index 9245cc1cb1c..3da4113497f 100644 --- a/app/helpers/application_settings_helper.rb +++ b/app/helpers/application_settings_helper.rb @@ -168,7 +168,7 @@ module ApplicationSettingsHelper def visible_attributes [ - :admin_notification_email, + :abuse_notification_email, :after_sign_out_path, :after_sign_up_text, :akismet_api_key, @@ -265,6 +265,7 @@ module ApplicationSettingsHelper :receive_max_input_size, :repository_checks_enabled, :repository_storages_weighted, + :require_admin_approval_after_user_signup, :require_two_factor_authentication, :restricted_visibility_levels, :rsa_key_restriction, @@ -345,6 +346,12 @@ module ApplicationSettingsHelper ] end + def deprecated_attributes + [ + :admin_notification_email # ok to remove in REST API v5 + ] + end + def expanded_by_default? Rails.env.test? end diff --git a/app/helpers/avatars_helper.rb b/app/helpers/avatars_helper.rb index 68dbc5b65d1..5457f96d506 100644 --- a/app/helpers/avatars_helper.rb +++ b/app/helpers/avatars_helper.rb @@ -60,7 +60,7 @@ module AvatarsHelper avatar_size = options[:size] || 16 user_name = options[:user].try(:name) || options[:user_name] - avatar_url = user_avatar_url_for(options.merge(size: avatar_size)) + avatar_url = user_avatar_url_for(**options.merge(size: avatar_size)) has_tooltip = options[:has_tooltip].nil? ? true : options[:has_tooltip] data_attributes = options[:data] || {} diff --git a/app/helpers/boards_helper.rb b/app/helpers/boards_helper.rb index 6a4a7a8dfb2..4750580e20d 100644 --- a/app/helpers/boards_helper.rb +++ b/app/helpers/boards_helper.rb @@ -14,6 +14,7 @@ module BoardsHelper root_path: root_path, full_path: full_path, bulk_update_path: @bulk_issues_path, + can_update: (!!can?(current_user, :admin_issue, board)).to_s, time_tracking_limit_to_hours: Gitlab::CurrentSettings.time_tracking_limit_to_hours.to_s, recent_boards_endpoint: recent_boards_path, parent: current_board_parent.model_name.param_key, diff --git a/app/helpers/clusters_helper.rb b/app/helpers/clusters_helper.rb index caad215e996..cc633df77f9 100644 --- a/app/helpers/clusters_helper.rb +++ b/app/helpers/clusters_helper.rb @@ -12,6 +12,18 @@ module ClustersHelper end end + def display_cluster_agents?(_clusterable) + false + end + + def js_cluster_agents_list_data(clusterable_project) + { + default_branch_name: clusterable_project.default_branch, + empty_state_image: image_path('illustrations/clusters_empty.svg'), + project_path: clusterable_project.full_path + } + end + def js_clusters_list_data(path = nil) { ancestor_help_path: help_page_path('user/group/clusters/index', anchor: 'cluster-precedence'), @@ -42,14 +54,6 @@ module ClustersHelper } end - # This method is depreciated and will be removed when associated HAML files are moved to JavaScript - def provider_icon(provider = nil) - img_data = js_clusters_list_data.dig(:img_tags, provider&.to_sym) || - js_clusters_list_data.dig(:img_tags, :default) - - image_tag img_data[:path], alt: img_data[:text], class: 'gl-h-full' - end - def render_gcp_signup_offer return if Gitlab::CurrentSettings.current_application_settings.hide_third_party_offers? return unless show_gcp_signup_offer? diff --git a/app/helpers/emails_helper.rb b/app/helpers/emails_helper.rb index d5c22927991..0a0dc77e5e2 100644 --- a/app/helpers/emails_helper.rb +++ b/app/helpers/emails_helper.rb @@ -218,8 +218,28 @@ module EmailsHelper _('Please contact your administrator with any questions.') end + def change_reviewer_notification_text(new_reviewers, previous_reviewers, html_tag = nil) + new = new_reviewers.any? ? users_to_sentence(new_reviewers) : s_('ChangeReviewer|Unassigned') + old = previous_reviewers.any? ? users_to_sentence(previous_reviewers) : nil + + if html_tag.present? + new = content_tag(html_tag, new) + old = content_tag(html_tag, old) if old.present? + end + + if old.present? + s_('ChangeReviewer|Reviewer changed from %{old} to %{new}').html_safe % { old: old, new: new } + else + s_('ChangeReviewer|Reviewer changed to %{new}').html_safe % { new: new } + end + end + private + def users_to_sentence(users) + sanitize_name(users.map(&:name).to_sentence) + end + def generate_link(text, url) link_to(text, url, target: :_blank, rel: 'noopener noreferrer') end diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index 0167f2ef698..f40755b9439 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -28,19 +28,7 @@ module EventsHelper end def event_action_name(event) - target = if event.target_type - if event.design? || event.design_note? - 'design' - elsif event.wiki_page? - 'wiki page' - elsif event.note? - event.note_target_type - else - event.target_type.titleize.downcase - end - else - 'project' - end + target = event.note_target_type_name || event.target_type_name [event.action_name, target].join(" ") end @@ -229,7 +217,7 @@ module EventsHelper def event_note_title_html(event) if event.note_target capture do - concat content_tag(:span, event.note_target_type, class: "event-target-type gl-mr-2") + concat content_tag(:span, event.note_target_type_name, class: "event-target-type gl-mr-2") concat link_to(event.note_target_reference, event_note_target_url(event), title: event.target_title, class: 'has-tooltip event-target-link gl-mr-2') end else diff --git a/app/helpers/feature_flags_helper.rb b/app/helpers/feature_flags_helper.rb new file mode 100644 index 00000000000..e50191a471f --- /dev/null +++ b/app/helpers/feature_flags_helper.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module FeatureFlagsHelper + include ::API::Helpers::RelatedResourcesHelpers + + def unleash_api_url(project) + expose_url(api_v4_feature_flags_unleash_path(project_id: project.id)) + end + + def unleash_api_instance_id(project) + project.feature_flags_client_token + end + + def feature_flag_issues_links_endpoint(_project, _feature_flag, _user) + '' + end +end + +FeatureFlagsHelper.prepend_if_ee('::EE::FeatureFlagsHelper') diff --git a/app/helpers/gitlab_routing_helper.rb b/app/helpers/gitlab_routing_helper.rb index d71e6b4c004..7df6bef7914 100644 --- a/app/helpers/gitlab_routing_helper.rb +++ b/app/helpers/gitlab_routing_helper.rb @@ -343,6 +343,18 @@ module GitlabRoutingHelper Gitlab::UrlBuilder.wiki_page_url(wiki, page, only_path: true, **options) end + def gitlab_ide_merge_request_path(merge_request) + target_project = merge_request.target_project + source_project = merge_request.source_project + params = {} + + if target_project != source_project + params = { target_project: target_project.full_path } + end + + ide_merge_request_path(source_project.namespace, source_project, merge_request, params) + end + private def snippet_query_params(snippet, *args) diff --git a/app/helpers/gitpod_helper.rb b/app/helpers/gitpod_helper.rb new file mode 100644 index 00000000000..7edf7dc218d --- /dev/null +++ b/app/helpers/gitpod_helper.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module GitpodHelper + def gitpod_enable_description + link_start = '<a href="https://gitpod.io/" target="_blank" rel="noopener noreferrer">'.html_safe + link_end = "#{sprite_icon('external-link', size: 12, css_class: 'ml-1 vertical-align-center')}</a>".html_safe + + s_('Enable %{link_start}Gitpod%{link_end} integration to launch a development environment in your browser directly from GitLab.').html_safe % { link_start: link_start, link_end: link_end } + end +end diff --git a/app/helpers/groups/group_members_helper.rb b/app/helpers/groups/group_members_helper.rb index dcff2be34da..0782961f541 100644 --- a/app/helpers/groups/group_members_helper.rb +++ b/app/helpers/groups/group_members_helper.rb @@ -10,11 +10,11 @@ module Groups::GroupMembersHelper end def render_invite_member_for_group(group, default_access_level) - render 'shared/members/invite_member', submit_url: group_group_members_path(group), access_levels: GroupMember.access_level_roles, default_access_level: default_access_level + render 'shared/members/invite_member', submit_url: group_group_members_path(group), access_levels: group.access_level_roles, default_access_level: default_access_level end def linked_groups_data_json(group_links) - GroupGroupLinkSerializer.new.represent(group_links).to_json + GroupGroupLinkSerializer.new.represent(group_links, { current_user: current_user }).to_json end def members_data_json(group, members) @@ -47,10 +47,10 @@ module Groups::GroupMembersHelper } }.merge(member_created_by_data(member.created_by)) - if user.present? - data[:user] = member_user_data(user) - else + if member.invite? data[:invite] = member_invite_data(member) + elsif user.present? + data[:user] = member_user_data(user) end data @@ -77,6 +77,17 @@ module Groups::GroupMembersHelper 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 diff --git a/app/helpers/invite_members_helper.rb b/app/helpers/invite_members_helper.rb new file mode 100644 index 00000000000..cbd08cb82ed --- /dev/null +++ b/app/helpers/invite_members_helper.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +module InviteMembersHelper + def invite_members_allowed?(group) + Feature.enabled?(:invite_members_group_modal, group) && can?(current_user, :admin_group_member, group) + end +end diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index b255597b18d..5b5902b1fa2 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -4,7 +4,10 @@ module IssuablesHelper include GitlabRoutingHelper def sidebar_gutter_toggle_icon - sidebar_gutter_collapsed? ? icon('angle-double-left', { 'aria-hidden': 'true' }) : icon('angle-double-right', { 'aria-hidden': 'true' }) + content_tag(:span, class: 'js-sidebar-toggle-container', data: { is_expanded: !sidebar_gutter_collapsed? }) do + sprite_icon('chevron-double-lg-left', css_class: "js-sidebar-expand #{'hidden' unless sidebar_gutter_collapsed?}") + + sprite_icon('chevron-double-lg-right', css_class: "js-sidebar-collapse #{'hidden' if sidebar_gutter_collapsed?}") + end end def sidebar_gutter_collapsed_class @@ -206,7 +209,7 @@ module IssuablesHelper end if access = project.team.human_max_access(issuable.author_id) - output << content_tag(:span, access, class: "user-access-role has-tooltip d-none d-xl-inline-block gl-ml-3 ", title: _("This user is a %{access} of the %{name} project.") % { access: access.downcase, name: project.name }) + output << content_tag(:span, access, class: "user-access-role has-tooltip d-none d-xl-inline-block gl-ml-3 ", title: _("This user has the %{access} role in the %{name} project.") % { access: access.downcase, name: project.name }) elsif project.team.contributor?(issuable.author_id) output << content_tag(:span, _("Contributor"), class: "user-access-role has-tooltip d-none d-xl-inline-block gl-ml-3", title: _("This user has previously committed to the %{name} project.") % { name: project.name }) end @@ -342,6 +345,12 @@ module IssuablesHelper issuable.closed? ^ should_inverse ? reopen_issuable_path(issuable) : close_issuable_path(issuable) end + def toggle_draft_issuable_path(issuable) + wip_event = issuable.work_in_progress? ? 'unwip' : 'wip' + + issuable_path(issuable, { merge_request: { wip_event: wip_event } }) + end + def issuable_path(issuable, *options) polymorphic_path(issuable, *options) end @@ -386,6 +395,12 @@ module IssuablesHelper end end + def reviewer_sidebar_data(reviewer, merge_request: nil) + { avatar_url: reviewer.avatar_url, name: reviewer.name, username: reviewer.username }.tap do |data| + data[:can_merge] = merge_request.can_be_merged_by?(reviewer) if merge_request + end + end + def issuable_squash_option?(issuable, project) if issuable.persisted? issuable.squash diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index e8ea39d7ffc..dbf284e70e4 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -137,6 +137,21 @@ module IssuesHelper issue.moved_from.project.service_desk_enabled? && !issue.project.service_desk_enabled? end + + def use_startup_call? + request.query_parameters.empty? && @sort == 'created_date' + end + + def startup_call_params + { + state: 'opened', + with_labels_details: 'true', + page: 1, + per_page: 20, + order_by: 'created_at', + sort: 'desc' + } + end end IssuesHelper.prepend_if_ee('EE::IssuesHelper') diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb index 3142d7d7782..bfe1728adad 100644 --- a/app/helpers/labels_helper.rb +++ b/app/helpers/labels_helper.rb @@ -36,11 +36,11 @@ module LabelsHelper # link_to_label(label) { "My Custom Label Text" } # # Returns a String - def link_to_label(label, type: :issue, tooltip: true, small: false, &block) + def link_to_label(label, type: :issue, tooltip: true, small: false, css_class: nil, &block) link = label.filter_path(type: type) if block_given? - link_to link, &block + link_to link, class: css_class, &block else render_label(label, link: link, tooltip: tooltip, small: small) end diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb index 1125ecb9b41..9cb7edbaeb6 100644 --- a/app/helpers/merge_requests_helper.rb +++ b/app/helpers/merge_requests_helper.rb @@ -109,10 +109,6 @@ module MergeRequestsHelper @merge_request_diffs.size - @merge_request_diffs.index(merge_request_diff) end - def different_base?(version1, version2) - version1 && version2 && version1.base_commit_sha != version2.base_commit_sha - end - def merge_params(merge_request) { auto_merge_strategy: AutoMergeService::STRATEGY_MERGE_WHEN_PIPELINE_SUCCEEDS, diff --git a/app/helpers/namespaces_helper.rb b/app/helpers/namespaces_helper.rb index 81451e398f2..8cf5cd49322 100644 --- a/app/helpers/namespaces_helper.rb +++ b/app/helpers/namespaces_helper.rb @@ -53,7 +53,7 @@ module NamespacesHelper selected = options.delete(:selected) || :current_user options[:groups] = current_user.manageable_groups_with_routes(include_groups_with_developer_maintainer_access: true) - namespaces_options(selected, options) + namespaces_options(selected, **options) end private diff --git a/app/helpers/nav_helper.rb b/app/helpers/nav_helper.rb index 578c7ae7923..3c757a4ef26 100644 --- a/app/helpers/nav_helper.rb +++ b/app/helpers/nav_helper.rb @@ -55,7 +55,8 @@ module NavHelper current_path?('projects/merge_requests/conflicts#show') || current_path?('issues#show') || current_path?('milestones#show') || - current_path?('issues#designs') + current_path?('issues#designs') || + current_path?('incidents#show') end def admin_monitoring_nav_links diff --git a/app/helpers/packages_helper.rb b/app/helpers/packages_helper.rb index e6ecc403a88..0a296b4e6ba 100644 --- a/app/helpers/packages_helper.rb +++ b/app/helpers/packages_helper.rb @@ -51,9 +51,15 @@ module PackagesHelper { resource_id: resource.id, page_type: type, - empty_list_help_url: help_page_path('administration/packages/index'), + empty_list_help_url: help_page_path('user/packages/package_registry/index'), empty_list_illustration: image_path('illustrations/no-packages.svg'), - coming_soon_json: packages_coming_soon_data(resource).to_json + coming_soon_json: packages_coming_soon_data(resource).to_json, + package_help_url: help_page_path('user/packages/index') } end + + def track_package_event(event_name, scope, **args) + ::Packages::CreateEventService.new(nil, current_user, event_name: event_name, scope: scope).execute + track_event(event_name, **args) + end end diff --git a/app/helpers/page_layout_helper.rb b/app/helpers/page_layout_helper.rb index a44760e85ca..6808ffc3e27 100644 --- a/app/helpers/page_layout_helper.rb +++ b/app/helpers/page_layout_helper.rb @@ -40,6 +40,14 @@ module PageLayoutHelper end end + def page_canonical_link(link = nil) + if link + @page_canonical_link = link + else + @page_canonical_link + end + end + def favicon Gitlab::Favicon.main end diff --git a/app/helpers/preferences_helper.rb b/app/helpers/preferences_helper.rb index 2c406641882..9bf819febb0 100644 --- a/app/helpers/preferences_helper.rb +++ b/app/helpers/preferences_helper.rb @@ -61,8 +61,8 @@ module PreferencesHelper @user_application_theme ||= Gitlab::Themes.for_user(current_user).css_class end - def user_application_theme_name - @user_application_theme_name ||= Gitlab::Themes.for_user(current_user).name.downcase.tr(' ', '_') + def user_application_theme_css_filename + @user_application_theme_css_filename ||= Gitlab::Themes.for_user(current_user).css_filename end def user_color_scheme diff --git a/app/helpers/profiles_helper.rb b/app/helpers/profiles_helper.rb index 5a42e581867..44d869fbd8f 100644 --- a/app/helpers/profiles_helper.rb +++ b/app/helpers/profiles_helper.rb @@ -29,4 +29,19 @@ module ProfilesHelper def user_profile? params[:controller] == 'users' end + + def ssh_key_delete_modal_data(key, is_admin) + { + path: path_to_key(key, is_admin), + method: 'delete', + qa_selector: 'delete_ssh_key_button', + modal_attributes: { + 'data-qa-selector': 'ssh_key_delete_modal', + title: _('Are you sure you want to delete this SSH key?'), + message: _('This action cannot be undone, and will permanently delete the %{key} SSH key') % { key: key.title }, + okVariant: 'danger', + okTitle: _('Delete') + } + } + end end diff --git a/app/helpers/projects/incidents_helper.rb b/app/helpers/projects/incidents_helper.rb index e96f0f5a384..0cac142f2dc 100644 --- a/app/helpers/projects/incidents_helper.rb +++ b/app/helpers/projects/incidents_helper.rb @@ -1,14 +1,17 @@ # frozen_string_literal: true module Projects::IncidentsHelper - def incidents_data(project) + def incidents_data(project, params) { 'project-path' => project.full_path, 'new-issue-path' => new_project_issue_path(project), 'incident-template-name' => 'incident', 'incident-type' => 'incident', 'issue-path' => project_issues_path(project), - 'empty-list-svg-path' => image_path('illustrations/incident-empty-state.svg') + 'empty-list-svg-path' => image_path('illustrations/incident-empty-state.svg'), + 'text-query': params[:search], + 'author-usernames-query': params[:author_username], + 'assignee-usernames-query': params[:assignee_username] } end end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 72cc07b13a5..6e317a63e47 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -468,7 +468,7 @@ module ProjectsHelper serverless: :read_cluster, error_tracking: :read_sentry_issue, alert_management: :read_alert_management_alert, - incidents: :read_incidents, + incidents: :read_issue, labels: :read_label, issues: :read_issue, project_members: :read_project_member, @@ -477,7 +477,14 @@ module ProjectsHelper end def can_view_operations_tab?(current_user, project) - [:read_environment, :read_cluster, :metrics_dashboard].any? do |ability| + [ + :metrics_dashboard, + :read_alert_management_alert, + :read_environment, + :read_issue, + :read_sentry_issue, + :read_cluster + ].any? do |ability| can?(current_user, ability, project) end end @@ -758,10 +765,6 @@ module ProjectsHelper !project.repository.gitlab_ci_yml end - def native_code_navigation_enabled?(project) - Feature.enabled?(:code_navigation, project, default_enabled: true) - end - def show_visibility_confirm_modal?(project) project.unlink_forks_upon_visibility_decrease_enabled? && project.visibility_level > Gitlab::VisibilityLevel::PRIVATE && project.forks_count > 0 end @@ -774,7 +777,7 @@ module ProjectsHelper def project_access_token_available?(project) return false if ::Gitlab.com? - ::Feature.enabled?(:resource_access_token, project, default_enabled: true) + can?(current_user, :admin_resource_access_tokens, project) end end diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb index d55ad878b92..36b58be60fc 100644 --- a/app/helpers/search_helper.rb +++ b/app/helpers/search_helper.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module SearchHelper - SEARCH_PERMITTED_PARAMS = [:search, :scope, :project_id, :group_id, :repository_ref, :snippets, :state].freeze + SEARCH_PERMITTED_PARAMS = [:search, :scope, :project_id, :group_id, :repository_ref, :snippets, :sort, :state, :confidential].freeze def search_autocomplete_opts(term) return unless current_user @@ -86,6 +86,11 @@ module SearchHelper }).html_safe end + def repository_ref(project) + # Always #to_s the repository_ref param in case the value is also a number + params[:repository_ref].to_s.presence || project.default_branch + end + # Overridden in EE def search_blob_title(project, path) path @@ -294,9 +299,12 @@ module SearchHelper sanitize(html, tags: %w(a p ol ul li pre code)) end - def show_user_search_tab? - return false if Feature.disabled?(:users_search, default_enabled: true) + # _search_highlight is used in EE override + def highlight_and_truncate_issue(issue, search_term, _search_highlight) + simple_search_highlight_and_truncate(issue.description, search_term, highlighter: '<span class="gl-text-black-normal gl-font-weight-bold">\1</span>') + end + def show_user_search_tab? if @project project_search_tabs?(:members) else diff --git a/app/helpers/services_helper.rb b/app/helpers/services_helper.rb index 6b5de73a831..ae59f84e7da 100644 --- a/app/helpers/services_helper.rb +++ b/app/helpers/services_helper.rb @@ -124,6 +124,10 @@ module ServicesHelper @group.present? && Feature.enabled?(:group_level_integrations, @group) end + def instance_level_integrations? + !Gitlab.com? + end + extend self private diff --git a/app/helpers/suggest_pipeline_helper.rb b/app/helpers/suggest_pipeline_helper.rb index aa67f0ea770..d64e8d6f2cd 100644 --- a/app/helpers/suggest_pipeline_helper.rb +++ b/app/helpers/suggest_pipeline_helper.rb @@ -2,7 +2,7 @@ module SuggestPipelineHelper def should_suggest_gitlab_ci_yml? - Feature.enabled?(:suggest_pipeline) && + experiment_enabled?(:suggest_pipeline) && current_user && params[:suggest_gitlab_ci_yml] == 'true' end diff --git a/app/helpers/system_note_helper.rb b/app/helpers/system_note_helper.rb index 0227ad1092d..79f4810e13a 100644 --- a/app/helpers/system_note_helper.rb +++ b/app/helpers/system_note_helper.rb @@ -2,6 +2,8 @@ module SystemNoteHelper ICON_NAMES_BY_ACTION = { + 'approved' => 'approval', + 'unapproved' => 'unapproval', 'cherry_pick' => 'cherry-pick-commit', 'commit' => 'commit', 'description' => 'pencil-square', @@ -11,6 +13,7 @@ module SystemNoteHelper 'closed' => 'issue-close', 'time_tracking' => 'timer', 'assignee' => 'user', + 'reviewer' => 'user', 'title' => 'pencil-square', 'task' => 'task-done', 'label' => 'label', @@ -34,7 +37,8 @@ module SystemNoteHelper 'designs_discussion_added' => 'doc-image', 'status' => 'status', 'alert_issue_added' => 'issues', - 'new_alert_added' => 'warning' + 'new_alert_added' => 'warning', + 'severity' => 'information-o' }.freeze def system_note_icon_name(note) diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb index 4984b51555d..bfc8803f514 100644 --- a/app/helpers/tags_helper.rb +++ b/app/helpers/tags_helper.rb @@ -38,4 +38,13 @@ module TagsHelper text.html_safe end + + def delete_tag_modal_attributes(tag_name) + { + title: s_('TagsPage|Delete tag'), + message: s_('TagsPage|Deleting the %{tag_name} tag cannot be undone. Are you sure?') % { tag_name: tag_name }, + okVariant: 'danger', + okTitle: s_('TagsPage|Delete tag') + }.to_json + end end diff --git a/app/helpers/timeboxes_helper.rb b/app/helpers/timeboxes_helper.rb index 34919f994ee..bbf8cf7dac3 100644 --- a/app/helpers/timeboxes_helper.rb +++ b/app/helpers/timeboxes_helper.rb @@ -228,8 +228,8 @@ module TimeboxesHelper end alias_method :milestone_date_range, :timebox_date_range - def milestone_tab_path(milestone, tab) - url_for(action: tab, format: :json) + def milestone_tab_path(milestone, tab, params = {}) + url_for(params.merge(action: tab, format: :json)) end def update_milestone_path(milestone, params = {}) diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 9865f7dfbef..7b0e0df8998 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -16,6 +16,7 @@ module TodosHelper def todo_action_name(todo) case todo.action when Todo::ASSIGNED then todo.self_added? ? 'assigned' : 'assigned you' + when Todo::REVIEW_REQUESTED then 'requested a review of' when Todo::MENTIONED then "mentioned #{todo_action_subject(todo)} on" when Todo::BUILD_FAILED then 'The build failed for' when Todo::MARKED then 'added a todo for' @@ -26,6 +27,13 @@ module TodosHelper end end + def todo_self_addressing(todo) + case todo.action + when Todo::ASSIGNED then 'to yourself' + when Todo::REVIEW_REQUESTED then 'from yourself' + end + end + def todo_target_link(todo) text = raw(todo_target_type_name(todo) + ' ') + if todo.for_commit? @@ -141,6 +149,7 @@ module TodosHelper [ { id: '', text: 'Any Action' }, { id: Todo::ASSIGNED, text: 'Assigned' }, + { id: Todo::REVIEW_REQUESTED, text: 'Review requested' }, { id: Todo::MENTIONED, text: 'Mentioned' }, { id: Todo::MARKED, text: 'Added' }, { id: Todo::BUILD_FAILED, text: 'Pipelines' }, diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb index 7644ed783eb..1d8d9ddc1ec 100644 --- a/app/helpers/tree_helper.rb +++ b/app/helpers/tree_helper.rb @@ -199,14 +199,14 @@ module TreeHelper } end - def ide_base_path(project) + def web_ide_url_data(project) can_push_code = current_user&.can?(:push_code, project) fork_path = current_user&.fork_of(project)&.full_path - if can_push_code - project.full_path + if fork_path && !can_push_code + { path: fork_path, is_fork: true } else - fork_path || project.full_path + { path: project.full_path, is_fork: false } end end @@ -216,7 +216,7 @@ module TreeHelper show_web_ide_button = (can_collaborate || current_user&.already_forked?(project) || can_create_mr_from_fork) { - ide_base_path: ide_base_path(project), + web_ide_url_data: web_ide_url_data(project), needs_to_fork: !can_collaborate && !current_user&.already_forked?(project), show_web_ide_button: show_web_ide_button, show_gitpod_button: show_web_ide_button && Gitlab::Gitpod.feature_and_settings_enabled?(project), diff --git a/app/helpers/user_callouts_helper.rb b/app/helpers/user_callouts_helper.rb index 967271a8431..b0cfda67ad4 100644 --- a/app/helpers/user_callouts_helper.rb +++ b/app/helpers/user_callouts_helper.rb @@ -9,7 +9,6 @@ module UserCalloutsHelper TABS_POSITION_HIGHLIGHT = 'tabs_position_highlight' WEBHOOKS_MOVED = 'webhooks_moved' CUSTOMIZE_HOMEPAGE = 'customize_homepage' - WEB_IDE_ALERT_DISMISSED = 'web_ide_alert_dismissed' def show_admin_integrations_moved? !user_dismissed?(ADMIN_INTEGRATIONS_MOVED) @@ -51,10 +50,6 @@ module UserCalloutsHelper customize_homepage && !user_dismissed?(CUSTOMIZE_HOMEPAGE) end - def show_web_ide_alert? - !user_dismissed?(WEB_IDE_ALERT_DISMISSED) - end - private def user_dismissed?(feature_name, ignore_dismissal_earlier_than = nil) diff --git a/app/helpers/whats_new_helper.rb b/app/helpers/whats_new_helper.rb index f0044daa645..edb3544d2d4 100644 --- a/app/helpers/whats_new_helper.rb +++ b/app/helpers/whats_new_helper.rb @@ -3,6 +3,24 @@ module WhatsNewHelper EMPTY_JSON = ''.to_json + def whats_new_most_recent_release_items_count + items = parsed_most_recent_release_items + + return unless items.is_a?(Array) + + items.count + end + + def whats_new_storage_key + items = parsed_most_recent_release_items + + return unless items.is_a?(Array) + + release = items.first.try(:[], 'release') + + ['display-whats-new-notification', release].compact.join('-') + end + def whats_new_most_recent_release_items YAML.load_file(most_recent_release_file_path).to_json @@ -14,6 +32,10 @@ module WhatsNewHelper private + def parsed_most_recent_release_items + Gitlab::Json.parse(whats_new_most_recent_release_items) + end + def most_recent_release_file_path Dir.glob(files_path).max end |