Skip to content

Commit

Permalink
Merge 53e75d0 into dcc567c
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Aug 27, 2019
2 parents dcc567c + 53e75d0 commit 058679e
Show file tree
Hide file tree
Showing 21 changed files with 877 additions and 394 deletions.
176 changes: 0 additions & 176 deletions src/lib/network/edit_nic_name.rb

This file was deleted.

96 changes: 96 additions & 0 deletions src/lib/y2network/dialogs/rename_interface.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Copyright (c) [2019] SUSE LLC
#
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2 of the GNU General Public License as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, contact SUSE LLC.
#
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

require "cwm/popup"
require "y2network/widgets/custom_interface_name"
require "y2network/widgets/rename_hwinfo"

module Y2Network
module Dialogs
# This dialog allows the user to rename a network interface
#
# Is works in a slightly different way depending on the interface.
#
# * For physical interfaces, it allows the user to select between using
# the MAC adddress or the Bus ID, which are present in the Hwinfo object
# associated to the interface.
# * For not connected interfaces ({FakeInterface}), as the hardware is not present,
# the user must specify the MAC or the Bus ID by hand (NOT IMPLEMENTED YET).
# * For virtual interfaces, like bridges, only the name can be chaned (no hardware
# info at all) (NOT IMPLEMENTED YET).
class RenameInterface < CWM::Popup
def initialize(builder)
textdomain "network"

@builder = builder
@old_name = interface.name
end

# Runs the dialog
def run
ret = super
return unless ret == :ok
renaming_mechanism = rename_hwinfo_widget.value unless virtual_interface?
@builder.rename_interface(name_widget.value, renaming_mechanism)
name_widget.value
end

# @see CWM::CustomWidget
def contents
VBox(
Left(name_widget),
*hardware_info
)
end

private

# Elements to display the hardware information
def hardware_info
virtual_interface? ? [Empty()] : [VSpacing(0.5), rename_hwinfo_widget]
end

# Interface's name widget
#
# @return [Y2Network::Widgets::CustomInterfaceName]
def name_widget
@name_widget ||= Y2Network::Widgets::CustomInterfaceName.new(@builder)
end

# Widget to select the hardware information to base the rename on
#
# @return [Y2Network::Widgets::RenameHwinfo]
def rename_hwinfo_widget
@rename_hwinfo_widget ||= Y2Network::Widgets::RenameHwinfo.new(@builder)
end

# Returns the interface
#
# @return [Y2Network::Interface]
def interface
@builder.interface
end

# Determines whether it is a virtual interface
def virtual_interface?
interface.is_a?(Y2Network::VirtualInterface)
end
end
end
end
Loading

0 comments on commit 058679e

Please sign in to comment.