Sha256: 44327cb5440b0451cbcce5d9e2b1fd62cb56de20d50cc2266a2e68d0ccb3c5a7

Contents?: true

Size: 915 Bytes

Versions: 53

Compression:

Stored size: 915 Bytes

Contents

# frozen_string_literal: true

module ForemanAnsible
  class ImportPlaybooksErrorNotification < ::UINotifications::Base
    private

    def initialize(error, task)
      @job_error = error
      @subject = task
    end

    def create
      ::Notification.create!(
        :audience => Notification::AUDIENCE_USER,
        :notification_blueprint => blueprint,
        :initiator => initiator,
        :message => message,
        :subject => subject,
        :actions => {
          :links => links
        }
      )
    end

    def blueprint
      name = 'Sync_playbooks_failed'
      @blueprint ||= NotificationBlueprint.unscoped.find_by(:name => name)
    end

    def message
      _("Failed to import playbooks Due to: #{@job_error}")
    end

    def links
      [{ :href => Rails.application.routes.url_helpers.foreman_tasks_task_path(:id => subject.id), :title => N_('Task Details') }]
    end
  end
end

Version data entries

53 entries across 53 versions & 1 rubygems

Version Path
foreman_ansible-10.2.0 app/services/foreman_ansible/import_playbooks_error_notification.rb
foreman_ansible-10.1.0 app/services/foreman_ansible/import_playbooks_error_notification.rb
foreman_ansible-10.0.1 app/services/foreman_ansible/import_playbooks_error_notification.rb
foreman_ansible-10.0.0 app/services/foreman_ansible/import_playbooks_error_notification.rb
foreman_ansible-7.1.4 app/services/foreman_ansible/import_playbooks_error_notification.rb
foreman_ansible-9.0.1 app/services/foreman_ansible/import_playbooks_error_notification.rb
foreman_ansible-7.1.3 app/services/foreman_ansible/import_playbooks_error_notification.rb
foreman_ansible-9.0.0 app/services/foreman_ansible/import_playbooks_error_notification.rb
foreman_ansible-7.1.2 app/services/foreman_ansible/import_playbooks_error_notification.rb
foreman_ansible-7.1.1 app/services/foreman_ansible/import_playbooks_error_notification.rb
foreman_ansible-8.0.1 app/services/foreman_ansible/import_playbooks_error_notification.rb
foreman_ansible-8.0.0 app/services/foreman_ansible/import_playbooks_error_notification.rb
foreman_ansible-7.1.0 app/services/foreman_ansible/import_playbooks_error_notification.rb