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

Use the new ServiceWidget #73

Merged
merged 9 commits into from
Aug 10, 2018
Merged

Use the new ServiceWidget #73

merged 9 commits into from
Aug 10, 2018

Conversation

dgdavid
Copy link
Member

@dgdavid dgdavid commented Aug 1, 2018

@dgdavid dgdavid changed the title Feature/service widget Use the new ServiceWidget Aug 1, 2018
# SuSEFirewall2 replaced by firewalld
BuildRequires: yast2 >= 4.0.39
# Yast2::ServiceWidget
BuildRequires: yast2 >= 4.1.0
Copy link
Contributor

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

@teclator
Copy link
Contributor

teclator commented Aug 1, 2018

In general, it looks good. Just not sure about the responsibility of restarting services as it was partially in DnsService.Write method.

Other doubt, could you link the PR which contains the yast2-4.1.0 version?

@dgdavid
Copy link
Member Author

dgdavid commented Aug 1, 2018

Just not sure about the responsibility of restarting services as it was partially in DnsService.Write method.

What do you mean? Restart/Reload the service always after write settings?

@@ -0,0 +1,22 @@
require "cwm/service_widget"

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

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.

Copy link
Member Author

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

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.

Copy link
Member Author

@dgdavid dgdavid Aug 7, 2018

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?

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

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.

Copy link
Member Author

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?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or require "yast/logger"

Copy link
Contributor

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?"))

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

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

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"))

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

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.

Copy link
Member Author

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())

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.

Copy link
Member Author

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.

Copy link

@joseivanlopez joseivanlopez left a 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.

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).
@dgdavid dgdavid changed the base branch from SLE-15-GA to master August 10, 2018 08:41
@coveralls
Copy link

coveralls commented Aug 10, 2018

Coverage Status

Coverage increased (+0.7%) to 20.475% when pulling fb6a305 on feature/service_widget into 29d565a on master.

Much of the methods related to status service widget were duplicated in
both dialog, reason why it has been moved to a helper module.
Copy link
Contributor

@imobachgs imobachgs left a 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
Copy link
Contributor

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
Copy link
Contributor

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")
Copy link
Contributor

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?

Copy link
Member Author

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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?")
Copy link
Contributor

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.

Copy link
Member Author

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)
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants