Skip to content

Commit

Permalink
Merge pull request #1037 from yast/networking_summary
Browse files Browse the repository at this point in the history
Added new presenters for the config and proposal summaries (bsc#1162796)
  • Loading branch information
teclator committed Feb 10, 2020
2 parents 7dedd62 + c583dee commit e15aac1
Show file tree
Hide file tree
Showing 19 changed files with 644 additions and 360 deletions.
7 changes: 7 additions & 0 deletions package/yast2-network.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri Feb 7 15:50:13 UTC 2020 - Knut Anderssen <kanderssen@suse.com>

- Fix the installation proposal text reflecting the network
configuration changes (bsc#1162796)
- 4.2.53

-------------------------------------------------------------------
Thu Feb 6 15:48:23 UTC 2020 - Knut Anderssen <kanderssen@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-network.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-network
Version: 4.2.52
Version: 4.2.53
Release: 0
Summary: YaST2 - Network Configuration
License: GPL-2.0-only
Expand Down
19 changes: 12 additions & 7 deletions src/lib/network/clients/network_proposal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
require "cgi"
require "installation/proposal_client"
require "y2network/proposal_settings"
require "y2network/presenters/summary"

module Yast
# Proposal client for Network configuration
Expand Down Expand Up @@ -53,7 +54,7 @@ def description
def make_proposal(_)
{
"preformatted_proposal" => preformatted_proposal,
"label_proposal" => [Yast::LanItems.summary("one_line")],
"label_proposal" => [proposal_summary.one_line_text],
"links" => BACKEND_LINKS
}
end
Expand All @@ -74,11 +75,19 @@ def ask_user(args)

private

def config
Yast::Lan.yast_config
end

def proposal_summary
@proposal_summary ||= Y2Network::Presenters::Summary.for(config, "proposal")
end

def preformatted_proposal
return lan_summary unless settings.network_manager_available?
return proposal_summary.text unless settings.network_manager_available?

proposal_text = switch_backend_link
proposal_text.prepend(lan_summary) if wicked_backend?
proposal_text.prepend(proposal_summary.text) if wicked_backend?
proposal_text
end

Expand Down Expand Up @@ -131,10 +140,6 @@ def Hyperlink(href, text)
end
end

def lan_summary
Yast::Lan.Summary("proposal")
end

def settings
Y2Network::ProposalSettings.instance
end
Expand Down
152 changes: 0 additions & 152 deletions src/lib/network/lan_items_summary.rb

This file was deleted.

13 changes: 11 additions & 2 deletions src/lib/y2network/connection_config/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,19 @@ def find_master(configs)
end
end

# Return whether the connection is configured using the dhcp protocol or not
#
# @return [Boolean] true when using dhcp; false otherwise
def dhcp?
return false unless bootproto
bootproto ? bootproto.dhcp? : false
end

bootproto.dhcp?
# Return whether the connection is configured using a fixed IPADDR
#
# @return [Boolean] true when static protocol is used or not defined
# bootpro; false otherwise
def static?
bootproto ? bootproto.static? : true
end

private
Expand Down
62 changes: 62 additions & 0 deletions src/lib/y2network/presenters/config_summary.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Copyright (c) [2020] 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 "yast"

module Y2Network
module Presenters
# This class is responsible of creating text summaries for the given
# Y2Network::Config.
class ConfigSummary
# @return [Y2Network::Config]
attr_reader :config

# Constructor
#
# @param config [Y2Network::Config]
def initialize(config)
@config = config
end

# Network config RichText summary
#
# @return [String]
def text
"#{interfaces_summary.text}#{dns_summary.text}#{routing_summary.text}"
end

private

# Convenicente method to obtain the current config interfaces summary
def interfaces_summary
@interfaces_summary ||= Summary.for(config, "interfaces")
end

# Convenicente method to obtain the current config routing summary
def routing_summary
@routing_summary ||= Summary.for(config, "routing")
end

# Convenicente method to obtain the current config dns summary
def dns_summary
@dns_summary ||= Summary.for(config, "dns")
end
end
end
end

0 comments on commit e15aac1

Please sign in to comment.