summaryrefslogtreecommitdiff
path: root/app/controllers/projects/incidents_controller.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-10-01 15:10:05 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-10-01 15:10:05 +0000
commitd57e27ef353787dac501d6970c546c9d86dd1f88 (patch)
tree89044194e81f95aaa15ace8a5d6a5b429179965f /app/controllers/projects/incidents_controller.rb
parenta27b8a5c104f492e4b0abac4c84385a615c4f6ba (diff)
downloadgitlab-ce-d57e27ef353787dac501d6970c546c9d86dd1f88.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/controllers/projects/incidents_controller.rb')
-rw-r--r--app/controllers/projects/incidents_controller.rb44
1 files changed, 44 insertions, 0 deletions
diff --git a/app/controllers/projects/incidents_controller.rb b/app/controllers/projects/incidents_controller.rb
index c0760f01db2..1c915842e61 100644
--- a/app/controllers/projects/incidents_controller.rb
+++ b/app/controllers/projects/incidents_controller.rb
@@ -1,8 +1,52 @@
# frozen_string_literal: true
class Projects::IncidentsController < Projects::ApplicationController
+ include IssuableActions
+ include Gitlab::Utils::StrongMemoize
+
before_action :authorize_read_issue!
+ before_action :check_feature_flag, only: [:show]
+ before_action :load_incident, only: [:show]
+
+ before_action do
+ push_frontend_feature_flag(:issues_incident_details, @project)
+ end
def index
end
+
+ 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
+
+ def check_feature_flag
+ render_404 unless Feature.enabled?(:issues_incident_details, @project)
+ end
end