Skip to content

Commit

Permalink
include manual repo selection in the result
Browse files Browse the repository at this point in the history
  • Loading branch information
lslezak committed Jun 13, 2015
1 parent 716df5a commit 19b184b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
42 changes: 35 additions & 7 deletions src/lib/registration/ui/migration_repos_workflow.rb
Expand Up @@ -31,6 +31,7 @@ def initialize
url = UrlHelpers.registration_url
self.registration = Registration.new(url)
self.registration_ui = RegistrationUI.new(registration)
self.registered_services = []
end

# The media add-on workflow is:
Expand Down Expand Up @@ -72,13 +73,18 @@ def run
}

log.info "Starting migration repositories sequence"
Yast::Sequencer.Run(aliases, sequence)
ui = Yast::Sequencer.Run(aliases, sequence)
log.info "User input: #{ui}"
self.aborted = ui == :abort || ui == :cancel

client_result
end

private

attr_accessor :result, :products, :migrations, :registration,
:registration_ui, :selected_migrations
:registration_ui, :selected_migrations, :registered_services,
:manual_repo_selection, :aborted

# check if the add-on repository provides a product resolvable
# @return [Symbol] workflow symbol (:next, :finish or :abort)
Expand Down Expand Up @@ -118,27 +124,49 @@ def select_migration_products
dialog = MigrationSelectionDialog.new(migrations)
ret = dialog.run

self.selected_migrations = dialog.selected_migrations if ret == :next
if ret == :next
self.selected_migrations = dialog.selected_migrations
self.manual_repo_selection = dialog.manual_repo_selection
end

log.info "Selected migrations: #{selected_migrations}"
ret
end

def register_migration_products
ret = []
Yast::Popup.Feedback(RegistrationUI::CONTACTING_MESSAGE,
# TRANSLATORS: Progress label
_("Registering Migration Products...")) do
selected_migrations.each do |migration|
migration.each do |product|
log.info "Registering migration product #{product}"
ret << registration.upgrade_product(product)
registered_services << registration.upgrade_product(product)
end
end
end

log.info "Registered migration products: #{ret}"
ret
log.info "Registered services: #{registered_services}"
:next
end

def client_result
{
aborted: aborted,
registered_services: registered_services.map do |service|
{
name: service.name,
url: service.url,
product: {
name: service.product.identifier,
friendly_name: service.product.friendly_name,
version: service.product.version,
arch: service.product.arch,
release_type: service.product.release_type
},
manual_repo_selection: manual_repo_selection
}
end
}
end
end
end
Expand Down
5 changes: 4 additions & 1 deletion src/lib/registration/ui/migration_selection_dialog.rb
Expand Up @@ -30,7 +30,7 @@ class MigrationSelectionDialog
Yast.import "UI"
Yast.import "Wizard"

attr_accessor :selected_migrations
attr_accessor :selected_migrations, :manual_repo_selection

def self.run(migrations)
dialog = MigrationSelectionDialog.new(migrations)
Expand All @@ -43,6 +43,7 @@ def initialize(migrations)
textdomain "registration"

self.migrations = migrations
self.manual_repo_selection = false
end

# display and run the dialog
Expand All @@ -68,6 +69,8 @@ def run
self.selected_migrations = []
selected.each { |idx| selected_migrations << migrations[idx] }
log.info "Selected migrations: #{selected_migrations}"

self.manual_repo_selection = Yast::UI.QueryWidget(Id(:manual_repos), :Value)
end

ret
Expand Down

0 comments on commit 19b184b

Please sign in to comment.