Class: Y2Network::Widgets::DeleteInterface

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

Instance Method Summary collapse

Constructor Details

#initialize(table) ⇒ DeleteInterface

Returns a new instance of DeleteInterface.

Parameters:


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

def initialize(table)
  textdomain "network"
  @table = table
end

Instance Method Details

#handleObject


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'src/lib/y2network/widgets/delete_interface.rb', line 46

def handle
  config = Yast::Lan.yast_config
  connection_config = config.connections.by_name(@table.value)
  return nil unless connection_config # unconfigured physical device. Delete do nothing

  if connection_config.startmode.name == "nfsroot"
    if !Yast::Popup.YesNoHeadline(
      Yast::Label.WarningMsg,
      _("Device you select has STARTMODE=nfsroot. Really delete?")
    )
      return nil
    end
  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


79
80
81
82
83
84
85
86
# File 'src/lib/y2network/widgets/delete_interface.rb', line 79

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

#initObject

See Also:

  • CWM::AbstractWidget#init

42
43
44
# File 'src/lib/y2network/widgets/delete_interface.rb', line 42

def init
  disable unless @table.value
end

#labelObject


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

def label
  Yast::Label.DeleteButton
end