diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-24 19:16:45 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-24 19:16:45 +0300 |
commit | 8022c833207eba848817d54c98ee29d21b69fe8d (patch) | |
tree | eee58397325abbded26d66f81322807eea4d5615 /app | |
parent | 32a578cb598d6568fbd8289e331cf166f94a4e87 (diff) |
Add latest changes from gitlab-org/gitlab@12-7-stable-ee
Diffstat (limited to 'app')
-rw-r--r-- | app/policies/project_policy.rb | 1 | ||||
-rw-r--r-- | app/services/error_tracking/base_service.rb | 8 | ||||
-rw-r--r-- | app/services/error_tracking/issue_details_service.rb | 2 | ||||
-rw-r--r-- | app/services/error_tracking/issue_latest_event_service.rb | 2 | ||||
-rw-r--r-- | app/services/error_tracking/issue_update_service.rb | 58 | ||||
-rw-r--r-- | app/services/error_tracking/list_issues_service.rb | 2 | ||||
-rw-r--r-- | app/services/error_tracking/list_projects_service.rb | 2 | ||||
-rw-r--r-- | app/services/system_note_service.rb | 6 |
8 files changed, 7 insertions, 74 deletions
diff --git a/app/policies/project_policy.rb b/app/policies/project_policy.rb index 2789152e175..e38eef527be 100644 --- a/app/policies/project_policy.rb +++ b/app/policies/project_policy.rb @@ -222,7 +222,6 @@ class ProjectPolicy < BasePolicy enable :read_deployment enable :read_merge_request enable :read_sentry_issue - enable :update_sentry_issue enable :read_prometheus end diff --git a/app/services/error_tracking/base_service.rb b/app/services/error_tracking/base_service.rb index 4fe01716704..430d9952332 100644 --- a/app/services/error_tracking/base_service.rb +++ b/app/services/error_tracking/base_service.rb @@ -7,7 +7,7 @@ module ErrorTracking return unauthorized if unauthorized begin - response = perform + response = fetch rescue Sentry::Client::Error => e return error(e.message, :bad_request) rescue Sentry::Client::MissingKeysError => e @@ -22,7 +22,7 @@ module ErrorTracking private - def perform + def fetch raise NotImplementedError, "#{self.class} does not implement #{__method__}" end @@ -62,9 +62,5 @@ module ErrorTracking def can_read? can?(current_user, :read_sentry_issue, project) end - - def can_update? - can?(current_user, :update_sentry_issue, project) - end end end diff --git a/app/services/error_tracking/issue_details_service.rb b/app/services/error_tracking/issue_details_service.rb index 31fb6a9618c..368cd4517fc 100644 --- a/app/services/error_tracking/issue_details_service.rb +++ b/app/services/error_tracking/issue_details_service.rb @@ -4,7 +4,7 @@ module ErrorTracking class IssueDetailsService < ErrorTracking::BaseService private - def perform + def fetch project_error_tracking_setting.issue_details(issue_id: params[:issue_id]) end diff --git a/app/services/error_tracking/issue_latest_event_service.rb b/app/services/error_tracking/issue_latest_event_service.rb index dd6b7f8285f..b6ad8f8028b 100644 --- a/app/services/error_tracking/issue_latest_event_service.rb +++ b/app/services/error_tracking/issue_latest_event_service.rb @@ -4,7 +4,7 @@ module ErrorTracking class IssueLatestEventService < ErrorTracking::BaseService private - def perform + def fetch project_error_tracking_setting.issue_latest_event(issue_id: params[:issue_id]) end diff --git a/app/services/error_tracking/issue_update_service.rb b/app/services/error_tracking/issue_update_service.rb index db754d54fef..e433b4a11f2 100644 --- a/app/services/error_tracking/issue_update_service.rb +++ b/app/services/error_tracking/issue_update_service.rb @@ -4,16 +4,6 @@ module ErrorTracking class IssueUpdateService < ErrorTracking::BaseService private - def perform - response = fetch - - unless parse_errors(response).present? - response[:closed_issue_iid] = update_related_issue&.iid - end - - response - end - def fetch project_error_tracking_setting.update_issue( issue_id: params[:issue_id], @@ -21,58 +11,12 @@ module ErrorTracking ) end - def update_related_issue - issue = related_issue - return unless issue - - close_and_create_note(issue) - end - - def close_and_create_note(issue) - return unless resolving? && issue.opened? - - processed_issue = close_issue(issue) - return unless processed_issue.reset.closed? - - create_system_note(processed_issue) - processed_issue - end - - def close_issue(issue) - Issues::CloseService - .new(project, current_user) - .execute(issue, system_note: false) - end - - def create_system_note(issue) - SystemNoteService.close_after_error_tracking_resolve(issue, project, current_user) - end - - def related_issue - SentryIssueFinder - .new(project, current_user: current_user) - .execute(params[:issue_id]) - &.issue - end - - def resolving? - update_params[:status] == 'resolved' - end - def update_params params.except(:issue_id) end def parse_response(response) - { - updated: response[:updated].present?, - closed_issue_iid: response[:closed_issue_iid] - } - end - - def check_permissions - return error('Error Tracking is not enabled') unless enabled? - return error('Access denied', :unauthorized) unless can_update? + { updated: response[:updated].present? } end end end diff --git a/app/services/error_tracking/list_issues_service.rb b/app/services/error_tracking/list_issues_service.rb index d34ea8aa3b0..132e9dfa7bd 100644 --- a/app/services/error_tracking/list_issues_service.rb +++ b/app/services/error_tracking/list_issues_service.rb @@ -12,7 +12,7 @@ module ErrorTracking private - def perform + def fetch project_error_tracking_setting.list_sentry_issues( issue_status: issue_status, limit: limit, diff --git a/app/services/error_tracking/list_projects_service.rb b/app/services/error_tracking/list_projects_service.rb index 6523a66bbed..09a0b952e84 100644 --- a/app/services/error_tracking/list_projects_service.rb +++ b/app/services/error_tracking/list_projects_service.rb @@ -12,7 +12,7 @@ module ErrorTracking private - def perform + def fetch project_error_tracking_setting.list_sentry_projects end diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb index 033c80fd8ed..38e0a7d34ad 100644 --- a/app/services/system_note_service.rb +++ b/app/services/system_note_service.rb @@ -99,12 +99,6 @@ module SystemNoteService ::SystemNotes::TimeTrackingService.new(noteable: noteable, project: project, author: author).change_time_spent end - def close_after_error_tracking_resolve(issue, project, author) - body = _('resolved the corresponding error and closed the issue.') - - create_note(NoteSummary.new(issue, project, author, body, action: 'closed')) - end - def change_status(noteable, project, author, status, source = nil) ::SystemNotes::IssuablesService.new(noteable: noteable, project: project, author: author).change_status(status, source) end |