-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Storage UI: Delete Partition (in proposal; trash-can icon) (#1915)
## Problem Making the trash-can icon work - https://trello.com/c/vPPaRAIg  ## Solution - [x] delete the item from the list (via configModel.Config) - [ ] ~ask for confirmation~ - [ ] ~check that the partition is not mandatory~ ... these two are postponed to a followup PBI ## Testing - Tested manually - Added a unit test for the UI part (thanks David!) ## Screenshots No. The deleted partition is not visible 🤣 and a video would be overkill.
- Loading branch information
Showing
4 changed files
with
207 additions
and
35 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 |
---|---|---|
@@ -1,3 +1,9 @@ | ||
------------------------------------------------------------------- | ||
Thu Jan 23 15:09:09 UTC 2025 - Martin Vidner <[email protected]> | ||
|
||
- Make the trash can icon (Delete) of a proposed partition work | ||
gh#agama-project/agama#1915) | ||
|
||
------------------------------------------------------------------- | ||
Mon Jan 20 16:45:18 UTC 2025 - Ladislav Slezák <[email protected]> | ||
|
||
|
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,93 @@ | ||
/* | ||
* Copyright (c) [2025] SUSE LLC | ||
* | ||
* All Rights Reserved. | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the Free | ||
* Software Foundation; either version 2 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* 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. | ||
*/ | ||
|
||
import React from "react"; | ||
import { screen, within } from "@testing-library/react"; | ||
import { plainRender } from "~/test-utils"; | ||
import DriveEditor, { DriveEditorProps } from "~/components/storage/DriveEditor"; | ||
import * as ConfigModel from "~/api/storage/types/config-model"; | ||
import { StorageDevice } from "~/types/storage"; | ||
|
||
const sda: StorageDevice = { | ||
sid: 59, | ||
isDrive: true, | ||
type: "disk", | ||
vendor: "Micron", | ||
model: "Micron 1100 SATA", | ||
driver: ["ahci", "mmcblk"], | ||
bus: "IDE", | ||
busId: "", | ||
transport: "usb", | ||
dellBOSS: false, | ||
sdCard: true, | ||
active: true, | ||
name: "/dev/sda", | ||
size: 1024, | ||
shrinking: { unsupported: ["Resizing is not supported"] }, | ||
systems: [], | ||
udevIds: ["ata-Micron_1100_SATA_512GB_12563", "scsi-0ATA_Micron_1100_SATA_512GB"], | ||
udevPaths: ["pci-0000:00-12", "pci-0000:00-12-ata"], | ||
description: "", | ||
}; | ||
|
||
const mockDrive: ConfigModel.Drive = { | ||
name: "/dev/sda", | ||
spacePolicy: "delete", | ||
partitions: [ | ||
{ | ||
mountPath: "swap", | ||
size: { | ||
min: 2_000_000_000, | ||
default: false, // false: user provided, true: calculated | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
const mockDeletePartition = jest.fn(); | ||
// TODO: why does "~/queries/storage" work elsewhere?? | ||
jest.mock("~/queries/storage/config-model", () => ({ | ||
...jest.requireActual("~/queries/storage/config-model"), | ||
useConfigModel: () => ({ drives: [mockDrive] }), | ||
useDrive: () => mockDrive, | ||
usePartition: () => ({ delete: mockDeletePartition }), | ||
})); | ||
|
||
const props: DriveEditorProps = { | ||
drive: mockDrive, | ||
driveDevice: sda, | ||
}; | ||
|
||
describe("PartitionMenuItem", () => { | ||
it("allows users delete a the partition", async () => { | ||
const { user } = plainRender(<DriveEditor {...props} />); | ||
|
||
const partitionsButton = screen.getByRole("button", { name: "Partitions" }); | ||
await user.click(partitionsButton); | ||
const partitionsMenu = screen.getByRole("menu"); | ||
const deleteSwapButton = within(partitionsMenu).getByRole("menuitem", { | ||
name: "Delete swap", | ||
}); | ||
await user.click(deleteSwapButton); | ||
expect(mockDeletePartition).toHaveBeenCalled(); | ||
}); | ||
}); |
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