Skip to content

Commit

Permalink
Merge pull request #716 from yast/hide_windows
Browse files Browse the repository at this point in the history
Hide windows actions if there are no windows partitions
  • Loading branch information
teclator committed Aug 23, 2018
2 parents e64427d + ac1da26 commit 48812d3
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 95 deletions.
7 changes: 7 additions & 0 deletions package/yast2-storage-ng.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Wed Aug 22 21:45:06 UTC 2018 - knut.anderssen@suse.com

- Partitioner: Hide the "what to do" selector for windows
partitions if there are no windows partitions (bsc#1055646)
- 4.1.9

-------------------------------------------------------------------
Wed Aug 22 16:56:53 CEST 2018 - schubi@suse.de

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-storage-ng.spec
Expand Up @@ -16,7 +16,7 @@
#

Name: yast2-storage-ng
Version: 4.1.8
Version: 4.1.9
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
14 changes: 8 additions & 6 deletions src/lib/y2storage/dialogs/guided_setup/select_root_disk.rb
Expand Up @@ -55,8 +55,7 @@ def dialog_content
VBox(
root_selection_widget,
VSpacing(1),
windows_action_widget,
VSpacing(1),
*(activate_windows_actions? ? [windows_action_widget, VSpacing(1)] : [Empty()]),
linux_delete_mode_widget,
VSpacing(1),
other_delete_mode_widget
Expand Down Expand Up @@ -143,8 +142,7 @@ def initialize_widgets
widget = settings.root_device || :any_disk
widget_update(widget, true)

widget_update(:windows_action, windows_action)
widget_update(:windows_action, activate_windows_actions?, attr: :Enabled)
widget_update(:windows_action, windows_action) if activate_windows_actions?

widget_update(:linux_delete_mode, settings.linux_delete_mode)
widget_update(:linux_delete_mode, activate_linux_delete_mode?, attr: :Enabled)
Expand All @@ -160,6 +158,12 @@ def update_settings!
settings.linux_delete_mode = widget_value(:linux_delete_mode)
settings.other_delete_mode = widget_value(:other_delete_mode)

update_windows_settings if activate_windows_actions?
end

private

def update_windows_settings
case widget_value(:windows_action)
when :not_modify
settings.resize_windows = false
Expand All @@ -176,8 +180,6 @@ def update_settings!
end
end

private

def candidate_disks
return @candidate_disks if @candidate_disks
candidates = settings.candidate_devices || []
Expand Down
7 changes: 7 additions & 0 deletions test/support/guided_setup_context.rb
Expand Up @@ -31,6 +31,13 @@
RSpec.shared_context "guided setup requirements" do
include Yast::UIShortcuts

def term_with_id(regexp, content)
content.nested_find do |nested|
next unless nested.is_a?(Yast::Term)
nested.params.any? { |i| i.is_a?(Yast::Term) && i.value == :id && regexp.match?(i.params.first) }
end
end

def expect_select(id, value = true)
expect(Yast::UI).to receive(:ChangeWidget).once.with(Id(id), :Value, value)
end
Expand Down
179 changes: 91 additions & 88 deletions test/y2storage/dialogs/guided_setup/select_root_disk_test.rb
Expand Up @@ -67,7 +67,7 @@
let(:candidate_disks) { all_disks }

before do
select_widget(:windows_action, :not_modify)
select_widget(:windows_action, :not_modify) unless windows_partitions.empty?
select_widget(:linux_delete_mode, :all)
select_widget(:other_delete_mode, :all)
end
Expand Down Expand Up @@ -125,18 +125,102 @@
context "when no disk has a Windows system" do
let(:windows_partitions) { [] }

it "disables windows actions" do
expect_disable(:windows_action)
subject.run
it "does not show the windows actions" do
widget = term_with_id(/windows_action/, subject.send(:dialog_content))
expect(widget).to be_nil
end
end

context "when some disk has a Windows system" do
let(:windows_partitions) { [partition_double("sda1")] }

it "enables windows actions" do
expect_enable(:windows_action)
subject.run
it "shows the windows actions" do
widget = term_with_id(/windows_action/, subject.send(:dialog_content))
expect(widget).to_not be_nil
end

context "when settings.windows_delete_mode is set to :all" do
let(:windows_partitions) { [partition_double("sda1")] }
before { settings.windows_delete_mode = :all }

it "sets the Windows action to :always_remove" do
expect_select(:windows_action, :always_remove)
subject.run
end
end

context "when settings.windows_delete_mode is set to :ondemand" do
let(:windows_partitions) { [partition_double("sda1")] }
before { settings.windows_delete_mode = :ondemand }

it "sets the Windows action to :remove" do
expect_select(:windows_action, :remove)
subject.run
end
end

context "when settings.windows_delete_mode is set to :none" do
let(:windows_partitions) { [partition_double("sda1")] }
before { settings.windows_delete_mode = :none }

context "and resizing is allowed" do
before { settings.resize_windows = true }

it "sets the Windows action to :resize" do
expect_select(:windows_action, :resize)
subject.run
end
end

context "and resizing is not allowed" do
before { settings.resize_windows = false }

it "sets the Windows action to :not_modify" do
expect_select(:windows_action, :not_modify)
subject.run
end
end
end

context "updating settings regarding Windows" do
context "if :not_modify is selected for Windows action" do
before { select_widget(:windows_action, :not_modify) }

it "updates the settings according" do
subject.run
expect(settings.windows_delete_mode).to eq :none
expect(settings.resize_windows).to eq false
end
end

context "if :resize is selected for Windows action" do
before { select_widget(:windows_action, :resize) }

it "updates the settings according" do
subject.run
expect(settings.windows_delete_mode).to eq :none
expect(settings.resize_windows).to eq true
end
end

context "if :remove is selected for Windows action" do
before { select_widget(:windows_action, :remove) }

it "updates the settings according" do
subject.run
expect(settings.windows_delete_mode).to eq :ondemand
expect(settings.resize_windows).to eq true
end
end

context "if :always_remove is selected for Windows action" do
before { select_widget(:windows_action, :always_remove) }

it "updates the settings according" do
subject.run
expect(settings.windows_delete_mode).to eq :all
end
end
end
end

Expand Down Expand Up @@ -204,87 +288,6 @@
subject.run
end

context "when settings.windows_delete_mode is set to :all" do
before { settings.windows_delete_mode = :all }

it "sets the Windows action to :always_remove" do
expect_select(:windows_action, :always_remove)
subject.run
end
end

context "when settings.windows_delete_mode is set to :ondemand" do
before { settings.windows_delete_mode = :ondemand }

it "sets the Windows action to :remove" do
expect_select(:windows_action, :remove)
subject.run
end
end

context "when settings.windows_delete_mode is set to :none" do
before { settings.windows_delete_mode = :none }

context "and resizing is allowed" do
before { settings.resize_windows = true }

it "sets the Windows action to :resize" do
expect_select(:windows_action, :resize)
subject.run
end
end

context "and resizing is not allowed" do
before { settings.resize_windows = false }

it "sets the Windows action to :not_modify" do
expect_select(:windows_action, :not_modify)
subject.run
end
end
end

context "updating settings regarding Windows" do
context "if :not_modify is selected for Windows action" do
before { select_widget(:windows_action, :not_modify) }

it "updates the settings according" do
subject.run
expect(settings.windows_delete_mode).to eq :none
expect(settings.resize_windows).to eq false
end
end

context "if :resize is selected for Windows action" do
before { select_widget(:windows_action, :resize) }

it "updates the settings according" do
subject.run
expect(settings.windows_delete_mode).to eq :none
expect(settings.resize_windows).to eq true
end
end

context "if :remove is selected for Windows action" do
before { select_widget(:windows_action, :remove) }

it "updates the settings according" do
subject.run
expect(settings.windows_delete_mode).to eq :ondemand
expect(settings.resize_windows).to eq true
end
end

context "if :always_remove is selected for Windows action" do
before { select_widget(:windows_action, :always_remove) }

it "updates the settings according" do
subject.run
expect(settings.windows_delete_mode).to eq :all
end
end
end

describe "updating settings regarding linux partitions" do
context "if :ondemand is selected for linux_delete_mode" do
before { select_widget(:linux_delete_mode, :ondemand) }
Expand Down

0 comments on commit 48812d3

Please sign in to comment.