Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle language change in users and storage #1642

Merged
merged 5 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion service/lib/agama/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def startup_phase
def locale=(locale)
service_status.busy
change_process_locale(locale)
users.update_issues
start_progress_with_descriptions(
_("Load software translations"),
_("Load storage translations")
Expand Down Expand Up @@ -183,7 +184,7 @@ def language

# Users client
#
# @return [DBus::Clients::Users]
# @return [Agama::Users]
def users
@users ||= Users.new(logger)
end
Expand Down
1 change: 1 addition & 0 deletions service/lib/agama/storage/manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ def actions
# @param locale [String] new locale
def locale=(locale)
change_process_locale(locale)
update_issues
end

private
Expand Down
45 changes: 23 additions & 22 deletions service/lib/agama/storage/proposal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ def initialize(config, logger: nil)
@on_calculate_callbacks = []
end

# List of issues.
#
# @return [Array<Issue>]
attr_reader :issues

# Whether the proposal was already calculated.
#
# @return [Boolean]
Expand Down Expand Up @@ -192,6 +187,25 @@ def guided_settings
strategy_object.settings
end

# List of issues.
#
# @return [Array<Issue>]
def issues
items = []

case @calculate_error
when Y2Storage::NoDiskSpaceError
items << failed_issue
when Y2Storage::Error
items << exception_issue(@calculate_error)
else
items << failed_issue if proposal&.failed?
end

items.concat(strategy_object.issues) if strategy_object
items
end

private

# @return [Agama::Config]
Expand Down Expand Up @@ -232,16 +246,15 @@ def calculate_agama_from_json(storage_json)
def calculate
return false unless storage_manager.probed?

@issues = []

@calculate_error = nil
begin
strategy_object.calculate
@issues << failed_issue if proposal.failed?
rescue Y2Storage::Error => e
handle_exception(e)
@calculate_error = e
rescue StandardError => e
raise e
end

@issues.concat(strategy_object.issues)
@on_calculate_callbacks.each(&:call)
success?
end
Expand All @@ -263,18 +276,6 @@ def storage_manager
Y2Storage::StorageManager.instance
end

# Handle Y2Storage exceptions
def handle_exception(error)
case error
when Y2Storage::NoDiskSpaceError
@issues << failed_issue
when Y2Storage::Error
@issues << exception_issue(error)
else
raise error
end
end

# Issue representing the proposal is not valid.
#
# @return [Issue]
Expand Down
8 changes: 4 additions & 4 deletions service/lib/agama/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,6 @@ def write
end
end

private

attr_reader :logger

# Recalculates the list of issues
def update_issues
new_issues = []
Expand All @@ -158,6 +154,10 @@ def update_issues
self.issues = new_issues
end

private

attr_reader :logger

# Determines whether a first user is defined or not
#
# @return [Boolean]
Expand Down
2 changes: 1 addition & 1 deletion service/lib/agama/with_locale.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def change_process_locale(locale)
ENV["LANG"] = locale
log.info "set yast locale to #{locale}"
# explicit call to textdomain to force fast gettext change of language ASAP
textdomain "installation"
textdomain "agama"
end
end
end
6 changes: 6 additions & 0 deletions service/package/rubygem-agama-yast.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Fri Sep 27 09:23:40 UTC 2024 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

- Handle UI language change in users and storage
(gh#agama-project/agama#1642).

-------------------------------------------------------------------
Mon Sep 23 14:55:53 UTC 2024 - José Iván López González <jlopez@suse.com>

Expand Down
Loading