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


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


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
68
69
70
71
72
73
# File 'src/lib/y2network/widgets/delete_interface.rb', line 41

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

#labelObject


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

def label
  Yast::Label.DeleteButton
end