Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #592 from yast/new-storage-ui-initial
Storage UI: initial steps
- Loading branch information
Showing
28 changed files
with
1,587 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,3 +43,4 @@ package/autoyast2-*.bz2 | |
/.yardoc | ||
/coverage | ||
/test-driver | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
# 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 "cwm" | ||
require "cwm/dialog" | ||
require "autoinstall/widgets/storage/overview_tree_pager" | ||
require "autoinstall/storage_controller" | ||
|
||
Yast.import "Label" | ||
Yast.import "Popup" | ||
|
||
module Y2Autoinstallation | ||
module Dialogs | ||
# Dialog to set up the partition plan | ||
# | ||
# @example Edit a partitioning section | ||
# devicegraph = devicegraph = Y2Storage::StorageManager.instance.probed | ||
# partitioning = Y2Storage::Autoinst::PartitioningSection.new_from_storage(devicegraph) | ||
# result = Y2Autoinstallation::Dialogs::Storage.new.run | ||
# | ||
# @example Start with an empty section | ||
# result = Y2Autoinstallation::Dialogs::Storage.new | ||
class Storage < CWM::Dialog | ||
# @return [Y2Storage::AutoinstProfile::PartitioningSection] | ||
# Partitioning section of the profile | ||
attr_reader :partitioning | ||
|
||
# Constructor | ||
# | ||
# @param partitioning [Y2Storage::AutoinstProfile::PartitioningSection] | ||
# Partitioning section of the profile | ||
def initialize(partitioning = Y2Storage::AutoinstProfile::PartitioningSection.new) | ||
textdomain "autoinst" | ||
@controller = Y2Autoinstallation::StorageController.new(partitioning) | ||
end | ||
|
||
# @macro seeDialog | ||
def contents | ||
MarginBox( | ||
0.5, | ||
0.5, | ||
Y2Autoinstallation::Widgets::Storage::OverviewTreePager.new(controller) | ||
) | ||
end | ||
|
||
# @macro seeDialog | ||
def next_button | ||
Yast::Label.FinishButton | ||
end | ||
|
||
# @macro seeDialog | ||
def abort_button | ||
"" | ||
end | ||
|
||
# @macro seeDialog | ||
def back_button | ||
Yast::Label.CancelButton | ||
end | ||
|
||
# @macro seeDialog | ||
def next_handler | ||
@partitioning = controller.partitioning | ||
true | ||
end | ||
|
||
# @macro seeDialog | ||
def back_handler | ||
Yast::Popup.ReallyAbort(controller.modified?) | ||
end | ||
|
||
def should_open_dialog? | ||
true | ||
end | ||
|
||
private | ||
|
||
attr_reader :controller | ||
|
||
# CWM show loop | ||
# | ||
# This method is redefined to keep the dialog in a loop if a | ||
# `redraw` is needed. | ||
def cwm_show | ||
loop do | ||
result = super | ||
return result if result != :redraw | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# 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 "y2storage" | ||
|
||
module Y2Autoinstallation | ||
# Controller for the editing the partitioning section of a profile | ||
# | ||
# It is supposed to be used internally by | ||
# {Y2Autoinstallation::Dialogs::Storage}. | ||
class StorageController | ||
# @return [Y2Storage::AutoinstProfile::PartitioningSection] | ||
# Partition section | ||
attr_reader :partitioning | ||
|
||
# Constructor | ||
# | ||
# @param partitioning [Y2Storage::AutoinstProfile::PartitioningSection] | ||
# Partitioning section of the profile | ||
def initialize(partitioning) | ||
@partitioning = partitioning | ||
@modified = false | ||
end | ||
|
||
TYPES_MAP = { | ||
disk: :CT_DISK | ||
}.freeze | ||
|
||
# Adds a new drive section of the given type | ||
# | ||
# @param type [Symbol] | ||
def add_drive(type) | ||
section = Y2Storage::AutoinstProfile::DriveSection.new_from_hashes(type: TYPES_MAP[type]) | ||
partitioning.drives << section | ||
end | ||
|
||
# Adds a new partition section under the given section | ||
# | ||
# @param parent [Y2Storage::AutoinstProfile::DriveSection] Parent section | ||
def add_partition(parent) | ||
parent.partitions << Y2Storage::AutoinstProfile::PartitionSection.new | ||
end | ||
|
||
# It determines whether the profile was modified | ||
# | ||
# @todo Implement logic to detect whether the partitioning | ||
# was modified or not. | ||
def modified? | ||
true | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# 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/ui_state" | ||
|
||
module Y2Autoinstallation | ||
# Singleton class to keep the position of the user in the UI and other similar | ||
# information that needs to be rememberd across UI redraws to give the user a | ||
# sense of continuity. | ||
class UIState < CWM::UIState | ||
# @see CWM::UIState#textdomain_name | ||
def textdomain_name | ||
"autoinst" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# 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. | ||
|
||
# Work around YARD inability to link across repos/gems: | ||
# @!macro [new] seeAbstractWidget | ||
# @see http://www.rubydoc.info/github/yast/yast-yast2/CWM%2FAbstractWidget:${0} | ||
# @!macro [new] seeCustomWidget | ||
# @see http://www.rubydoc.info/github/yast/yast-yast2/CWM%2FCustomWidget:${0} | ||
# @!macro [new] seeDialog | ||
# @see http://www.rubydoc.info/github/yast/yast-yast2/CWM%2FDialog:${0} | ||
# @!macro [new] seeComboBox | ||
# @see http://www.rubydoc.info/github/yast/yast-yast2/CWM%2FComboBox:${0} |
69 changes: 69 additions & 0 deletions
69
src/lib/autoinstall/widgets/storage/add_children_button.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# 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 | ||
# This class provides a button to add 'partition' sections | ||
# | ||
# In an AutoYaST profile, a 'partition' section is used to define a | ||
# partition, a logical volume, a RAID member, etc. | ||
class AddChildrenButton < CWM::PushButton | ||
extend Yast::I18n | ||
|
||
# Constructor | ||
# | ||
# @param controller [Y2Autoinstallation::StorageController] UI controller | ||
# @param section [Y2Storage::AutoinstProfile::DriveSection] Drive section of the profile | ||
def initialize(controller, section) | ||
textdomain "autoinst" | ||
@controller = controller | ||
@section = section | ||
end | ||
|
||
TYPE_LABELS = { | ||
CT_DISK: N_("Partition") | ||
}.freeze | ||
|
||
def label | ||
type_label = _(TYPE_LABELS[section.type]) | ||
format(_("Add %{type_label}"), type_label: type_label) | ||
end | ||
|
||
# @macro seeAbstractWidget | ||
def handle | ||
# FIXME: the controller could keep track of the current section | ||
controller.add_partition(section) | ||
:redraw | ||
end | ||
|
||
private | ||
|
||
# @return [Y2Autoinstallation::StorageController] | ||
attr_reader :controller | ||
|
||
# @return [Y2Storage::AutoinstProfile::DriveSection] | ||
attr_reader :section | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.