Hello community,

here is the log from the commit of package yast2 for openSUSE:Factory checked 
in at 2020-01-04 19:20:41
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/yast2 (Old)
 and      /work/SRC/openSUSE:Factory/.yast2.new.6675 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "yast2"

Sat Jan  4 19:20:41 2020 rev:468 rq:758203 version:4.2.49

Changes:
--------
--- /work/SRC/openSUSE:Factory/yast2/yast2.changes      2019-12-14 
12:03:08.867405708 +0100
+++ /work/SRC/openSUSE:Factory/.yast2.new.6675/yast2.changes    2020-01-04 
19:20:47.565122655 +0100
@@ -1,0 +2,13 @@
+Thu Dec 19 14:51:23 UTC 2019 - Knut Anderssen <[email protected]>
+
+- Yast2::ServiceWidget: By default, propose to reload or restart
+  the service when it is active (bsc#1158946)
+- 4.2.49
+
+-------------------------------------------------------------------
+Thu Dec 19 09:11:35 CET 2019 - [email protected]
+
+- Added helper to create UI sort-key term (bsc#1140018)
+- 4.2.48
+
+-------------------------------------------------------------------

Old:
----
  yast2-4.2.47.tar.bz2

New:
----
  yast2-4.2.49.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ yast2.spec ++++++
--- /var/tmp/diff_new_pack.7evDyH/_old  2020-01-04 19:20:48.257122962 +0100
+++ /var/tmp/diff_new_pack.7evDyH/_new  2020-01-04 19:20:48.257122962 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           yast2
-Version:        4.2.47
+Version:        4.2.49
 Release:        0
 Summary:        YaST2 Main Package
 License:        GPL-2.0-only

++++++ yast2-4.2.47.tar.bz2 -> yast2-4.2.49.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-4.2.47/library/cwm/src/lib/cwm/service_widget.rb 
new/yast2-4.2.49/library/cwm/src/lib/cwm/service_widget.rb
--- old/yast2-4.2.47/library/cwm/src/lib/cwm/service_widget.rb  2019-12-05 
08:52:54.000000000 +0100
+++ new/yast2-4.2.49/library/cwm/src/lib/cwm/service_widget.rb  2019-12-19 
15:11:34.000000000 +0100
@@ -23,6 +23,8 @@
 module CWM
   # CWM wrapper for Yast2::ServiceWidget
   class ServiceWidget < CustomWidget
+    extend Forwardable
+
     # creates new widget instance for given service
     # @param service [Yast2::SystemService,Yast2::CompoundService] service to 
be configured
     def initialize(service)
@@ -30,14 +32,12 @@
       self.handle_all_events = true
     end
 
+    def_delegators :@service_widget, :refresh, :store, :help, :default_action=
+
     def contents
       @service_widget.content
     end
 
-    def refresh
-      @service_widget.refresh
-    end
-
     def handle(event)
       log.info "handling event #{event.inspect}"
       return unless event
@@ -45,18 +45,10 @@
       @service_widget.handle_input(event["ID"])
     end
 
-    def store
-      @service_widget.store
-    end
-
     # The widget needs to be refreshed each time it is rendered. Otherwise, 
cached
     # service values would not be selected (e.g., when switching in a 
DialogTree)
     def init
       refresh
     end
-
-    def help
-      @service_widget.help
-    end
   end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-4.2.47/library/cwm/src/lib/cwm/table.rb 
new/yast2-4.2.49/library/cwm/src/lib/cwm/table.rb
--- old/yast2-4.2.47/library/cwm/src/lib/cwm/table.rb   2019-12-05 
08:52:54.000000000 +0100
+++ new/yast2-4.2.49/library/cwm/src/lib/cwm/table.rb   2019-12-19 
15:11:34.000000000 +0100
@@ -91,6 +91,12 @@
       Yast::Term.new(:icon, path)
     end
 
+    # helper to create sort-key term
+    # @param value [String] sort-key
+    def sort_key(value)
+      Yast::Term.new(:sortKey, value)
+    end
+
     # helper to create icon term
     # @param args content of cell, often used to combine icon and string
     # @note Please see difference between `Cell` and `cell`. The first one is
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/yast2-4.2.47/library/systemd/src/lib/yast2/service_widget.rb 
new/yast2-4.2.49/library/systemd/src/lib/yast2/service_widget.rb
--- old/yast2-4.2.47/library/systemd/src/lib/yast2/service_widget.rb    
2019-12-05 08:52:54.000000000 +0100
+++ new/yast2-4.2.49/library/systemd/src/lib/yast2/service_widget.rb    
2019-12-19 15:11:34.000000000 +0100
@@ -34,12 +34,17 @@
   #     end
   #
   #     def propose
-  #       @service.action = :restart
+  #       # The default service widget action can be proposed by the current
+  #       # service action
+  #       @service.restart
   #       @service.start_mode = :on_demand
   #     end
   #
   #     def show_dialog
   #       service_widget = ServiceWidget.new(@service)
+  #       # Or can be set by the service_widget
+  #       service_widget.default_action = :reload if service.running?
+  #
   #       content = VBox(
   #         ...,
   #         service_widget.content
@@ -60,15 +65,35 @@
   # @todo Allow to specify the widget ID. Currently, it uses always the same, 
so you can not use
   #   more than one instance of this class at the same time.
   class ServiceWidget
+    extend Yast::I18n
     include Yast::I18n
     include Yast::Logger
     include Yast::UIShortcuts
 
+    # It stores the selected service action
+    #
+    # @return [Symbol] service action (:nothing for no action)
+    # @see Yast2::SystemService#action
+    attr_reader :current_action
+
     # creates new widget instance for given service
     # @param service [Yast2::SystemService,Yast2::CompoundService] service
     def initialize(service)
       textdomain "base"
       @service = service
+      # When the service is active, by default, propose to reload or restart
+      # it after writting the configuration (bsc#1158946)
+      init_default_action
+    end
+
+    # Set the given action as the current action selected by the widget, when
+    # no action is given it will not touch the service unless modified in the
+    # selection list
+    #
+    # @param value [Symbol, nil] uses :nothing in case of no action given
+    # @see Yast2::SystemService#action
+    def default_action=(value)
+      @current_action = value || :nothing
     end
 
     # gets widget term
@@ -155,11 +180,28 @@
 
     attr_reader :service
 
+    # Initialize the default option for the service widget. It tries to use the
+    # action from the service if set, if not, will propose :reload or :restart
+    # when the service is active or do nothing in case of inactive.
+    def init_default_action
+      # For being compatible with the default action proposed by the service
+      return self.default_action = service.action if service.action
+      return self.default_action = :nothing unless service.currently_active?
+
+      self.default_action = service.support_reload? ? :reload : :restart
+    end
+
     def store_action
       action = Yast::UI.QueryWidget(Id(:service_widget_action), :Value)
       return unless action
 
       action = action.to_s.sub(/^service_widget_action_/, "").to_sym
+      # Remember the selected option in case of refresh, specially if the
+      # option was :reload or :restart it will be the same after applying the
+      # changes and refreshing
+      @current_action = action
+      # We can return safely without modifying the service action as the
+      # service should be reset before calling this method
       return if action == :nothing
 
       service.public_send(action)
@@ -199,16 +241,64 @@
       )
     end
 
