Skip to content

Commit

Permalink
Implement all-in-one overview for CASP/CaaSP (FATE#322328)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvidner committed Jan 25, 2017
1 parent bd0438c commit d8c0637
Show file tree
Hide file tree
Showing 5 changed files with 332 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Makefile.am
Expand Up @@ -23,6 +23,7 @@ client_DATA = \
clients/installation.rb \
clients/installation_settings_finish.rb \
clients/inst_ask_online_update.rb \
clients/inst_casp_overview.rb \
clients/inst_complex_welcome.rb \
clients/inst_congratulate.rb \
clients/inst_deploy_image.rb \
Expand Down Expand Up @@ -150,6 +151,7 @@ ylibclient_DATA = \
lib/installation/clients/installation.rb \
lib/installation/clients/installation_settings_finish.rb \
lib/installation/clients/inst_ask_online_update.rb \
lib/installation/clients/inst_casp_overview.rb \
lib/installation/clients/inst_complex_welcome.rb \
lib/installation/clients/inst_congratulate.rb \
lib/installation/clients/inst_deploy_image.rb \
Expand Down Expand Up @@ -207,6 +209,11 @@ ylibdialog_DATA = \
lib/installation/dialogs/ssh_import.rb \
lib/installation/dialogs/worker_role.rb

ylibwidgetdir = "${yast2dir}/lib/installation/widgets"
ylibwidget_DATA = \
lib/installation/widgets/mocked.rb \
lib/installation/widgets/system_role.rb

EXTRA_DIST = $(module_DATA) $(client_DATA) $(ynclude_DATA) $(scrconf_DATA) $(schemafiles_DATA) $(desktop_DATA) $(fillup_DATA) $(ylibdialog_DATA) $(ylib_DATA) $(ylibtransfer_DATA)

include $(top_srcdir)/Makefile.am.common
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
134 changes: 134 additions & 0 deletions src/lib/installation/clients/inst_casp_overview.rb
@@ -0,0 +1,134 @@
# 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 "installation/widgets/system_role"
# FIXME: prototype only
require "installation/widgets/mocked"

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 "Mode"
Yast.import "CWM"

textdomain "installation"

# 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?

Yast::Wizard.SetTitleIcon("yast-users") # ?
Yast::Wizard.EnableAbortButton

# FIXME: where in the CaaSP workflow do we set the real thing?
fake_release_notes = {
# product name => notes (rich text)
"CaaaaaaaSP!" => "<p>These are the <i>fake</i> release notes.</p>"
}
Yast::UI.SetReleaseNotes(fake_release_notes)
# FIXME: This is copied from inst_complex_welcome
# and may be superfluous here. We will find out once we integrate
# this dialog in the workflow.
Yast::Wizard.ShowReleaseNotesButton(_("Re&lease Notes..."), "rel_notes")

ret = Yast::CWM.show(
content,
# Title for installation overview dialog
caption: _("Installation Overview"),
# Button label: start the installation
next_button: _("Install")
)

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 UI widget-set for the dialog
def content
quadrant_layout(
upper_left: VBox(
::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,
Tune::Widgets::SystemInformation.new
),
upper_right: VBox(
::Widgets::PartitioningOverview.new,
::Widgets::BootloaderOverview.new
),
lower_right: VBox(
::Widgets::NetworkOverview.new,
::Widgets::KdumpOverview.new
)
)
end

# Returns whether we need/ed to create new UI Wizard
def separate_wizard_needed?
Yast::Mode.normal
end
end
end
136 changes: 136 additions & 0 deletions src/lib/installation/widgets/mocked.rb
@@ -0,0 +1,136 @@
require "yast"
require "cwm/widget"

# FIXME: these are mock only

# move this to: yast2-registration
module Widgets
class RegistrationCode < CWM::InputField
def initialize
textdomain "FIXME"
end

def label
_("Registration Code or SMT Server URL")
end
end
end

module Widgets
class Overview < CWM::CustomWidget
def contents
VBox(
Left(PushButton(Id(button_id), label)),
* items.map { |i| Left(Label(" * #{i}")) }
)
end

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

def items
d = Yast::WFM.CallFunction(proposal_client,
[
"MakeProposal",
{"cramped_label_mode" => true}
])
d["label_proposal"]
end

def handle(_event)
Yast::WFM.CallFunction(proposal_client, ["AskUser", {}])
# FIXME: refresh the summary items
nil
end

private

def button_id
self.class.to_s
end
end

class PartitioningOverview < Overview
def initialize
textdomain "storage"
end

def proposal_client
"partitions_proposal"
end

def label
# FIXME: The storage subsystem is locked by an unknown app...
if ENV["FAKE_STORAGE"]
"&Partitioning"
else
super
end
end

def items
if ENV["FAKE_STORAGE"]
["Standard"]
else
super
end
end
end

class BootloaderOverview < Overview
def initialize
textdomain "bootloader"

Yast.import "Bootloader"
end

def proposal_client
"bootloader_proposal"
end

def label
_("Booting")
end

def items
# FIXME: it returns richtext
Yast::Bootloader.Summary
end
end

class NetworkOverview < Overview
def initialize
textdomain "network"
Yast.import "Lan"
end

def label
_("&Network")
end

def items
Yast::Lan.Summary("")
end

def handle(event)
Yast::WFM.CallFunction("inst_lan", [{"skip_detection" => true}])
# FIXME: refresh the summary items
nil
end

end

class KdumpOverview < Overview
def initialize
textdomain "kdump"

Yast.import "Kdump"
end

def proposal_client
"kdump_proposal"
end
end
end
53 changes: 53 additions & 0 deletions src/lib/installation/widgets/system_role.rb
@@ -0,0 +1,53 @@
# 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"

module Installation
module Widgets
# TODO: steal / refactor Installation::SelectSystemRole
# from src/lib/installation/select_system_role.rb
class SystemRole < CWM::ComboBox
def initialize
textdomain "installation"
end

def label
_("System Role")
end

def opt
[:hstretch]
end

def items
[
# FIXME: still hardcoding for easier testing
["foo", _("Adminstration Dashboard")],
["bar", _("Worker")],
["baz", _("Plain System")],
["qux", _("FIXME use real data")]
]
end
end
end
end

0 comments on commit d8c0637

Please sign in to comment.