Welcome to mirror list, hosted at ThFree Co, Russian Federation.

base_service.rb « timeline_events « incident_management « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cae58465e4a78e4496e1f0baa914555fd07e9a72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

module IncidentManagement
  module TimelineEvents
    class BaseService
      def allowed?
        user&.can?(:admin_incident_management_timeline_event, incident)
      end

      def success(timeline_event)
        ServiceResponse.success(payload: { timeline_event: timeline_event })
      end

      def error(message)
        ServiceResponse.error(message: message)
      end

      def error_no_permissions
        error(_('You have insufficient permissions to manage timeline events for this incident'))
      end

      def error_in_save(timeline_event)
        error(timeline_event.errors.full_messages.to_sentence)
      end
    end
  end
end