openSUSE:WebYaST plugin status messages

Jump to: navigation, search

Plugin Status Messages

Each WebYaST service plugin has the possibility to report his state in the status WebYaST UI.

Some usecases are:

  • The registration service plugin wants to report that the registration has not been done or has not been finished correctly.
  • The mail service plugin wants to ask for the successfully sent of a test email.

How to define a message ?

A service message is defined in an own model with the filename <controoler_name>_state.rb

e.g. registration/app/models/registration_state.rb:

require 'gettext'

class RegistrationState
  include GetText
  def self.read()
    unless Register.new.is_registered?
      return { :level => "warning",
               :message_id => "MISSING_REGISTRATION",
               :short_description => _("Registration is missing"),
               :long_description => _("Please register your system in order to get updates."),
               :confirmation_host => "client",
               :confirmation_link => "/registration",
               :confirmation_label => _("register"),
               :confirmation_kind => "link" } 
     else
       return {}
     end
  end
end

An empty Hash will be returned if the module does not want to report anything. Otherwise a Hash will be returned with following entries:

  • level ok|warning|error
  • message_id This ID will be currently used for defining the translation on the WebYaST client side.
  • short_description This message will be shown in the control center and is the headline in the status UI plugin.
  • long_description A detailed description of the message will be shown in the status UI plugin.
  • confirmation_host client|service. The link described in confirmation_link belongs to the UI or the service.
  • confirmation_link Address behind the button/link described in confirmation_label
  • confirmation_label Label for the button/link which will will be shown in the status UI plugin.
  • confirmation_kind button/link