Class: Y2Network::Widgets::DeleteInterface

Inherits:
InterfaceButton
  • Object
show all
Defined in:
src/lib/y2network/widgets/delete_interface.rb

Instance Method Summary collapse

Methods inherited from InterfaceButton

#config, #connection_config, #init, #item, #selected_interface

Constructor Details

#initialize(table) ⇒ DeleteInterface

Constructor

Parameters:



31
32
33
34
# File 'src/lib/y2network/widgets/delete_interface.rb', line 31

def initialize(table)
  textdomain "network"
  super(table)
end

Instance Method Details

#disable?Boolean

Returns:

  • (Boolean)


69
70
71
72
73
74
# File 'src/lib/y2network/widgets/delete_interface.rb', line 69

def disable?
  return true unless @table.value
  return true unless connection_config

  false
end

#handleObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'src/lib/y2network/widgets/delete_interface.rb', line 40

def handle
  return nil unless connection_config # unconfigured physical device. Delete do nothing

  if connection_config.startmode.name == "nfsroot" && !Yast::Popup.YesNoHeadline(
    Yast::Label.WarningMsg,
    _("Device you select has STARTMODE=nfsroot. Really delete?")
  )
    return nil
  end

  others = all_modify(config, connection_config)
  if !others.empty?
    delete, modify = others.partition { |c| c.type.vlan? }
    message = format(_("Device you select has been used in other devices.<br>" \
                       "When deleted these devices will be modified<ul>%s</ul><br>" \
                       "and these devices deleted: <ul>%s</ul><br>" \
                       "Really delete?"),
      modify.map { |m| "<li>#{m.name}</li>" }.join("\n"),
      delete.map { |m| "<li>#{m.name}</li>" }.join("\n"))
    if Yast2::Popup.show(message, richtext: :yes, buttons: :yes_no, headline: :warning) == :no
      return nil
    end
  end

  config.delete_interface(@table.value)

  :redraw
end

#helpObject



76
77
78
79
80
81
82
83
# File 'src/lib/y2network/widgets/delete_interface.rb', line 76

def help
  # TRANSLATORS: Help for 'Delete' interface configuration button.
  _(
    "<p><b><big>Deleting:</big></b><br>\n" \
    "Choose a network card to remove.\n" \
    "Then press <b>Delete</b>.</p>\n"
  )
end

#labelObject



36
37
38
# File 'src/lib/y2network/widgets/delete_interface.rb', line 36

def label
  Yast::Label.DeleteButton
end