debian-mirror-gitlab/app/helpers/releases_helper.rb

60 lines
1.8 KiB
Ruby
Raw Normal View History

2019-12-04 20:38:33 +05:30
# frozen_string_literal: true
module ReleasesHelper
IMAGE_PATH = 'illustrations/releases.svg'
DOCUMENTATION_PATH = 'user/project/releases/index'
def illustration
image_path(IMAGE_PATH)
end
2020-04-22 19:07:51 +05:30
def help_page(anchor: nil)
help_page_path(DOCUMENTATION_PATH, anchor: anchor)
2019-12-04 20:38:33 +05:30
end
def data_for_releases_page
{
project_id: @project.id,
2020-11-24 15:15:51 +05:30
project_path: @project.full_path,
2019-12-04 20:38:33 +05:30
illustration_path: illustration,
2019-12-21 20:55:43 +05:30
documentation_path: help_page
2020-04-08 14:13:33 +05:30
}.tap do |data|
2020-07-28 23:09:34 +05:30
if can?(current_user, :create_release, @project)
2020-10-24 23:57:45 +05:30
data[:new_release_path] = if Feature.enabled?(:new_release_page, @project, default_enabled: true)
2020-07-28 23:09:34 +05:30
new_project_release_path(@project)
else
new_project_tag_path(@project)
end
end
2020-04-08 14:13:33 +05:30
end
2019-12-04 20:38:33 +05:30
end
2019-12-21 20:55:43 +05:30
def data_for_edit_release_page
2020-07-28 23:09:34 +05:30
new_edit_pages_shared_data.merge(
tag_name: @release.tag,
releases_page_path: project_releases_path(@project, anchor: @release.tag)
)
end
def data_for_new_release_page
new_edit_pages_shared_data.merge(
2020-10-24 23:57:45 +05:30
default_branch: @project.default_branch,
releases_page_path: project_releases_path(@project)
2020-07-28 23:09:34 +05:30
)
end
private
def new_edit_pages_shared_data
2019-12-21 20:55:43 +05:30
{
project_id: @project.id,
markdown_preview_path: preview_markdown_path(@project),
markdown_docs_path: help_page_path('user/markdown'),
2020-04-22 19:07:51 +05:30
update_release_api_docs_path: help_page_path('api/releases/index.md', anchor: 'update-a-release'),
2020-05-24 23:13:21 +05:30
release_assets_docs_path: help_page(anchor: 'release-assets'),
manage_milestones_path: project_milestones_path(@project),
2020-07-28 23:09:34 +05:30
new_milestone_path: new_project_milestone_path(@project)
2019-12-21 20:55:43 +05:30
}
2019-12-04 20:38:33 +05:30
end
end