Skip to content

Commit

Permalink
Merge pull request #613 from yast/polish-new-storage-ui
Browse files Browse the repository at this point in the history
[Storage UI] Fine tuning the interface
  • Loading branch information
dgdavid committed May 19, 2020
2 parents dfc98bc + a9ccf21 commit 86b8d8a
Show file tree
Hide file tree
Showing 25 changed files with 906 additions and 295 deletions.
7 changes: 7 additions & 0 deletions src/lib/autoinstall/presenters/partition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ def drive_type
drive_presenter.type
end

# Whether the section is an LVM Logical Volume
#
# @return [Boolean] true when belongs to an LVM drive; false otherwise
def logical_volume?
drive_type.to_sym == :CT_LVM
end

# Values to suggest for bcache devices fields
#
# @return [Array<String>]
Expand Down
17 changes: 15 additions & 2 deletions src/lib/autoinstall/storage_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ def add_partition
self.section = drive.partitions.last
end

# Removes currently selected section
def delete_section
return unless section

if section.section_name == "drives"
drives.delete(section)
self.section = drives.first
else
section.parent.partitions.delete(section)
self.section = section.parent
end
end

# It determines whether the profile was modified
#
# @todo Implement logic to detect whether the partitioning
Expand All @@ -80,15 +93,15 @@ def drive_presenters
drives.map { |d| Presenters::Drive.new(d) }
end

private

# Drive sections inside the partitioning one
#
# @return [Array<Y2Storage::AutoinstProfile::DriveSection>]
def drives
partitioning.drives
end

private

# Drive section that is currently selected directly or indirectly (ie.
# because one of its partition sections is selected)
#
Expand Down
54 changes: 54 additions & 0 deletions src/lib/autoinstall/widgets/storage/delete_section_button.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright (c) [2020] SUSE LLC
#
# All Rights Reserved.
#
# 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 LLC.
#
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

require "yast"
require "cwm/common_widgets"

module Y2Autoinstallation
module Widgets
module Storage
# Button to remove the selected section
class DeleteSectionButton < CWM::PushButton
# Constructor
#
# @param controller [Y2Autoinstallation::StorageController] UI controller
def initialize(controller)
textdomain "autoinst"
@controller = controller
end

# @macro seeAbstractWidget
def label
_("Delete")
end

# @macro seeAbstractWidget
def handle
controller.delete_section
:redraw
end

private

# @return [Y2Autoinstallation::StorageController]
attr_reader :controller
end
end
end
end
12 changes: 6 additions & 6 deletions src/lib/autoinstall/widgets/storage/disk_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
require "autoinstall/widgets/storage/disk_device"
require "autoinstall/widgets/storage/init_drive"
require "autoinstall/widgets/storage/disk_usage"
require "autoinstall/widgets/storage/partition_table"
require "autoinstall/widgets/storage/disklabel"

module Y2Autoinstallation
module Widgets
Expand All @@ -41,7 +41,7 @@ def widgets
HSquash(MinWidth(15, disk_device_widget)),
init_drive_widget,
disk_usage_widget,
partition_table_widget
disklabel_widget
]
end

Expand All @@ -50,7 +50,7 @@ def init_widgets_values
disk_device_widget.value = drive.device
init_drive_widget.value = !!drive.initialize_attr
disk_usage_widget.value = drive.use
partition_table_widget.value = drive.disklabel
disklabel_widget.value = drive.disklabel
set_disk_usage_status
end

Expand All @@ -60,7 +60,7 @@ def widgets_values
"device" => disk_device_widget.value,
"initialize_attr" => init_drive_widget.value,
"use" => disk_usage_widget.value,
"disklabel" => partition_table_widget.value
"disklabel" => disklabel_widget.value
}
end

Expand All @@ -83,8 +83,8 @@ def disk_usage_widget
end

# Widget for setting the disk partition table
def partition_table_widget
@partition_table_widget ||= PartitionTable.new
def disklabel_widget
@disklabel_widget ||= Disklabel.new
end

