Skip to content

Commit

Permalink
Add help text to disk selection dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Nov 27, 2017
1 parent ccecf5d commit da492e2
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
19 changes: 17 additions & 2 deletions src/lib/autoinstall/dialogs/disk_selector.rb
Expand Up @@ -37,15 +37,18 @@ class DiskSelector < UI::Dialog
attr_reader :devicegraph
# @return [Array<String>] Device names that should be omitted
attr_reader :blacklist
# @return [Integer] Drive section index
attr_reader :drive_index

# Constructor
#
# @param devicegraph [Y2Storage::Devicegraph] Devicegraph used to find disks.
# By default, the probed devicegraph is used.
# @param blacklist [Array<String>] Device names that should be omitted.
# These disks will be filtered out.
def initialize(devicegraph = nil, blacklist: [])
def initialize(devicegraph = nil, drive_index: 1, blacklist: [])
@devicegraph = devicegraph || Y2Storage::StorageManager.instance.probed
@drive_index = drive_index
@blacklist = blacklist
end

Expand All @@ -63,11 +66,15 @@ def dialog_content
# @return [Yast::Term] Dialog content
def disks_content
VBox(
Label(_("Choose a hard disk")),
Heading(_("Disk Selection")),
VSpacing(1),
Label(help_text),
VSpacing(1),
RadioButtonGroup(
Id(:options),
VBox(*options)
),
VSpacing(1),
ButtonBox(*buttons)
)
end
Expand Down Expand Up @@ -140,6 +147,14 @@ def abort_button
def label(disk)
"#{disk.basename}, #{disk.hwinfo.model}"
end

# Help text
def help_text
# TRANSLATORS: %s will be replaced by a number
_("All hard disks automatically detected on your system are shown here.\n" \
"Please, select a hard disk to be used in the #%s drive section of the\n" \
"given AutoYaST profile.") % drive_index
end
end
end
end
Expand Down
10 changes: 6 additions & 4 deletions src/lib/autoinstall/partitioning_preprocessor.rb
Expand Up @@ -52,9 +52,9 @@ def run(drives)
# @return [Array<Hash>] Drives definition replacing +ask+ for user selected values
def replace_ask(drives)
blacklist = []
drives.each do |drive|
drives.each_with_index do |drive, idx|
next unless drive["device"] == "ask"
selection = select_disk(blacklist)
selection = select_disk(idx, blacklist)
return nil if selection == :abort
drive["device"] = selection
blacklist << drive["device"]
Expand All @@ -65,8 +65,10 @@ def replace_ask(drives)
#
# @param blacklist [Array<String>] List of device names that were already used
# @return [String,Symbol] Selected device name
def select_disk(blacklist)
Y2Autoinstallation::Dialogs::DiskSelector.new(blacklist: blacklist).run
def select_disk(drive_index, blacklist)
Y2Autoinstallation::Dialogs::DiskSelector.new(
drive_index: drive_index, blacklist: blacklist
).run
end
end
end
14 changes: 14 additions & 0 deletions test/lib/dialogs/disk_selector_test.rb
Expand Up @@ -94,6 +94,20 @@
dialog.dialog_content
end
end

it "contains help text" do
expect(dialog).to receive(:Label).with(/All hard disks.*the #1 drive/m)
dialog.dialog_content
end

context "when a drive index is specified" do
subject(:dialog) { described_class.new(devicegraph, drive_index: 2) }

it "is included in the help text" do
expect(dialog).to receive(:Label).with(/All hard disks.*the #2 drive/m)
dialog.dialog_content
end
end
end

describe "#run" do
Expand Down

0 comments on commit da492e2

Please sign in to comment.