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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

93 lines
2.6 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'
2021-09-30 23:02:18 +05:30
# This needs to be kept in sync with the constant in
# app/assets/javascripts/releases/constants.js
DEFAULT_SORT = 'RELEASED_AT_DESC'
2019-12-04 20:38:33 +05:30
def illustration
image_path(IMAGE_PATH)
end
2022-07-16 23:28:13 +05:30
def releases_help_page_path(anchor: nil)
2020-04-22 19:07:51 +05:30
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,
2022-07-16 23:28:13 +05:30
documentation_path: releases_help_page_path
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)
2021-09-30 23:02:18 +05:30
data[:new_release_path] = new_project_release_path(@project)
2020-07-28 23:09:34 +05:30
end
2020-04-08 14:13:33 +05:30
end
2019-12-04 20:38:33 +05:30
end
2021-09-30 23:02:18 +05:30
# For simplicity, only optimize non-paginated requests
def use_startup_query_for_index_page?
params[:before].nil? && params[:after].nil?
end
def index_page_startup_query_variables
{
fullPath: @project.full_path,
sort: DEFAULT_SORT,
first: 1
}
end
2021-01-03 14:25:43 +05:30
def data_for_show_page
{
project_id: @project.id,
project_path: @project.full_path,
tag_name: @release.tag
}
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,
2022-08-13 15:12:31 +05:30
releases_page_path: project_releases_path(@project, anchor: @release.tag),
delete_release_docs_path: releases_help_page_path(anchor: 'delete-a-release')
2020-07-28 23:09:34 +05:30
)
end
def data_for_new_release_page
new_edit_pages_shared_data.merge(
2022-08-13 15:12:31 +05:30
tag_name: params[:tag_name],
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
2021-01-29 00:20:46 +05:30
def group_milestone_project_releases_available?(project)
false
end
2020-07-28 23:09:34 +05:30
private
def new_edit_pages_shared_data
2019-12-21 20:55:43 +05:30
{
project_id: @project.id,
2021-01-29 00:20:46 +05:30
group_id: @project.group&.id,
group_milestones_available: group_milestone_project_releases_available?(@project),
2021-01-03 14:25:43 +05:30
project_path: @project.full_path,
2019-12-21 20:55:43 +05:30
markdown_preview_path: preview_markdown_path(@project),
markdown_docs_path: help_page_path('user/markdown'),
2022-07-16 23:28:13 +05:30
release_assets_docs_path: releases_help_page_path(anchor: 'release-assets'),
2020-05-24 23:13:21 +05:30
manage_milestones_path: project_milestones_path(@project),
2022-11-25 23:54:43 +05:30
new_milestone_path: new_project_milestone_path(@project, redirect_path: 'new_release'),
2022-08-13 15:12:31 +05:30
edit_release_docs_path: releases_help_page_path(anchor: 'edit-a-release'),
upcoming_release_docs_path: releases_help_page_path(anchor: 'upcoming-releases')
2019-12-21 20:55:43 +05:30
}
2019-12-04 20:38:33 +05:30
end
end
2021-01-29 00:20:46 +05:30
2021-06-08 01:23:25 +05:30
ReleasesHelper.prepend_mod_with('ReleasesHelper')