/
inst_casp_overview.rb
158 lines (142 loc) · 4.95 KB
/
inst_casp_overview.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# 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/overview"
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 "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
content, blocking_widgets = content_and_blocking_widgets
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]
)
blocker = blocking_widgets.find(&:blocking?)
if blocker
# %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.") %
blocker.label.delete("&")
)
next
end
break if ret != :redraw
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_and_blocking_widgets
dashboard = Installation::Widgets::DashboardPlace.new
partitions = Installation::Widgets::Overview.new(client: "partitions_proposal")
bootloader = Installation::Widgets::Overview.new(client: "bootloader_proposal")
network = Installation::Widgets::Overview.new(client: "network_proposal")
kdump = Installation::Widgets::Overview.new(client: "kdump_proposal")
blocking = [partitions, bootloader, network, kdump]
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(dashboard),
dashboard,
Tune::Widgets::SystemInformation.new
),
upper_right: VBox(
partitions,
bootloader
),
lower_right: VBox(
network,
kdump,
Installation::Widgets::InvisibleSoftwareOverview.new
)
)
[content, blocking]
end
# Returns whether we need/ed to create new UI Wizard
def separate_wizard_needed?
Yast::Mode.normal
end
end
end