Skip to content

Commit

Permalink
Merge pull request #507 from yast/aio-master
Browse files Browse the repository at this point in the history
Implement all-in-one overview for CASP/CaaSP (FATE#322328) (CASP->master)
  • Loading branch information
mvidner committed Jan 31, 2017
2 parents b570847 + ff6e5fb commit 5ae24ff
Show file tree
Hide file tree
Showing 10 changed files with 565 additions and 8 deletions.
23 changes: 23 additions & 0 deletions package/yast2-installation.changes
@@ -1,3 +1,26 @@
-------------------------------------------------------------------
Fri Jan 27 15:55:33 UTC 2017 - kanderssen@suse.com

- Ask for installation confirmation in all-in-one dialog before
proceed with it. (Fate#322328)
- 3.2.18

-------------------------------------------------------------------
Fri Jan 27 09:11:32 UTC 2017 - jreidinger@suse.com

- Respect newly registered update repos in software proposal and
do register. (FATE#322328)

-------------------------------------------------------------------
Thu Jan 26 14:16:43 UTC 2017 - jreidinger@suse.com

- handle proposal errors in all-in-one dialog (FATE#322328)

-------------------------------------------------------------------
Wed Jan 25 15:29:02 UTC 2017 - mvidner@suse.com

- Added an all-in-one installation overview for CaaSP (FATE#322328)

-------------------------------------------------------------------
Wed Jan 25 10:41:33 UTC 2017 - igonzalezsosa@suse.com

Expand Down
16 changes: 8 additions & 8 deletions package/yast2-installation.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-installation
Version: 3.2.17
Version: 3.2.18
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down Expand Up @@ -82,11 +82,11 @@ Requires: yast2-network >= 3.1.143
# Requires: yast2-update

# new root password cwm widget
Requires: yast2-users >= 3.2.7
# new keyboard layout cwm widget needed only for CASP, so use version that works
# also for SP3
# FIXME: update dependency when CASP is merged to SP2 and SP3 for yast2-country
Requires: yast2-country >= 3.1.30
BuildRequires: yast2-users >= 3.2.8
Requires: yast2-users >= 3.2.8
# new keyboard layout cwm widget
BuildRequires: yast2-country >= 3.2.7
Requires: yast2-country >= 3.2.7

# Pkg::SourceProvideSignedFile Pkg::SourceProvideDigestedFile
# pkg-bindings are not directly required
Expand All @@ -104,8 +104,8 @@ Conflicts: yast2-core < 2.17.10
# Top bar with logo
Conflicts: yast2-ycp-ui-bindings < 3.1.7

# RegserviceSelectionDialog
Conflicts: yast2-registration < 3.1.179
# new registration widget
Conflicts: yast2-registration <= 3.2.1

Obsoletes: yast2-installation-devel-doc

Expand Down
2 changes: 2 additions & 0 deletions src/clients/inst_casp_overview.rb
@@ -0,0 +1,2 @@
require "installation/clients/inst_casp_overview"
::Installation::InstCaspOverview.new.run
156 changes: 156 additions & 0 deletions src/lib/installation/clients/inst_casp_overview.rb
@@ -0,0 +1,156 @@
# encoding: utf-8

# ------------------------------------------------------------------------------
# Copyright (c) 2017 SUSE LLC
#
#
# 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.
#
# To contact SUSE about this file by physical or electronic mail, you may find
# current contact information at www.suse.com.
# ------------------------------------------------------------------------------

require "users/widgets"
require "y2country/widgets"
require "ui/widgets"
require "tune/widgets"
require "registration/widgets/registration_code"

require "installation/widgets/overview"
require "installation/widgets/system_role"

module Installation
# This library provides a simple dialog for setting
# - the password for the system administrator (root)
# - the keyboard layout
# This dialog does not write the password to the system,
# only stores it in UsersSimple module,
# to be written during inst_finish.
class InstCaspOverview
include Yast::Logger
include Yast::I18n
include Yast::UIShortcuts

def run
Yast.import "UI"
Yast.import "Language"
Yast.import "Mode"
Yast.import "CWM"
Yast.import "Popup"
Yast.import "Pkg"

textdomain "installation"

# Simplified work-flow do not contain language proposal, but have software one.
# So avoid false positive detection of language change
Yast::Pkg.SetPackageLocale(Yast::Language.language)

# We do not need to create a wizard dialog in installation, but it's
# helpful when testing all manually on a running system
Yast::Wizard.CreateDialog if separate_wizard_needed?

ret = nil
loop do
ret = Yast::CWM.show(
content,
# Title for installation overview dialog
caption: _("Installation Overview"),
# Button label: start the installation
next_button: _("Install"),
# do not show abort and back button
abort_button: "",
back_button: "",
# do not store stuff when just redrawing
skip_store_for: [:redraw]
)
next if ret == :redraw

# do software proposal
d = Yast::WFM.CallFunction("software_proposal",
[
"MakeProposal",
{ "simple_mode" => true }
])
# report problems with sofware proposal
if [:blocker, :fatal].include?(d["warning_level"])
# %s is a problem description
Yast::Popup.Error(
_("Software proposal failed. Cannot proceed with installation.\n%s") % d["warning"]
)
# continue only if confirmed
elsif Yast::WFM.CallFunction("inst_doit", []) == :next
break
end
end

Yast::Wizard.CloseDialog if separate_wizard_needed?

ret
end

private

def quadrant_layout(upper_left:, lower_left:, upper_right:, lower_right:)
HBox(
HWeight(
6,
VBox(
VWeight(5, upper_left),
VStretch(),
VWeight(5, lower_left)
)
),
HSpacing(3),
HWeight(
4,
VBox(
VWeight(5, upper_right),
VStretch(),
VWeight(5, lower_right)
)
)
)
end

# Returns a pair with UI widget-set for the dialog and widgets that can
# block installation
def content
dashboard = Installation::Widgets::DashboardPlace.new
quadrant_layout(
upper_left: VBox(
::Registration::Widgets::RegistrationCode.new,
::Users::PasswordWidget.new(little_space: true),
# use english us as default keyboard layout
::Y2Country::Widgets::KeyboardSelectionCombo.new("english-us")
),
lower_left: VBox(
Installation::Widgets::SystemRole.new(dashboard),
dashboard,
Tune::Widgets::SystemInformation.new
),
upper_right: VBox(
Installation::Widgets::Overview.new(client: "partitions_proposal"),
Installation::Widgets::Overview.new(client: "bootloader_proposal")
),
lower_right: VBox(
Installation::Widgets::Overview.new(client: "network_proposal"),
Installation::Widgets::Overview.new(client: "kdump_proposal")
)
)
end

# Returns whether we need/ed to create new UI Wizard
def separate_wizard_needed?
Yast::Mode.normal
end
end
end
112 changes: 112 additions & 0 deletions src/lib/installation/widgets/overview.rb
@@ -0,0 +1,112 @@
# encoding: utf-8

# ------------------------------------------------------------------------------
# Copyright (c) 2017 SUSE LLC
#
#
# 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.
#
# To contact SUSE about this file by physical or electronic mail, you may find
# current contact information at www.suse.com.
# ------------------------------------------------------------------------------

require "yast"
require "cwm/widget"

Yast.import "Popup"

module Installation
module Widgets
# A widget for an all-in-one installation dialog.
# It uses the `simple_mode` of {Installation::ProposalClient#make_proposal}
# It is immutable, so for showing new values reinitialize widget
class Overview < CWM::CustomWidget
attr_reader :proposal_client

# @param client [String] A proposal client implementing simple_mode,
# eg. "bootloader_proposal"
def initialize(client:)
textdomain "installation"
@proposal_client = client
# by default widget_id is the class name; must differentiate instances
self.widget_id = "overview_" + client
@blocking = false
end

def contents
VBox(
Left(PushButton(Id(button_id), label)),
* items.map { |i| Left(Label(" * #{i}")) }
)
end

def label
return @label if @label

d = Yast::WFM.CallFunction(proposal_client, ["Description", {}])
@label = d["menu_title"]
end

def items
return @items if @items

d = Yast::WFM.CallFunction(proposal_client,
[
"MakeProposal",
{ "simple_mode" => true }
])
if d["warning"] && !d["warning"].empty? && d["warning_level"] != :notice
Yast::Popup.LongError(
format(
_("Problem found when proposing %{client}:<br>" \
"Severity: %{severity}<br>" \
"Message: %{message}"),
client: label.delete("&"),
severity: (d["warning_level"] || :warning).to_s,
message: d["warning"]
)
)
@blocking = [:blocker, :fatal].include?(d["warning_level"])
end
@items = d["label_proposal"]
end

def handle(_event)
Yast::WFM.CallFunction(proposal_client, ["AskUser", {}])
:redraw
end

def validate
return true unless @blocking

# %s is a heading of a problematic section, like "Partitioning" or "Network"
Yast::Popup.Error(
_("%s blocks the installation. Please solve the problem there before proceeding.") %
label.delete("&")
)

false
end

def blocking?
@blocking
end

private

def button_id
# an arbitrary unique id
"ask_" + proposal_client
end
end
end
end

0 comments on commit 5ae24ff

Please sign in to comment.