2020-07-23 05:09:18 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Projects::IncidentsController < Projects::ApplicationController
|
2020-10-01 11:10:05 -04:00
|
|
|
include IssuableActions
|
|
|
|
include Gitlab::Utils::StrongMemoize
|
|
|
|
|
2020-09-30 17:10:09 -04:00
|
|
|
before_action :authorize_read_issue!
|
2020-10-01 11:10:05 -04:00
|
|
|
before_action :load_incident, only: [:show]
|
|
|
|
|
2020-10-08 14:08:32 -04:00
|
|
|
feature_category :incident_management
|
|
|
|
|
2020-07-23 05:09:18 -04:00
|
|
|
def index
|
|
|
|
end
|
2020-10-01 11:10:05 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def incident
|
|
|
|
strong_memoize(:incident) do
|
|
|
|
incident_finder
|
|
|
|
.execute
|
|
|
|
.inc_relations_for_view
|
|
|
|
.iid_in(params[:id])
|
|
|
|
.without_order
|
|
|
|
.first
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def load_incident
|
|
|
|
@issue = incident # needed by rendered view
|
|
|
|
return render_404 unless can?(current_user, :read_issue, incident)
|
|
|
|
|
|
|
|
@noteable = incident
|
|
|
|
@note = incident.project.notes.new(noteable: issuable)
|
|
|
|
end
|
|
|
|
|
|
|
|
alias_method :issuable, :incident
|
|
|
|
|
|
|
|
def incident_finder
|
|
|
|
IssuesFinder.new(current_user, project_id: @project.id, issue_types: :incident)
|
|
|
|
end
|
|
|
|
|
|
|
|
def serializer
|
|
|
|
IssueSerializer.new(current_user: current_user, project: incident.project)
|
|
|
|
end
|
2020-07-23 05:09:18 -04:00
|
|
|
end
|