From 3e07fd9baddeb50e4145835c6224319a095dea18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Imobach=20Gonz=C3=A1lez=20Sosa?= Date: Thu, 23 Jan 2025 11:53:09 +0000 Subject: [PATCH] feat: ask for registration when base product is missing --- service/lib/agama/dbus/software/product.rb | 3 +-- service/lib/agama/software/manager.rb | 14 +++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/service/lib/agama/dbus/software/product.rb b/service/lib/agama/dbus/software/product.rb index b8c02aaaa5..b1db6e266f 100644 --- a/service/lib/agama/dbus/software/product.rb +++ b/service/lib/agama/dbus/software/product.rb @@ -180,8 +180,6 @@ def register(reg_code, email: nil) [1, "Product not selected yet"] elsif backend.registration.reg_code [2, "Product already registered"] - elsif !backend.product.registration - [3, "Product does not support registration"] else connect_result(first_error_code: 4) do backend.registration.register(reg_code, email: email) @@ -254,6 +252,7 @@ def register_callbacks # software related issues. backend.registration.on_change { issues_properties_changed } backend.registration.on_change { registration_properties_changed } + backend.on_issues_change { issues_properties_changed } end def registration_properties_changed diff --git a/service/lib/agama/software/manager.rb b/service/lib/agama/software/manager.rb index ddd415a735..f5b1856d4e 100644 --- a/service/lib/agama/software/manager.rb +++ b/service/lib/agama/software/manager.rb @@ -589,6 +589,7 @@ def missing_product_issue # @return [Agama::Issue] def missing_registration_issue Issue.new(_("Product must be registered"), + kind: :missing_registration, source: Issue::Source::SYSTEM, severity: Issue::Severity::ERROR) end @@ -597,8 +598,19 @@ def missing_registration_issue # # @return [Boolean] def missing_registration? + return false unless product + registration.reg_code.nil? && - registration.requirement == Agama::Registration::Requirement::MANDATORY + product.registration && + missing_base_product? + end + + # Whether the base product is missing + # + # @return [Boolean] + def missing_base_product? + products = Y2Packager::Resolvable.find(kind: :product, name: product.name) + products.empty? end def pattern_exist?(pattern_name)