Commit 3ea8d5df authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'sy-system-note-follow-up' into 'master'

Pull duplicate EE::SystemNoteService calls into helpers

See merge request gitlab-org/gitlab!31041
parents f6bf831e 886c2093
......@@ -17,11 +17,11 @@ module EE
end
def relate_issue(noteable, noteable_ref, user)
::SystemNotes::IssuablesService.new(noteable: noteable, project: noteable.project, author: user).relate_issue(noteable_ref)
issuables_service(noteable, noteable.project, user).relate_issue(noteable_ref)
end
def unrelate_issue(noteable, noteable_ref, user)
::SystemNotes::IssuablesService.new(noteable: noteable, project: noteable.project, author: user).unrelate_issue(noteable_ref)
issuables_service(noteable, noteable.project, user).unrelate_issue(noteable_ref)
end
# Parameters:
......@@ -34,9 +34,9 @@ module EE
#
# Returns [Array<Note>]: the created Note objects
def design_version_added(version)
EE::SystemNotes::DesignManagementService.new(noteable: version.issue,
project: version.issue.project,
author: version.author).design_version_added(version)
design_management_service(version.issue,
version.issue.project,
version.author).design_version_added(version)
end
# Called when a new discussion is created on a design
......@@ -50,29 +50,29 @@ module EE
# Returns the created Note object
def design_discussion_added(discussion_note)
design = discussion_note.noteable
EE::SystemNotes::DesignManagementService.new(noteable: design.issue,
project: design.project,
author: discussion_note.author).design_discussion_added(discussion_note)
design_management_service(design.issue,
design.project,
discussion_note.author).design_discussion_added(discussion_note)
end
def epic_issue(epic, issue, user, type)
EE::SystemNotes::EpicsService.new(noteable: epic, author: user).epic_issue(issue, type)
epics_service(epic, user).epic_issue(issue, type)
end
def epic_issue_moved(from_epic, issue, to_epic, user)
EE::SystemNotes::EpicsService.new(noteable: from_epic, author: user).epic_issue_moved(issue, to_epic)
epics_service(from_epic, user).epic_issue_moved(issue, to_epic)
end
def issue_promoted(noteable, noteable_ref, author, direction:)
EE::SystemNotes::EpicsService.new(noteable: noteable, author: author).issue_promoted(noteable_ref, direction: direction)
epics_service(noteable, author).issue_promoted(noteable_ref, direction: direction)
end
def issue_on_epic(issue, epic, user, type)
EE::SystemNotes::EpicsService.new(noteable: epic, author: user).issue_on_epic(issue, type)
epics_service(epic, user).issue_on_epic(issue, type)
end
def issue_epic_change(issue, epic, user)
EE::SystemNotes::EpicsService.new(noteable: epic, author: user).issue_epic_change(issue)
epics_service(epic, user).issue_epic_change(issue)
end
# Called when the merge request is approved by user
......@@ -86,11 +86,11 @@ module EE
#
# Returns the created Note object
def approve_mr(noteable, user)
::SystemNotes::MergeRequestsService.new(noteable: noteable, project: noteable.project, author: user).approve_mr
merge_requests_service(noteable, noteable.project, user).approve_mr
end
def unapprove_mr(noteable, user)
::SystemNotes::MergeRequestsService.new(noteable: noteable, project: noteable.project, author: user).unapprove_mr
merge_requests_service(noteable, noteable.project, user).unapprove_mr
end
# Called when the weight of a Noteable is changed
......@@ -107,7 +107,7 @@ module EE
#
# Returns the created Note object
def change_weight_note(noteable, project, author)
::SystemNotes::IssuablesService.new(noteable: noteable, project: project, author: author).change_weight_note
issuables_service(noteable, project, author).change_weight_note
end
# Called when the health_stauts of an Issue is changed
......@@ -123,7 +123,7 @@ module EE
#
# Returns the created Note object
def change_health_status_note(noteable, project, author)
::SystemNotes::IssuablesService.new(noteable: noteable, project: project, author: author).change_health_status_note
issuables_service(noteable, project, author).change_health_status_note
end
# Called when the start or end date of an Issuable is changed
......@@ -139,50 +139,77 @@ module EE
#
# Returns the created Note object
def change_epic_date_note(noteable, author, date_type, date)
EE::SystemNotes::EpicsService.new(noteable: noteable, author: author).change_epic_date_note(date_type, date)
epics_service(noteable, author).change_epic_date_note(date_type, date)
end
def change_epics_relation(epic, child_epic, user, type)
EE::SystemNotes::EpicsService.new(noteable: epic, author: user).change_epics_relation(child_epic, type)
epics_service(epic, user).change_epics_relation(child_epic, type)
end
# Called when 'merge train' is executed
def merge_train(noteable, project, author, merge_train)
EE::SystemNotes::MergeTrainService.new(noteable: noteable, project: project, author: author).enqueue(merge_train)
merge_trains_service(noteable, project, author).enqueue(merge_train)
end
# Called when 'merge train' is canceled
def cancel_merge_train(noteable, project, author)
EE::SystemNotes::MergeTrainService.new(noteable: noteable, project: project, author: author).cancel
merge_trains_service(noteable, project, author).cancel
end
# Called when 'merge train' is aborted
def abort_merge_train(noteable, project, author, reason)
EE::SystemNotes::MergeTrainService.new(noteable: noteable, project: project, author: author).abort(reason)
merge_trains_service(noteable, project, author).abort(reason)
end
# Called when 'add to merge train when pipeline succeeds' is executed
def add_to_merge_train_when_pipeline_succeeds(noteable, project, author, sha)
EE::SystemNotes::MergeTrainService.new(noteable: noteable, project: project, author: author).add_when_pipeline_succeeds(sha)
merge_trains_service(noteable, project, author).add_when_pipeline_succeeds(sha)
end
# Called when 'add to merge train when pipeline succeeds' is canceled
def cancel_add_to_merge_train_when_pipeline_succeeds(noteable, project, author)
EE::SystemNotes::MergeTrainService.new(noteable: noteable, project: project, author: author).cancel_add_when_pipeline_succeeds
merge_trains_service(noteable, project, author).cancel_add_when_pipeline_succeeds
end
# Called when 'add to merge train when pipeline succeeds' is aborted
def abort_add_to_merge_train_when_pipeline_succeeds(noteable, project, author, reason)
EE::SystemNotes::MergeTrainService.new(noteable: noteable, project: project, author: author).abort_add_when_pipeline_succeeds(reason)
merge_trains_service(noteable, project, author).abort_add_when_pipeline_succeeds(reason)
end
# Called when state is changed for 'vulnerability'
def change_vulnerability_state(noteable, author)
EE::SystemNotes::VulnerabilitiesService.new(noteable: noteable, project: noteable.project, author: author).change_vulnerability_state
vulnerabilities_service(noteable, noteable.project, author).change_vulnerability_state
end
# Called when quick action to publish an issue to status page is called
def publish_issue_to_status_page(noteable, project, author)
::SystemNotes::IssuablesService.new(noteable: noteable, project: project, author: author).publish_issue_to_status_page
issuables_service(noteable, project, author).publish_issue_to_status_page
end
private
def issuables_service(noteable, project, author)
::SystemNotes::IssuablesService.new(noteable: noteable, project: project, author: author)
end
def design_management_service(noteable, project, author)
EE::SystemNotes::DesignManagementService.new(noteable: noteable, project: project, author: author)
end
def epics_service(noteable, author)
EE::SystemNotes::EpicsService.new(noteable: noteable, author: author)
end
def merge_requests_service(noteable, project, author)
::SystemNotes::MergeRequestsService.new(noteable: noteable, project: project, author: author)
end
def merge_trains_service(noteable, project, author)
EE::SystemNotes::MergeTrainService.new(noteable: noteable, project: project, author: author)
end
def vulnerabilities_service(noteable, project, author)
EE::SystemNotes::VulnerabilitiesService.new(noteable: noteable, project: project, author: author)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment