diff --git a/service/lib/agama/storage/proposal_settings_conversion/to_y2storage.rb b/service/lib/agama/storage/proposal_settings_conversion/to_y2storage.rb index c38add3cf5..b029b45b1f 100644 --- a/service/lib/agama/storage/proposal_settings_conversion/to_y2storage.rb +++ b/service/lib/agama/storage/proposal_settings_conversion/to_y2storage.rb @@ -207,20 +207,9 @@ def boot_device # # @see ProposalSettings#installation_devices # - # If a device is partitioned, then its partitions are included instead of the device. - # # @return [Array] def all_devices - settings.installation_devices - .map { |d| device_or_partitions(d) } - .flatten - end - - # @param device [String] - # @return [String, Array] - def device_or_partitions(device) - partitions = partitions(device) - partitions.empty? ? device : partitions + settings.installation_devices.flat_map { |d| partitions(d) } end # @param device [String] diff --git a/service/package/gem2rpm.yml b/service/package/gem2rpm.yml index dcb9b696e3..36f3036ccb 100644 --- a/service/package/gem2rpm.yml +++ b/service/package/gem2rpm.yml @@ -38,7 +38,7 @@ Requires: yast2-iscsi-client >= 4.5.7 Requires: yast2-network Requires: yast2-proxy - Requires: yast2-storage-ng >= 5.0.12 + Requires: yast2-storage-ng >= 5.0.13 Requires: yast2-users %ifarch s390 s390x Requires: yast2-s390 >= 4.6.4 diff --git a/service/package/rubygem-agama-yast.changes b/service/package/rubygem-agama-yast.changes index 0225ba8470..5ba52de817 100644 --- a/service/package/rubygem-agama-yast.changes +++ b/service/package/rubygem-agama-yast.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Apr 25 13:40:06 UTC 2024 - Ancor Gonzalez Sosa + +- Adapted to recent changes on Y2Storage::GuidedProposal + (gh#yast/yast-storage-ng#1382) + ------------------------------------------------------------------- Thu Apr 18 08:46:06 UTC 2024 - Ladislav Slezák diff --git a/service/test/agama/storage/proposal_settings_conversion/to_y2storage_test.rb b/service/test/agama/storage/proposal_settings_conversion/to_y2storage_test.rb index 1fc6087951..6cd5be7191 100644 --- a/service/test/agama/storage/proposal_settings_conversion/to_y2storage_test.rb +++ b/service/test/agama/storage/proposal_settings_conversion/to_y2storage_test.rb @@ -262,7 +262,7 @@ settings.space.policy = :delete end - it "generates delete actions for all used devices" do + it "generates delete actions for all the partitions at the used devices" do y2storage_settings = subject.convert expect(y2storage_settings.space_settings).to have_attributes( @@ -270,9 +270,7 @@ actions: { "/dev/sda1" => :force_delete, "/dev/sda2" => :force_delete, - "/dev/sda3" => :force_delete, - "/dev/sdb" => :force_delete, - "/dev/sdc" => :force_delete + "/dev/sda3" => :force_delete } ) end @@ -283,7 +281,7 @@ settings.space.policy = :resize end - it "generates resize actions for all used devices" do + it "generates resize actions for all the partitions at the used devices" do y2storage_settings = subject.convert expect(y2storage_settings.space_settings).to have_attributes( @@ -291,9 +289,7 @@ actions: { "/dev/sda1" => :resize, "/dev/sda2" => :resize, - "/dev/sda3" => :resize, - "/dev/sdb" => :resize, - "/dev/sdc" => :resize + "/dev/sda3" => :resize } ) end diff --git a/web/package/cockpit-agama.changes b/web/package/cockpit-agama.changes index 6db121f296..3b8b0b9783 100644 --- a/web/package/cockpit-agama.changes +++ b/web/package/cockpit-agama.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Apr 25 13:40:06 UTC 2024 - Ancor Gonzalez Sosa + +- Adapted to recent changes on Y2Storage::GuidedProposal + (gh#yast/yast-storage-ng#1382) + ------------------------------------------------------------------- Tue Apr 16 11:15:13 UTC 2024 - David Diaz diff --git a/web/src/client/storage.js b/web/src/client/storage.js index 190600f862..f5a2b92ec0 100644 --- a/web/src/client/storage.js +++ b/web/src/client/storage.js @@ -539,7 +539,7 @@ class ProposalManager { const names = uniq(compact(values)).filter(d => d.length > 0); // #findDevice returns undefined if no device is found with the given name. - return compact(names.map(findDevice)); + return compact(names.sort().map(findDevice)); }; const dbusSettings = proxy.Settings; diff --git a/web/src/components/storage/SpaceActionsTable.jsx b/web/src/components/storage/SpaceActionsTable.jsx index f78d044040..ce7f615fa2 100644 --- a/web/src/components/storage/SpaceActionsTable.jsx +++ b/web/src/components/storage/SpaceActionsTable.jsx @@ -27,7 +27,7 @@ import { FormSelect, FormSelectOption } from "@patternfly/react-core"; import { _ } from "~/i18n"; import { FilesystemLabel } from "~/components/storage"; import { deviceChildren, deviceSize } from '~/components/storage/utils'; -import { If, Tag, TreeTable } from "~/components/core"; +import { Tag, TreeTable } from "~/components/core"; import { sprintf } from "sprintf-js"; /** @@ -97,7 +97,7 @@ const DeviceSizeDetails = ({ device }) => { }; /** - * Column content with the space action for a device. + * Form to configure the space action for a device (a partition). * @component * * @param {object} props @@ -106,9 +106,7 @@ const DeviceSizeDetails = ({ device }) => { * @param {boolean} [props.isDisabled=false] * @param {(action: SpaceAction) => void} [props.onChange] */ -const DeviceAction = ({ device, action, isDisabled = false, onChange }) => { - if (!device.sid || device.partitionTable) return null; - +const DeviceActionForm = ({ device, action, isDisabled = false, onChange }) => { const changeAction = (_, action) => onChange({ device: device.name, action }); return ( @@ -122,16 +120,45 @@ const DeviceAction = ({ device, action, isDisabled = false, onChange }) => { } > - {/* Resize action does not make sense for drives, so it is filtered out. */} - } - /> + ); }; +/** + * Column content with the space action (a form or a description) for a device + * @component + * + * @param {object} props + * @param {StorageDevice} props.device + * @param {string} props.action - Possible values: "force_delete", "resize" or "keep". + * @param {boolean} [props.isDisabled=false] + * @param {(action: SpaceAction) => void} [props.onChange] + */ +const DeviceAction = ({ device, action, isDisabled = false, onChange }) => { + if (!device.sid) return null; + + if (device.type === "partition") { + return ( + + ); + } + + if (device.filesystem || device.component) + return _("The content may be deleted"); + + if (!device.partitionTable || device.partitionTable.partitions.length === 0) + return _("No content found"); + + return null; +}; + /** * Table for selecting the space actions of the given devices. * @component diff --git a/web/src/components/storage/SpacePolicyDialog.jsx b/web/src/components/storage/SpacePolicyDialog.jsx index 829bd56e0b..e0f5162d04 100644 --- a/web/src/components/storage/SpacePolicyDialog.jsx +++ b/web/src/components/storage/SpacePolicyDialog.jsx @@ -114,19 +114,12 @@ export default function SpacePolicyDialog({ // Generates the action value according to the policy. const deviceAction = (device) => { - let action; - if (policy.id === "custom") { - action = actions.find(a => a.device === device.name)?.action || "keep"; - } else { - const policyAction = { delete: "force_delete", resize: "resize", keep: "keep" }; - action = policyAction[policy.id]; + return actions.find(a => a.device === device.name)?.action || "keep"; } - // For a drive device (e.g., Disk, RAID) it does not make sense to offer the resize action. - // At this moment, the Agama backend generates a resize action for drives if the policy is set - // to 'resize'. In that cases, the action is converted here to 'keep'. - return ((device.isDrive && action === "resize") ? "keep" : action); + const policyAction = { delete: "force_delete", resize: "resize", keep: "keep" }; + return policyAction[policy.id]; }; const changeActions = (spaceAction) => { diff --git a/web/src/components/storage/SpacePolicyDialog.test.jsx b/web/src/components/storage/SpacePolicyDialog.test.jsx index 0c513c5511..a28ed8ac19 100644 --- a/web/src/components/storage/SpacePolicyDialog.test.jsx +++ b/web/src/components/storage/SpacePolicyDialog.test.jsx @@ -49,7 +49,7 @@ const sda = { const sda1 = { sid: 60, isDrive: false, - type: "", + type: "partition", active: true, name: "/dev/sda1", size: 512, @@ -62,7 +62,7 @@ const sda1 = { const sda2 = { sid: 61, isDrive: false, - type: "", + type: "partition", active: true, name: "/dev/sda2", size: 512, @@ -194,7 +194,7 @@ describe("SpacePolicyDialog", () => { // TODO: use a more inclusive way to disable the actions. // https://css-tricks.com/making-disabled-buttons-more-inclusive/ const spaceActions = screen.getAllByRole("combobox", { name: /Space action selector/, hidden: true }); - expect(spaceActions.length).toEqual(3); + expect(spaceActions.length).toEqual(2); }); }); @@ -213,7 +213,7 @@ describe("SpacePolicyDialog", () => { it("allows to modify the space actions", async () => { plainRender(); const spaceActions = screen.getAllByRole("combobox", { name: /Space action selector/ }); - expect(spaceActions.length).toEqual(3); + expect(spaceActions.length).toEqual(2); }); }); @@ -222,7 +222,7 @@ describe("SpacePolicyDialog", () => { props.policy = customPolicy; }); - it("renders the space actions selector for devices without partition table", async () => { + it("renders the space actions selector for partitions", async () => { plainRender(); // sda has partition table, the selector shouldn't be found const sdaRow = screen.getByRole("row", { name: /sda gpt/i }); @@ -232,17 +232,10 @@ describe("SpacePolicyDialog", () => { const unusedRow = screen.getByRole("row", { name: /unused space/i }); const unusedActionsSelector = within(unusedRow).queryByRole("combobox"); expect(unusedActionsSelector).toBeNull(); - // sdb does not have partition table, selector should be there + // sdb is a disk, selector shouldn't be there const sdbRow = screen.getByRole("row", { name: /sdb/ }); - within(sdbRow).getByRole("combobox"); - }); - - it("does not renders the 'resize' option for drives", async () => { - plainRender(); - const sdbRow = screen.getByRole("row", { name: /sdb/ }); - const spaceActionsSelector = within(sdbRow).getByRole("combobox"); - const resizeOption = within(spaceActionsSelector).queryByRole("option", { name: /resize/ }); - expect(resizeOption).toBeNull(); + const sdbActionsSelector = within(sdbRow).queryByRole("combobox"); + expect(sdbActionsSelector).toBeNull(); }); it("renders the 'resize' option for devices other than drives", async () => {