summaryrefslogtreecommitdiff
path: root/app/serializers
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-04 21:08:55 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-04 21:08:55 +0000
commit51612d3ef5be853289008694c40973b479e8547c (patch)
tree0a74213e94c9b6d81f6f0cb01e0b5dbff26f5444 /app/serializers
parentca05512007cea51e05d3431b2c8bd7228c754370 (diff)
downloadgitlab-ce-51612d3ef5be853289008694c40973b479e8547c.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/serializers')
-rw-r--r--app/serializers/merge_request_widget_entity.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/app/serializers/merge_request_widget_entity.rb b/app/serializers/merge_request_widget_entity.rb
index adc4d08a6f6..7d67a35c94c 100644
--- a/app/serializers/merge_request_widget_entity.rb
+++ b/app/serializers/merge_request_widget_entity.rb
@@ -50,6 +50,19 @@ class MergeRequestWidgetEntity < Grape::Entity
ci_environments_status_project_merge_request_path(merge_request.project, merge_request)
end
+ expose :merge_request_add_ci_config_path, if: ->(mr, _) { can_add_ci_config_path?(mr) } do |merge_request|
+ project_new_blob_path(
+ merge_request.source_project,
+ merge_request.source_branch,
+ file_name: '.gitlab-ci.yml',
+ commit_message: s_("CommitMessage|Add %{file_name}") % { file_name: Gitlab::FileDetector::PATTERNS[:gitlab_ci] }
+ )
+ end
+
+ expose :human_access do |merge_request|
+ merge_request.project.team.human_max_access(current_user&.id)
+ end
+
# Rendering and redacting Markdown can be expensive. These links are
# just nice to have in the merge request widget, so only
# include them if they are explicitly requested on first load.
@@ -75,6 +88,13 @@ class MergeRequestWidgetEntity < Grape::Entity
@presenters ||= {}
@presenters[merge_request] ||= MergeRequestPresenter.new(merge_request, current_user: current_user) # rubocop: disable CodeReuse/Presenter
end
+
+ def can_add_ci_config_path?(merge_request)
+ merge_request.source_project&.uses_default_ci_config? &&
+ merge_request.all_pipelines.none? &&
+ merge_request.commits_count.positive? &&
+ can?(current_user, :push_code, merge_request.source_project)
+ end
end
MergeRequestWidgetEntity.prepend_if_ee('EE::MergeRequestWidgetEntity')