-    def action_items
-      current_action = service.action
-      res = []
-      res << Item(Id(:service_widget_action_start), _("Start"), current_action 
== :start) if service.currently_active? != true
-      res << Item(Id(:service_widget_action_stop), _("Stop"), current_action 
== :stop) if service.currently_active? != false
-      res << Item(Id(:service_widget_action_restart), _("Restart"), 
current_action == :restart) if service.currently_active? != false
-      res << Item(Id(:service_widget_action_reload), _("Reload"), 
current_action == :reload) if service.currently_active? != false && 
service.support_reload?
-      res << Item(Id(:service_widget_action_nothing), _("Keep current state"), 
current_action.nil?)
+    ACTION_LABEL =
+      {
+        start:   N_("Start"),
+        stop:    N_("Stop"),
+        reload:  N_("Reload"),
+        restart: N_("Restart"),
+        nothing: N_("Keep current state")
+      }.freeze
 
-      res
+    # Return whether the option given is supported and a valid one according
+    # to the service status.
+    #
+    # @param value [Symbol] the current_action selected
+    def valid_action?(value)
+      actions.include?(value)
+    end
+
+    # Return the list of actions permitted and supported depending on the
+    # current service status.
+    def actions
+      actions = service.currently_active? ? [:stop, :restart] : [:start]
+      actions << :reload if service.currently_active? && 
service.support_reload?
+      actions << :nothing
+    end
+
+    # @param value [Symbol]
+    def action_item_id(value)
+      Id("service_widget_action_#{value}".to_sym)
+    end
+
+    # @param value [Symbol]
+    def action_label(value)
+      _(ACTION_LABEL[value])
+    end
+
+    # When the cached action is valid, it returns if the current action is the
+    # given action. If the cached option is invalid, then return true only if
+    # the given action is for not touching the service
+    #
+    # @see valid_action?
+    # @param value [Symbol]
+    def selected_item?(value)
+      if !valid_action?(current_action)
+        value == :nothing
+      else
+        current_action == value
+      end
+    end
+
+    # @param value [Symbol]
+    # @return [Yast::Term] action Item
+    def action_item(value)
+      Item(action_item_id(value), action_label(value), selected_item?(value))
+    end
+
+    # @return [Array<Yast::Term>] list of action items
+    def action_items
+      actions.map { |a| action_item(a) }
     end
 
     def autostart_widget
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-4.2.47/package/yast2.changes 
new/yast2-4.2.49/package/yast2.changes
--- old/yast2-4.2.47/package/yast2.changes      2019-12-05 08:52:54.000000000 
+0100
+++ new/yast2-4.2.49/package/yast2.changes      2019-12-19 15:11:34.000000000 
+0100
@@ -1,4 +1,17 @@
 -------------------------------------------------------------------
+Thu Dec 19 14:51:23 UTC 2019 - Knut Anderssen <[email protected]>
+
+- Yast2::ServiceWidget: By default, propose to reload or restart
+  the service when it is active (bsc#1158946)
+- 4.2.49
+
+-------------------------------------------------------------------
+Thu Dec 19 09:11:35 CET 2019 - [email protected]
+
+- Added helper to create UI sort-key term (bsc#1140018)
+- 4.2.48
+
+-------------------------------------------------------------------
 Wed Dec  4 14:26:35 UTC 2019 - Josef Reidinger <[email protected]>
 
 - Add backward compatible hash accessors to Resolvable which solve
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/yast2-4.2.47/package/yast2.spec 
new/yast2-4.2.49/package/yast2.spec
--- old/yast2-4.2.47/package/yast2.spec 2019-12-05 08:52:54.000000000 +0100
+++ new/yast2-4.2.49/package/yast2.spec 2019-12-19 15:11:34.000000000 +0100
@@ -17,7 +17,7 @@
 
 
 Name:           yast2
-Version:        4.2.47
+Version:        4.2.49
 Release:        0
 Summary:        YaST2 Main Package
 License:        GPL-2.0-only


Reply via email to