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