diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
commit | 48aff82709769b098321c738f3444b9bdaa694c6 (patch) | |
tree | e00c7c43e2d9b603a5a6af576b1685e400410dee /app/services/alert_management/alerts/update_service.rb | |
parent | 879f5329ee916a948223f8f43d77fba4da6cd028 (diff) |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'app/services/alert_management/alerts/update_service.rb')
-rw-r--r-- | app/services/alert_management/alerts/update_service.rb | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/app/services/alert_management/alerts/update_service.rb b/app/services/alert_management/alerts/update_service.rb index 18d615aa7e7..464d5f2ecea 100644 --- a/app/services/alert_management/alerts/update_service.rb +++ b/app/services/alert_management/alerts/update_service.rb @@ -13,6 +13,7 @@ module AlertManagement @current_user = current_user @params = params @param_errors = [] + @status = params.delete(:status) end def execute @@ -35,7 +36,7 @@ module AlertManagement private - attr_reader :alert, :current_user, :params, :param_errors + attr_reader :alert, :current_user, :params, :param_errors, :status delegate :resolved?, to: :alert def allowed? @@ -68,8 +69,12 @@ module AlertManagement param_errors << message end + def param_errors? + params.empty? && status.blank? + end + def filter_params - param_errors << _('Please provide attributes to update') if params.empty? + param_errors << _('Please provide attributes to update') if param_errors? filter_status filter_assignees @@ -110,9 +115,9 @@ module AlertManagement # ------ Status-related behavior ------- def filter_status - return unless params[:status] + return unless status - status_event = AlertManagement::Alert::STATUS_EVENTS[status_key] + status_event = alert.status_event_for(status) unless status_event param_errors << _('Invalid status') @@ -122,13 +127,6 @@ module AlertManagement params[:status_event] = status_event end - def status_key - strong_memoize(:status_key) do - status = params.delete(:status) - AlertManagement::Alert::STATUSES.key(status) - end - end - def handle_status_change add_status_change_system_note resolve_todos if resolved? @@ -144,7 +142,7 @@ module AlertManagement def filter_duplicate # Only need to check if changing to an open status - return unless params[:status_event] && AlertManagement::Alert::OPEN_STATUSES.include?(status_key) + return unless params[:status_event] && AlertManagement::Alert.open_status?(status) param_errors << unresolved_alert_error if duplicate_alert? end |