• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

yast / yast-network / 13674608242

05 Mar 2025 11:09AM UTC coverage: 79.781% (-1.1%) from 80.833%
13674608242

Pull #1374

github

teclator
Make rubocop happy
Pull Request #1374: Added dialog for changing the bond ports naming schema to BusID (bsc#1233653) - master

11 of 139 new or added lines in 5 files covered. (7.91%)

40 existing lines in 16 files now uncovered.

9403 of 11786 relevant lines covered (79.78%)

20.05 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

38.3
/src/include/network/widgets.rb
1
# ***************************************************************************
2
#
3
# Copyright (c) 2012 Novell, Inc.
4
# All Rights Reserved.
5
#
6
# This program is free software; you can redistribute it and/or
7
# modify it under the terms of version 2 of the GNU General Public License as
8
# published by the Free Software Foundation.
9
#
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.   See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, contact Novell, Inc.
17
#
18
# To contact Novell about this file by physical or electronic mail,
19
# you may find current contact information at www.novell.com
20
#
21
# **************************************************************************
22
# File:        include/network/widgets.ycp
23
# Package:     Network configuration
24
# Summary:     Widgets for CWM
25
# Authors:     Martin Vidner <mvidner@suse.cz>
26
#
27
module Yast
1✔
28
  module NetworkWidgetsInclude
1✔
29
    def initialize_network_widgets(include_target)
1✔
30
      Yast.import "UI"
59✔
31

32
      textdomain "network"
59✔
33

34
      # Gradually all yast2-network UI will be converted to CWM
35
      # for easier maintenance.
36
      # This is just a start.
37

38
      Yast.import "IP"
59✔
39
      Yast.import "NetworkService"
59✔
40
      Yast.import "Lan"
59✔
41

42
      Yast.include include_target, "network/complex.rb"
59✔
43
    end
44

45
    # Validator for IP adresses, no_popup
46
    # @param key [String] the widget being validated
47
    # @param _event [Hash] the event being handled
48
    # @return whether valid
49
    def ValidateIP(key, _event)
1✔
50
      value = Convert.to_string(UI.QueryWidget(Id(key), :Value))
×
51
      return IP.Check(value) if value != ""
×
52

53
      true
×
54
    end
55

56
    # Initialize the NetworkManager widget
57
    # @param _key [String] id of the widget
58
    def ManagedInit(_key)
1✔
59
      items = []
×
60

61
      Y2Network::Backend.available.each do |backend|
×
62
        items << Item(
×
63
          Id(backend.name),
64
          # the user can control the network with the NetworkManager program
65
          backend.label,
66
          !!Lan.yast_config&.backend?(backend.id)
67
        )
68
      end
69

70
      UI.ChangeWidget(Id(:managed), :Items, items)
×
71

UNCOV
72
      nil
×
73
    end
74

75
    # Store the NetworkManager widget
76
    # @param _key [String] id of the widget
77
    # @param _event [Hash] the event being handled
78
    def ManagedStore(_key, _event)
1✔
79
      new_backend = UI.QueryWidget(Id(:managed), :Value)
×
80

81
      Lan.yast_config.backend = new_backend.to_sym
×
82

83
      if Lan.system_config.backend != Lan.yast_config.backend &&
×
84
          (Stage.normal && Lan.yast_config&.backend?(:network_manager))
×
85
        Popup.AnyMessage(
×
86
          _("Applet needed"),
87
          _(
88
            "NetworkManager is controlled by desktop applet\n" \
89
            "(KDE plasma widget and nm-applet for GNOME).\n" \
90
            "Be sure it's running and if not, start it manually."
91
          )
92
        )
93
      end
94

UNCOV
95
      nil
×
96
    end
97

98
    def ManagedHandle(_key, _event)
1✔
99
      selected_service = UI.QueryWidget(Id(:managed), :Value)
×
100

101
      # Disable / enable all widgets which depends on network service
102
      # in the Managed dialog
103
      # See include/network/lan/dhcp.rb for referenced widgets
104
      [:clientid, :hostname, :no_defaultroute].each do |i|
×
105
        UI.ChangeWidget(Id(i), :Enabled, selected_service == "wicked")
×
106
      end
107

UNCOV
108
      nil
×
109
    end
110

111
    def managed_widget
1✔
UNCOV
112
      {
×
113
        "widget"        => :custom,
114
        "custom_widget" => Frame(
115
          _("General Network Settings"),
116
          Left(
117
            ComboBox(
118
              Id(:managed),
119
              Opt(:hstretch, :notify),
120
              _("Network Setup Method"),
121
              []
122
            )
123
          )
124
        ),
125
        "opt"           => [],
126
        "help"          => @help["managed"] || "",
127
        "init"          => fun_ref(method(:ManagedInit), "void (string)"),
128
        "handle"        => fun_ref(method(:ManagedHandle), "symbol (string, map)"),
129
        "store"         => fun_ref(method(:ManagedStore), "void (string, map)")
130
      }
131
    end
132

133
    def initIPv6(_key)
1✔
134
      UI.ChangeWidget(Id(:ipv6), :Value, Lan.ipv6 ? true : false)
×
135

UNCOV
136
      nil
×
137
    end
138

139
    def handleIPv6(_key, event)
1✔
140
      if Ops.get_string(event, "EventReason", "") == "ValueChanged"
×
141
        Lan.SetIPv6(Convert.to_boolean(UI.QueryWidget(Id(:ipv6), :Value)))
×
142
      end
UNCOV
143
      nil
×
144
    end
145

146
    def storeIPv6(_key, _event)
1✔
147
      if Convert.to_boolean(UI.QueryWidget(Id(:ipv6), :Value))
×
148
        Lan.SetIPv6(true)
×
149
      else
150
        Lan.SetIPv6(false)
×
151
      end
152

UNCOV
153
      nil
×
154
    end
155

156
    def ipv6_widget
1✔
UNCOV
157
      {
×
158
        "widget"        => :custom,
159
        "custom_widget" => Frame(
160
          _("IPv6 Protocol Settings"),
161
          Left(CheckBox(Id(:ipv6), Opt(:notify), _("Enable IPv6")))
162
        ),
163
        "opt"           => [],
164
        "help"          => Ops.get_string(@help, "ipv6", ""),
165
        "init"          => fun_ref(method(:initIPv6), "void (string)"),
166
        "handle"        => fun_ref(
167
          method(:handleIPv6),
168
          "symbol (string, map)"
169
        ),
170
        "store"         => fun_ref(method(:storeIPv6), "void (string, map)")
171
      }
172
    end
173
  end
174
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc