2018-09-25 23:45:43 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-11-05 05:16:41 -05:00
|
|
|
class Projects::ReleasesController < Projects::ApplicationController
|
|
|
|
# Authorize
|
2019-10-28 17:06:24 -04:00
|
|
|
before_action :require_non_empty_project, except: [:index]
|
2020-03-04 07:07:52 -05:00
|
|
|
before_action :release, only: %i[edit show update downloads]
|
2018-12-13 06:08:53 -05:00
|
|
|
before_action :authorize_read_release!
|
2019-10-15 20:06:16 -04:00
|
|
|
before_action do
|
2020-03-12 11:09:39 -04:00
|
|
|
push_frontend_feature_flag(:release_issue_summary, project, default_enabled: true)
|
2020-01-16 16:08:24 -05:00
|
|
|
push_frontend_feature_flag(:release_evidence_collection, project, default_enabled: true)
|
2020-03-05 22:08:08 -05:00
|
|
|
push_frontend_feature_flag(:release_show_page, project, default_enabled: true)
|
2020-04-01 08:08:00 -04:00
|
|
|
push_frontend_feature_flag(:release_asset_link_editing, project)
|
2019-10-15 20:06:16 -04:00
|
|
|
end
|
2019-10-31 23:06:26 -04:00
|
|
|
before_action :authorize_update_release!, only: %i[edit update]
|
2018-12-10 07:03:00 -05:00
|
|
|
|
|
|
|
def index
|
2019-10-28 17:06:24 -04:00
|
|
|
respond_to do |format|
|
|
|
|
format.html do
|
|
|
|
require_non_empty_project
|
|
|
|
end
|
|
|
|
format.json { render json: releases }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-01-29 13:08:47 -05:00
|
|
|
def show
|
2020-03-05 22:08:08 -05:00
|
|
|
return render_404 unless Feature.enabled?(:release_show_page, project, default_enabled: true)
|
2020-01-29 13:08:47 -05:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html do
|
|
|
|
render :show
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-03-04 07:07:52 -05:00
|
|
|
def downloads
|
|
|
|
redirect_to link.url
|
|
|
|
end
|
|
|
|
|
2019-10-28 17:06:24 -04:00
|
|
|
protected
|
|
|
|
|
|
|
|
def releases
|
|
|
|
ReleasesFinder.new(@project, current_user).execute
|
2018-12-10 07:03:00 -05:00
|
|
|
end
|
2019-10-31 23:06:26 -04:00
|
|
|
|
|
|
|
def edit
|
|
|
|
respond_to do |format|
|
2020-01-29 13:08:47 -05:00
|
|
|
format.html do
|
|
|
|
render :edit
|
|
|
|
end
|
2019-10-31 23:06:26 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def authorize_update_release!
|
|
|
|
access_denied! unless can?(current_user, :update_release, release)
|
|
|
|
end
|
|
|
|
|
|
|
|
def release
|
|
|
|
@release ||= project.releases.find_by_tag!(sanitized_tag_name)
|
|
|
|
end
|
|
|
|
|
2020-03-04 07:07:52 -05:00
|
|
|
def link
|
|
|
|
release.links.find_by_filepath!(sanitized_filepath)
|
|
|
|
end
|
|
|
|
|
|
|
|
def sanitized_filepath
|
|
|
|
CGI.unescape(params[:filepath])
|
|
|
|
end
|
|
|
|
|
2019-10-31 23:06:26 -04:00
|
|
|
def sanitized_tag_name
|
|
|
|
CGI.unescape(params[:tag])
|
|
|
|
end
|
2015-11-05 05:16:41 -05:00
|
|
|
end
|