releases_helper.rb 1.05 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
# frozen_string_literal: true

module ReleasesHelper
  IMAGE_PATH = 'illustrations/releases.svg'
  DOCUMENTATION_PATH = 'user/project/releases/index'

  def illustration
    image_path(IMAGE_PATH)
  end

11 12
  def help_page(anchor: nil)
    help_page_path(DOCUMENTATION_PATH, anchor: anchor)
13 14 15 16 17 18
  end

  def data_for_releases_page
    {
      project_id: @project.id,
      illustration_path: illustration,
19
      documentation_path: help_page
20 21 22
    }.tap do |data|
      data[:new_release_path] = new_project_tag_path(@project) if can?(current_user, :create_release, @project)
    end
23
  end
Nathan Friend's avatar
Nathan Friend committed
24 25 26 27 28 29 30

  def data_for_edit_release_page
    {
      project_id: @project.id,
      tag_name: @release.tag,
      markdown_preview_path: preview_markdown_path(@project),
      markdown_docs_path: help_page_path('user/markdown'),
31
      releases_page_path: project_releases_path(@project, anchor: @release.tag),
32 33
      update_release_api_docs_path: help_page_path('api/releases/index.md', anchor: 'update-a-release'),
      release_assets_docs_path: help_page(anchor: 'release-assets')
Nathan Friend's avatar
Nathan Friend committed
34 35
    }
  end
36
end