-
Notifications
You must be signed in to change notification settings - Fork 74
Storage UI: Delete Partition (in proposal; trash-can icon) #1915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+207
−35
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
fbe38a2
just log when the UI button is clicked
mvidner ba30864
Clicking the trash can icon always deletes a proposed partition
mvidner f2f32f3
fix aria-label=Delete
mvidner 104195f
rename to PartitionHook.delete
mvidner b64ff55
WIP test
mvidner f292d2c
fix(web): extend partitions menu markup and add a test
dgdavid 8f91158
Merge branch 'storage-config-ui' into delete-proposed-partition
mvidner 2d8b27e
adjust test after merging with upstream
mvidner 84c37e0
comment usePartition better
mvidner 3c52b08
comment Size.default better
mvidner 50f677d
changelog
mvidner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ancorgs thanks for the explanation...
now I know that the comment should actually go to storage.model.schema.json, but I haven't found a Makefile-like declaration to update the generated config-model.ts so I am postponing this yak shave