Skip to content

Commit

Permalink
Merge pull request #994 from yast/kill-dead-code
Browse files Browse the repository at this point in the history
Remove no longer used extra warning
  • Loading branch information
dgdavid committed Nov 25, 2021
2 parents dc16faa + 666ac0d commit 0b9015b
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 116 deletions.
7 changes: 7 additions & 0 deletions package/yast2-installation.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Nov 24 15:13:23 UTC 2021 - David Diaz <dgonzalez@suse.com>

- Remove no longer used extra warning about destructive actions
before starting the installation process (related to bsc#1057437).
- 4.4.23

-------------------------------------------------------------------
Fri Nov 12 14:08:02 UTC 2021 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-installation.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-installation
Version: 4.4.22
Version: 4.4.23
Release: 0
Summary: YaST2 - Installation Parts
License: GPL-2.0-only
Expand Down
169 changes: 58 additions & 111 deletions src/include/installation/misc.rb
@@ -1,38 +1,21 @@
# encoding: utf-8

# ------------------------------------------------------------------------------
# Copyright (c) 2006-2012 Novell, Inc. All Rights Reserved.
# Copyright (c) [2006-2021] 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 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.
# 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 Novell, Inc.
#
# To contact Novell about this file by physical or electronic mail, you may find
# current contact information at www.novell.com.
# ------------------------------------------------------------------------------

# File:
# include/installation/misc.ycp
#
# Module:
# System installation
#
# Summary:
# Miscelaneous functions
#
# Authors:
# Jiri Srain <jsrain@suse.cz>
#
# $Id$
# 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 "shellwords"

Expand All @@ -52,11 +35,6 @@ def initialize_installation_misc(_include_target)
Yast.import "Linuxrc"
Yast.import "InstData"
Yast.import "HTML"
# storage-ng
# rubocop:disable Style/BlockComments
=begin
Yast.import "Storage"
=end

@modules_to_enable_with_AC_on = nil
end
Expand Down Expand Up @@ -84,84 +62,12 @@ def UpdateWizardSteps
nil
end

# moved from clients/inst_doit.ycp
# to fix bug #219097

# Confirm installation or update.
# Returns 'true' if the user confirms, 'false' otherwise.
# Confirm installation or update
#
# @note moved from clients/inst_doit.ycp to fix bug #219097
#
# @return [Booelan] true if the user confirms; false otherwise
def confirmInstallation
heading = ""
body = ""
confirm_button_label = ""

if !Mode.update
# Heading for confirmation popup before the installation really starts
heading = HTML.Heading(_("Confirm Installation"))

# Text for confirmation popup before the installation really starts 1/3
body = _(
"<p>Information required for the base installation is now complete.</p>"
)

# storage-ng
some_destructive = false
=begin
some_destructive = Storage.GetCommitInfos.any? do |info|
Ops.get_boolean(info, :destructive, false)
end
=end

if some_destructive
# Text for confirmation popup before the installation really starts 2/3
body = Ops.add(
body,
_(
"<p>If you continue now, <b>existing\n" \
"partitions</b> on your hard disk will be <b>deleted</b> or <b>formatted</b>\n" \
"(<b>erasing any existing data</b> in those partitions) according to the\n" \
"installation settings in the previous dialogs.</p>"
)
)
else
# Text for confirmation popup before the installation really starts 2/3
body = Ops.add(
body,
_(
"<p>If you continue now, partitions on your\n" \
"hard disk will be modified according to the installation settings in the\n" \
"previous dialogs.</p>"
)
)
end

# Text for confirmation popup before the installation really starts 3/3
body = Ops.add(
body,
_("<p>Go back and check the settings if you are unsure.</p>")
)

confirm_button_label = Label.InstallButton
else
# Heading for confirmation popup before the update really starts
heading = HTML.Heading(_("Confirm Update"))

body =
# Text for confirmation popup before the update really starts 1/3
_("<p>Information required to perform an update is now complete.</p>") +
# Text for confirmation popup before the update really starts 2/3
_(
"\n" \
"<p>If you continue now, data on your hard disk will be overwritten\n" \
"according to the settings in the previous dialogs.</p>"
) +
# Text for confirmation popup before the update really starts 3/3
_("<p>Go back and check the settings if you are unsure.</p>")

# Label for the button that confirms startint the installation
confirm_button_label = _("Start &Update")
end

display_info = UI.GetDisplayInfo
size_x = Builtins.tointeger(Ops.get_integer(display_info, "Width", 800))
size_y = Builtins.tointeger(Ops.get_integer(display_info, "Height", 600))
Expand All @@ -183,7 +89,7 @@ def confirmInstallation
HBox(
HSpacing(0.7),
VSpacing(size_y), # force height
RichText(heading + body),
RichText(Mode.update ? confirm_update_text : confirm_installation_text),
HSpacing(0.7)
),
ButtonBox(
Expand All @@ -203,6 +109,47 @@ def confirmInstallation
button == :ok
end

# Text for confirmation popup before the installation really starts
#
# @return [String]
def confirm_installation_text
result = ""

result << HTML.Heading(_("Confirm Installation"))
result << _("<p>Information required for the base installation is now complete.</p>")
result << _(
"<p>If you continue now, partitions on your\n" \
"hard disk will be modified according to the installation settings in the\n" \
"previous dialogs.</p>"
)
result << _(
"<p>Go back and check the settings if you are unsure.</p>"
)
end

# Text for confirmation popup before the update really starts
#
# @return [String]
def confirm_update_text
result = ""

result << HTML.Heading(_("Confirm Update"))
result << _("<p>Information required to perform an update is now complete.</p>")
result << _(
"\n" \
"<p>If you continue now, data on your hard disk will be overwritten\n" \
"according to the settings in the previous dialogs.</p>"
)
result << _("<p>Go back and check the settings if you are unsure.</p>")
end

# Label for the confirmation button before starting the installation or update process
#
# @return [String]
def confirm_button_label
Mode.update ? _("Start &Update") : Label.InstallButton
end

# Some client calls have to be called even if using AC
def EnableRequiredModules
# Lazy init
Expand Down
76 changes: 72 additions & 4 deletions test/installation_misc_test.rb
@@ -1,13 +1,81 @@
#! /usr/bin/env rspec

# Copyright (c) [2015-2021] 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_relative "./test_helper"
require_relative "../src/include/installation/misc"

# a testing class for includign the "misc" include
class InstallationMiscIncludeTest
include Yast::InstallationMiscInclude
Yast.import "UI"
Yast.import "Mode"

# A dummy class for testing the "misc" include
class InstallationMiscIncludeTest < Yast::Client
include Yast::I18n

def initialize
Yast.include self, "installation/misc.rb"
end
end

describe Yast::InstallationMiscInclude do
pending
subject { InstallationMiscIncludeTest.new }

RSpec.shared_examples "confirmation dialog" do
it "displays proper heading, text, and confirmation label" do
expect(Yast::UI).to receive(:OpenDialog) do |term|
content = term.nested_find { |e| e.is_a?(Yast::Term) && e.value == :RichText }

confirm_button = term.nested_find do |e|
e.is_a?(Yast::Term) && e.value == :PushButton && e.params.include?(confirm_label)
end

expect(content.params).to include(/#{heading}/)
expect(content.params).to include(/#{body_fragment}/)
expect(confirm_button).to_not be_nil
end

subject.confirmInstallation
end
end

describe "#confirmInstallation" do
before do
allow(Yast::Mode).to receive(:update).and_return(update_mode)
end

context "when performing an installation" do
let(:update_mode) { false }
let(:heading) { "<h3>Confirm Installation</h3>" }
let(:body_fragment) { "partitions on your\nhard disk will be modified" }
let(:confirm_label) { "&Install" }

include_examples "confirmation dialog"
end

context "when performing an update" do
let(:update_mode) { true }
let(:heading) { "<h3>Confirm Update</h3>" }
let(:body_fragment) { "data on your hard disk will be overwritten" }
let(:confirm_label) { "Start &Update" }

include_examples "confirmation dialog"
end
end
end

0 comments on commit 0b9015b

Please sign in to comment.