Sha256: bee91ce7073b92a62a65c9277915996c82c3bfb2276a32bb4f64b77194b65e6d

Contents?: true

Size: 1.62 KB

Versions: 72

Compression:

Stored size: 1.62 KB

Contents

module Actions
  module Pulp3
    module Repository
      module Presenters
        class AbstractSyncPresenter < Helpers::Presenter::Base
          def humanized_output
            if action.external_task
              humanized_details
            end
          end

          private

          def humanized_details
            fail NotImplementedError
          end

          def index_action
            plan = action.execution_plan
            index_step = plan.run_steps.find { |s| s.action_class == Actions::Katello::Repository::IndexContent }
            index_step&.action(plan)
          end

          def added_content_message
            if (content_added = index_action&.output&.[](:new_content))
              content_added = content_added.select { |_type, number| number > 0 }
              if content_added&.any?
                count_messages = content_added.map { |type, number| "#{type.to_s.humanize.pluralize}: #{number}" }
                _("Added %s") % count_messages.join(', ')
              else
                _("No content added.")
              end
            end
          end

          def sync_task
            tasks = action.external_task.select do |task|
              if task.key? 'name'
                task['name'].include?("sync")
              end
            end
            tasks.first
          end

          def cancelled?
            sync_task && sync_task['state'] == 'cancelled'
          end

          def task_result
            sync_task['result']
          end

          def task_result_details
            task_result && task_result['details']
          end
        end
      end
    end
  end
end

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
katello-4.11.0.rc2 app/lib/actions/pulp3/repository/presenters/abstract_sync_presenter.rb
katello-4.11.0.rc1 app/lib/actions/pulp3/repository/presenters/abstract_sync_presenter.rb
katello-4.10.0 app/lib/actions/pulp3/repository/presenters/abstract_sync_presenter.rb
katello-4.9.2 app/lib/actions/pulp3/repository/presenters/abstract_sync_presenter.rb
katello-4.10.0.rc2 app/lib/actions/pulp3/repository/presenters/abstract_sync_presenter.rb
katello-4.10.0.rc1 app/lib/actions/pulp3/repository/presenters/abstract_sync_presenter.rb
katello-4.8.4 app/lib/actions/pulp3/repository/presenters/abstract_sync_presenter.rb
katello-4.9.1 app/lib/actions/pulp3/repository/presenters/abstract_sync_presenter.rb
katello-4.8.3 app/lib/actions/pulp3/repository/presenters/abstract_sync_presenter.rb
katello-4.9.0 app/lib/actions/pulp3/repository/presenters/abstract_sync_presenter.rb
katello-4.7.6 app/lib/actions/pulp3/repository/presenters/abstract_sync_presenter.rb
katello-4.8.2 app/lib/actions/pulp3/repository/presenters/abstract_sync_presenter.rb
katello-4.9.0.rc2 app/lib/actions/pulp3/repository/presenters/abstract_sync_presenter.rb
katello-4.9.0.rc1 app/lib/actions/pulp3/repository/presenters/abstract_sync_presenter.rb
katello-4.8.1 app/lib/actions/pulp3/repository/presenters/abstract_sync_presenter.rb
katello-4.7.5 app/lib/actions/pulp3/repository/presenters/abstract_sync_presenter.rb
katello-4.8.0 app/lib/actions/pulp3/repository/presenters/abstract_sync_presenter.rb
katello-4.8.0.rc2 app/lib/actions/pulp3/repository/presenters/abstract_sync_presenter.rb
katello-4.7.4 app/lib/actions/pulp3/repository/presenters/abstract_sync_presenter.rb
katello-4.8.0.rc1 app/lib/actions/pulp3/repository/presenters/abstract_sync_presenter.rb