debian-mirror-gitlab/app/services/metrics/dashboard/annotations/delete_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

45 lines
1,005 B
Ruby
Raw Normal View History

2020-04-22 19:07:51 +05:30
# frozen_string_literal: true
# Delete Metrics::Dashboard::Annotation entry
module Metrics
module Dashboard
module Annotations
class DeleteService < ::BaseService
include Stepable
steps :authorize_action,
:delete
def initialize(user, annotation)
2021-04-29 21:17:54 +05:30
@user = user
@annotation = annotation
2020-04-22 19:07:51 +05:30
end
def execute
execute_steps
end
private
attr_reader :user, :annotation
def authorize_action(_options)
2023-05-27 22:25:52 +05:30
if Ability.allowed?(user, :admin_metrics_dashboard_annotation, annotation)
2020-04-22 19:07:51 +05:30
success
else
2021-11-18 22:05:49 +05:30
error(s_('MetricsDashboardAnnotation|You are not authorized to delete this annotation'))
2020-04-22 19:07:51 +05:30
end
end
def delete(_options)
if annotation.destroy
success
else
2021-11-18 22:05:49 +05:30
error(s_('MetricsDashboardAnnotation|Annotation has not been deleted'))
2020-04-22 19:07:51 +05:30
end
end
end
end
end
end