Skip to content

Commit

Permalink
Update from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
dgdavid committed Aug 7, 2018
1 parent 7f33661 commit 4bd94a0
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/include/dhcp-server/dialogs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
#
# Representation of the configuration of dhcp-server.
# Input and output routines.

require "yast2/popup"

module Yast
module DhcpServerDialogsInclude
include Yast::Logger
Expand Down Expand Up @@ -51,7 +54,7 @@ def ReadDialog
# Write settings dialog
#
# @return [Symbol] :next whether configuration is saved successfully
# :back if user decided to change settings
# :back if user decided go back to change settings
# :abort otherwise
def WriteDialog
log.info("Running write dialog")
Expand All @@ -60,7 +63,7 @@ def WriteDialog
Wizard.RestoreHelp(help_text)

return :next if write_settings
return :back if Popup.YesNo(_("Saving the configuration failed. Change the settings?"))
return :back if back_to_change_setting?
:abort
end

Expand All @@ -82,17 +85,27 @@ def SaveAndRestart(event)

# Write DHCP server settings and save the service
#
# NOTE: currently, the DhpcServer is a Perl module, reason why the write of
# @note currently, the DhpcServer is a Perl module, reason why the write of
# settings is being performed in two separate steps.
#
# @return [Boolean] true if settings are saved successfully; false otherwise
def write_settings
DhcpServer.Write && dhcp_service.save
end

# Shows a popup asking to user if wants to change settings
#
# @return [Boolean] true if user decides to go back to change settings; false otherwise
def back_to_change_setting?
change_settings_message = _("Saving the configuration failed. Change the settings?")
Yast2::Popup.show(change_settings_message, headline: :warning, buttons: :yes_no) == :yes
end

# Validates and saves CWM widgets
#
# @param [Hash] event map that triggered saving
#
# @return [Boolean] true when widgets pass the validaton; false otherwise
def validate_and_save_widgets(event)
return false unless CWM.validate_current_widgets(event)

Expand Down

0 comments on commit 4bd94a0

Please sign in to comment.