diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /app/presenters | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'app/presenters')
-rw-r--r-- | app/presenters/alert_management/alert_presenter.rb | 3 | ||||
-rw-r--r-- | app/presenters/analytics/cycle_analytics/stage_presenter.rb | 58 | ||||
-rw-r--r-- | app/presenters/ci/pipeline_presenter.rb | 3 | ||||
-rw-r--r-- | app/presenters/gitlab/whats_new/item_presenter.rb | 22 | ||||
-rw-r--r-- | app/presenters/packages/composer/packages_presenter.rb | 2 | ||||
-rw-r--r-- | app/presenters/project_presenter.rb | 23 | ||||
-rw-r--r-- | app/presenters/projects/import_export/project_export_presenter.rb | 4 | ||||
-rw-r--r-- | app/presenters/search_service_presenter.rb | 43 |
8 files changed, 141 insertions, 17 deletions
diff --git a/app/presenters/alert_management/alert_presenter.rb b/app/presenters/alert_management/alert_presenter.rb index 4bfa3dc9a13..1cebf5c561a 100644 --- a/app/presenters/alert_management/alert_presenter.rb +++ b/app/presenters/alert_management/alert_presenter.rb @@ -8,7 +8,6 @@ module AlertManagement MARKDOWN_LINE_BREAK = " \n" HORIZONTAL_LINE = "\n\n---\n\n" - INCIDENT_LABEL_NAME = ::IncidentManagement::CreateIncidentLabelService::LABEL_PROPERTIES[:title] delegate :metrics_dashboard_url, :runbook, to: :parsed_payload @@ -48,7 +47,7 @@ module AlertManagement end def incident_issues_link - project_issues_url(project, label_name: INCIDENT_LABEL_NAME) + project_incidents_url(project) end def performance_dashboard_link diff --git a/app/presenters/analytics/cycle_analytics/stage_presenter.rb b/app/presenters/analytics/cycle_analytics/stage_presenter.rb new file mode 100644 index 00000000000..7b295b814bc --- /dev/null +++ b/app/presenters/analytics/cycle_analytics/stage_presenter.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +module Analytics + module CycleAnalytics + class StagePresenter < Gitlab::View::Presenter::Delegated + def title + extract_default_stage_attribute(:title) || name + end + + def description + extract_default_stage_attribute(:description) || '' + end + + def legend + '' + end + + private + + def extract_default_stage_attribute(attribute) + default_stage_attributes.dig(name.to_sym, attribute.to_sym) + end + + def default_stage_attributes + @default_stage_attributes ||= { + issue: { + title: s_('CycleAnalyticsStage|Issue'), + description: _('Time before an issue gets scheduled') + }, + plan: { + title: s_('CycleAnalyticsStage|Plan'), + description: _('Time before an issue starts implementation') + }, + code: { + title: s_('CycleAnalyticsStage|Code'), + description: _('Time until first merge request') + }, + test: { + title: s_('CycleAnalyticsStage|Test'), + description: _('Total test time for all commits/merges') + }, + review: { + title: s_('CycleAnalyticsStage|Review'), + description: _('Time between merge request creation and merge/close') + }, + staging: { + title: s_('CycleAnalyticsStage|Staging'), + description: _('From merge request merge until deploy to production') + }, + production: { + title: s_('CycleAnalyticsStage|Total'), + description: _('From issue creation until deploy to production') + } + }.freeze + end + end + end +end diff --git a/app/presenters/ci/pipeline_presenter.rb b/app/presenters/ci/pipeline_presenter.rb index da610f13899..f3bb63b31c3 100644 --- a/app/presenters/ci/pipeline_presenter.rb +++ b/app/presenters/ci/pipeline_presenter.rb @@ -10,7 +10,8 @@ module Ci def self.failure_reasons { unknown_failure: 'Unknown pipeline failure!', config_error: 'CI/CD YAML configuration error!', - external_validation_failure: 'External pipeline validation failed!' } + external_validation_failure: 'External pipeline validation failed!', + deployments_limit_exceeded: 'Pipeline deployments limit exceeded!' } end presents :pipeline diff --git a/app/presenters/gitlab/whats_new/item_presenter.rb b/app/presenters/gitlab/whats_new/item_presenter.rb new file mode 100644 index 00000000000..9f66e19ade0 --- /dev/null +++ b/app/presenters/gitlab/whats_new/item_presenter.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Gitlab + module WhatsNew + class ItemPresenter + DICTIONARY = { + core: 'Free', + starter: 'Bronze', + premium: 'Silver', + ultimate: 'Gold' + }.freeze + + def self.present(item) + if Gitlab.com? + item['packages'] = item['packages'].map { |p| DICTIONARY[p.downcase.to_sym] } + end + + item + end + end + end +end diff --git a/app/presenters/packages/composer/packages_presenter.rb b/app/presenters/packages/composer/packages_presenter.rb index 84f266989e9..cce006cbb1a 100644 --- a/app/presenters/packages/composer/packages_presenter.rb +++ b/app/presenters/packages/composer/packages_presenter.rb @@ -11,7 +11,7 @@ module Packages end def root - path = api_v4_group___packages_composer_package_name_path({ id: @group.id, package_name: '%package%', format: '.json' }, true) + path = api_v4_group___packages_composer_package_name_path({ id: @group.id, package_name: '%package%$%hash%', format: '.json' }, true) { 'packages' => [], 'provider-includes' => { 'p/%hash%.json' => { 'sha256' => provider_sha } }, 'providers-url' => path } end diff --git a/app/presenters/project_presenter.rb b/app/presenters/project_presenter.rb index 0f5b601f2b0..55b550d8544 100644 --- a/app/presenters/project_presenter.rb +++ b/app/presenters/project_presenter.rb @@ -77,19 +77,19 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated end def readme_path - filename_path(:readme) + filename_path(repository.readme_path) end def changelog_path - filename_path(:changelog) + filename_path(repository.changelog&.name) end def license_path - filename_path(:license_blob) + filename_path(repository.license_blob&.name) end def ci_configuration_path - filename_path(:gitlab_ci_yml) + filename_path(repository.gitlab_ci_yml&.name) end def contribution_guide_path @@ -244,11 +244,11 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated end def readme_anchor_data - if current_user && can_current_user_push_to_default_branch? && repository.readme.nil? + if current_user && can_current_user_push_to_default_branch? && readme_path.nil? AnchorData.new(false, statistic_icon + _('Add README'), empty_repo? ? add_readme_ide_path : add_readme_path) - elsif repository.readme + elsif readme_path AnchorData.new(false, statistic_icon('doc-text') + _('README'), default_view != 'readme' ? readme_path : '#readme', @@ -397,13 +397,10 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated current_user && can?(current_user, :create_cluster, project) end - def filename_path(filename) - if blob = repository.public_send(filename) # rubocop:disable GitlabSecurity/PublicSend - project_blob_path( - project, - tree_join(default_branch, blob.name) - ) - end + def filename_path(filepath) + return if filepath.blank? + + project_blob_path(project, tree_join(default_branch, filepath)) end def anonymous_project_view diff --git a/app/presenters/projects/import_export/project_export_presenter.rb b/app/presenters/projects/import_export/project_export_presenter.rb index 8f3fc53af10..b52f3411c49 100644 --- a/app/presenters/projects/import_export/project_export_presenter.rb +++ b/app/presenters/projects/import_export/project_export_presenter.rb @@ -15,6 +15,10 @@ module Projects self.respond_to?(:override_description) ? override_description : super end + def protected_branches + project.exported_protected_branches + end + private def converted_group_members diff --git a/app/presenters/search_service_presenter.rb b/app/presenters/search_service_presenter.rb new file mode 100644 index 00000000000..19a90d002aa --- /dev/null +++ b/app/presenters/search_service_presenter.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +class SearchServicePresenter < Gitlab::View::Presenter::Delegated + include RendersCommits + + presents :search_service + + SCOPE_PRELOAD_METHOD = { + projects: :with_web_entity_associations, + issues: :with_web_entity_associations, + merge_requests: :with_web_entity_associations, + epics: :with_web_entity_associations + }.freeze + + SORT_ENABLED_SCOPES = %w(issues merge_requests).freeze + + def search_objects + @search_objects ||= begin + objects = search_service.search_objects(SCOPE_PRELOAD_METHOD[scope.to_sym]) + + case scope + when 'users' + objects.eager_load(:status) # rubocop:disable CodeReuse/ActiveRecord + when 'commits' + prepare_commits_for_rendering(objects) + else + objects + end + end + end + + def show_sort_dropdown? + SORT_ENABLED_SCOPES.include?(scope) + end + + def show_results_status? + !without_count? || show_snippets? || show_sort_dropdown? + end + + def without_count? + search_objects.is_a?(Kaminari::PaginatableWithoutCount) + end +end |