openSUSE:WebYaST 插件状态消息

跳转到:导航搜索

插件状态消息

每个 WebYaST 服务插件都有可能在其状态 WebYaST UI 中报告其状态。

一些用例包括:

  • 注册服务插件希望报告注册尚未完成或未正确完成。
  • 邮件服务插件希望请求成功发送测试邮件。

如何定义消息?

服务消息在名为 <controoler_name>_state.rb 的单独模型中定义

例如: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

如果模块不想报告任何内容,将返回一个空 Hash。否则,将返回一个包含以下条目的 Hash

  • level ok|warning|error
  • message_id 此 ID 将当前用于在 WebYaST 客户端上定义翻译。
  • short_description 此消息将在控制中心显示,并且是状态 UI 插件中的标题。
  • long_description 状态 UI 插件中将显示消息的详细描述。
  • confirmation_host client|service。在 confirmation_link 中描述的链接属于 UI 或服务。
  • confirmation_link confirmation_label 中描述的按钮/链接背后的地址
  • confirmation_label 将在状态 UI 插件中显示的按钮/链接的标签。
  • confirmation_kind button/link