debian-mirror-gitlab/app/presenters/release_presenter.rb

71 lines
1.5 KiB
Ruby
Raw Normal View History

2019-12-26 22:10:19 +05:30
# frozen_string_literal: true
class ReleasePresenter < Gitlab::View::Presenter::Delegated
include ActionView::Helpers::UrlHelper
presents :release
delegate :project, :tag, to: :release
def commit_path
return unless release.commit && can_download_code?
project_commit_path(project, release.commit.id)
end
def tag_path
return unless can_download_code?
project_tag_path(project, release.tag)
end
2020-03-13 15:44:24 +05:30
def self_url
2020-04-08 14:13:33 +05:30
return unless ::Feature.enabled?(:release_show_page, project, default_enabled: true)
2020-03-13 15:44:24 +05:30
project_release_url(project, release)
end
2019-12-26 22:10:19 +05:30
def merge_requests_url
return unless release_mr_issue_urls_available?
project_merge_requests_url(project, params_for_issues_and_mrs)
end
def issues_url
return unless release_mr_issue_urls_available?
project_issues_url(project, params_for_issues_and_mrs)
end
def edit_url
return unless release_edit_page_available?
edit_project_release_url(project, release)
end
2020-01-01 13:55:28 +05:30
def evidence_file_path
2020-04-22 19:07:51 +05:30
evidence = release.evidences.first
return unless evidence
2020-01-01 13:55:28 +05:30
2020-04-22 19:07:51 +05:30
project_evidence_url(project, release, evidence, format: :json)
2020-01-01 13:55:28 +05:30
end
2019-12-26 22:10:19 +05:30
private
def can_download_code?
can?(current_user, :download_code, project)
end
def params_for_issues_and_mrs
{ scope: 'all', state: 'opened', release_tag: release.tag }
end
def release_mr_issue_urls_available?
::Feature.enabled?(:release_mr_issue_urls, project)
end
def release_edit_page_available?
2020-01-01 13:55:28 +05:30
can?(current_user, :update_release, release)
2019-12-26 22:10:19 +05:30
end
end