-
Notifications
You must be signed in to change notification settings - Fork 11
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
Use the new ServiceWidget #73
Conversation
# SuSEFirewall2 replaced by firewalld | ||
BuildRequires: yast2 >= 4.0.39 | ||
# Yast2::ServiceWidget | ||
BuildRequires: yast2 >= 4.1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not only required for Building
In general, it looks good. Just not sure about the responsibility of restarting services as it was partially in Other doubt, could you link the PR which contains the yast2-4.1.0 version? |
What do you mean? Restart/Reload the service always after write settings? |
cc96351
to
90fc0fb
Compare
@@ -0,0 +1,22 @@ | |||
require "cwm/service_widget" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add license text at the beginning of the file.
@service ||= Yast2::SystemService.find("named") | ||
end | ||
|
||
# Returns the status widget for service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only for curiosity, why do you refer the widget as "status widget"? It confuses me a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it is the (service) widget responsible to manage the final status of service (running, stopped, etc). But if it is confusing I could change it and simply use "service widget" :)
|
||
# Returns the status widget for service | ||
# | ||
# @return [::CWM::ServiceWidget] service status widget |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NP: is it necessary to explicitly add ::
for top-level name resolution? In case there is no conflict, I would not add it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had problems without the ::
, but I can't remember if it was here. However, after that I started to use ::CWM::ServiceWidget
in all modules, for consistence. Shall I to use ::
only when needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was curious why you needed it. Fine with me as it is now.
|
||
module Yast | ||
# Representation of the configuration of dns-server. | ||
# Input and output routines. | ||
module DnsServerDialogMainInclude | ||
include Yast::Logger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it is necessary to require yast to use the logger. Probably it works because another file is already requiring yast.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I must to explicitly require "yast"
at the beginning, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or require "yast/logger"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requiring yast
is quite common.
Wizard.RestoreHelp(write_help_text) | ||
|
||
return :next if write_settings | ||
return :back if Popup.YesNo(_("Saving the configuration failed. Change the settings?")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NP: same comment as in another PR. In new code I would use Yast2::Popup
.
end | ||
|
||
# Writes settings and restores the dialog without exiting | ||
def SaveAndRestart | ||
# Writes settings without exit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NP: typo "without exit" => "without exiting" ?
nil | ||
end | ||
|
||
# Writes DNS server settings and save the service | ||
# | ||
# NOTE: currently, the DnsServer is a Perl module, reason why the write of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NP: please, use @note
VSpacing(), | ||
"firewall", | ||
VStretch(), | ||
Right( | ||
PushButton(Id("apply"), _("Apply Changes")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change? I would tend to avoid the Hash way to define widgets.
require "yast2/system_service" | ||
|
||
module Y2DnsServer | ||
module ServiceWidgetHelpers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NP: Do you think this "helper" pays off? At the end, it only contains to simple methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other option is to have this two simple methods duplicated, reason why I move them here.
} | ||
Service->Disable ("named"); | ||
|
||
if (Mode->auto() || Mode->config()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably we could definitely remove this code and use SystemService
in auto client.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but maybe it is better to do it as a dedicated task, after finish the ServiceWidget adaptation.
f0374a0
to
a46872d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, update version and add changelog entry.
8f68cfb
to
e2506f8
Compare
Since Yast2::SystemService (used through the new ServiceWidget) is responsible to update properly the service status (start/stop/restart/...), related logic in the DnsServer Perl module it has been limited to be executed only for AutoYast (`auto` and `config` modes).
e2506f8
to
aa02e8b
Compare
aa02e8b
to
ee9e8ac
Compare
Much of the methods related to status service widget were duplicated in both dialog, reason why it has been moved to a helper module.
ee9e8ac
to
67c97a6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor comments. Otherwise, it looks good.
@@ -23,6 +28,14 @@ def initialize_dns_server_dialog_installwizard(include_target) | |||
Yast.import "CWMFirewallInterfaces" | |||
end | |||
|
|||
# Writes settings and save the service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np: saves
|
||
module Yast | ||
# Representation of the configuration of dns-server. | ||
# Input and output routines. | ||
module DnsServerDialogMainInclude | ||
include Yast::Logger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requiring yast
is quite common.
:abort | ||
end | ||
end | ||
log.info("Running write dialog") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you really want to log this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I don't. However I started with dhcp
module, which has an identical method which logs that information. So, in attempt to has an unified code I put it also here.
But no problem deleting it :)
|
||
nil | ||
end | ||
|
||
# Writes DNS server settings and save the service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np: saves
DnsServer.Write && service.save | ||
end | ||
|
||
# Shows a popup asking to user if wants to change settings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np: to the user
|
||
# 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
np: the user
# | ||
# @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?") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are keeping the original text (which is right). But it does not sound good to me. I would go for something like "Do you want to review the settings?". But, for the time being, let's keep it as it is because it is out of the scope of this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree
# Validates and saves CWM widgets | ||
# | ||
# @param [Hash] event map that triggered saving | ||
def validate_and_save_widgets(event) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, document the return value.
c90effd
to
fb6a305
Compare
More info: https://trello.com/c/uAe4i9Ru/107-5-fate319428-allow-socket-activation-widget