# Widget for settings if disk should be initialize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module Storage
# Widget to set the type of partition table to use
#
# It corresponds to the `disklabel` element in the profile.
class PartitionTable < CWM::ComboBox
class Disklabel < CWM::ComboBox
# Constructor
def initialize
textdomain "autoinst"
Expand All @@ -36,7 +36,7 @@ def initialize

# @macro seeAbstractWidget
def label
_("Partition Table")
_("Disklabel")
end

# We are only interested in these types.
Expand Down
94 changes: 94 additions & 0 deletions src/lib/autoinstall/widgets/storage/not_lvm_partition_attrs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Copyright (c) [2020] SUSE LLC
#
# All Rights Reserved.
#
# 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 LLC.
#
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

require "yast"
require "cwm/custom_widget"
require "autoinstall/widgets/storage/partition_id"
require "autoinstall/widgets/storage/partition_type"

module Y2Autoinstallation
module Widgets
module Storage
# Not LVM partitions specific widgets
#
# It holds widgets managing specific attributes for a partition not related to a CT_LVM drive.
#
# @see PartitionGeneralTab
class NotLvmPartitionAttrs < CWM::CustomWidget
# Constructor
#
# @param section [Presenters::Partition] presenter for the partition section
def initialize(section)
textdomain "autoinst"
super()
@section = section
end

# @macro seeAbstractWidget
def label
""
end

# @macro seeCustomWidget
def contents
VBox(
Left(
HBox(
HSquash(MinWidth(15, partition_id_widget)),
HSpacing(2),
partition_type_widget
)
)
)
end

# @macro seeAbstractWidget
def init
partition_id_widget.value = section.partition_id
partition_type_widget.value = section.partition_type
end

# Returns the widgets values
#
# @return [Hash<String,Object>]
def values
{
"partition_id" => partition_id_widget.value,
"partition_type" => partition_type_widget.value
}
end

private

# @return [Presenters::Partition] presenter for the partition section
attr_reader :section

# Widget for setting the partition id
def partition_id_widget
@partition_id_widget ||= PartitionId.new
end

# Widget for setting the partition type
def partition_type_widget
@partition_type_widget ||= PartitionType.new
end
end
end
end
end
32 changes: 31 additions & 1 deletion src/lib/autoinstall/widgets/storage/overview_tree_pager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
require "autoinstall/widgets/storage/partition_page"
require "autoinstall/widgets/storage/add_drive_button"
require "autoinstall/widgets/storage/add_partition_button"
require "autoinstall/widgets/storage/delete_section_button"
require "autoinstall/ui_state"

module Y2Autoinstallation
Expand All @@ -50,7 +51,8 @@ def contents
Left(
HBox(
AddDriveButton.new(controller),
AddPartitionButton.new(controller)
AddPartitionButton.new(controller),
delete_button
)
)
)
Expand All @@ -63,6 +65,13 @@ def items
end
end

# Extends the events management to control the DeleteSectionButton status
def handle(event)
super
set_delete_button_status
nil
end

# Switch to the given page
#
# It redefines the original implementation to save the current
Expand Down Expand Up @@ -91,6 +100,27 @@ def tree
@tree ||= OverviewTree.new(items)
end

# Widget for removing currently selected section
#
# @return [DeleteSectionButton]
def delete_button
@delete_button ||= DeleteSectionButton.new(controller)
end

# Changes the #delete_button status according to selected section
def set_delete_button_status
if drive_selected? && controller.drives.size == 1
delete_button.disable
else
delete_button.enable
end
end

# Whether selected section is a Y2Storage::AutoinstProfileDriveSection
def drive_selected?
controller.section.is_a?(Y2Storage::AutoinstProfile::DriveSection)
end

def controller_page
return nil unless controller.section

Expand Down
Loading

0 comments on commit 86b8d8a

Please sign in to comment.