Skip to content
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

storage: Put the minimum of a slider at the far left #19515

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pkg/storaged/dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ class SizeSliderElement extends React.Component {
const { unit } = this.state;

const change_slider = (_event, f) => {
onChange(Math.max(min, size_slider_round(f * max / 100, round)));
onChange(Math.max(min, size_slider_round(f, round)));
};

const change_text = (value) => {
Expand Down Expand Up @@ -972,7 +972,8 @@ class SizeSliderElement extends React.Component {
return (
<Grid hasGutter className="size-slider">
<GridItem span={12} sm={8}>
<Slider showBoundaries={false} value={(slider_val / max) * 100} onChange={change_slider} />
<Slider showBoundaries={false} min={min} max={max} step={(max - min) / 500}
value={slider_val} onChange={change_slider} />
</GridItem>
<GridItem span={6} sm={2}>
<TextInputPF4 className="size-text" value={text_val} onChange={(_event, value) => change_text(value)} />
Expand Down
17 changes: 11 additions & 6 deletions test/verify/check-storage-partitions
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,27 @@ class TestStoragePartitions(storagelib.StorageCase):
about_half_way = width / 2 + 1

b.mouse(slider, "click", about_half_way, 0)
self.dialog_wait_val("size", 27.3)
self.dialog_wait_val("size", 27.4)
b.focus(slider + " + .pf-v5-c-slider__thumb")
b.key_press(chr(37), use_ord=True) # arrow left
self.dialog_wait_val("size", 26.7)
b.key_press(chr(37), use_ord=True)
b.key_press(chr(37), use_ord=True)
self.dialog_wait_val("size", 27.1)

# Check that changing units affects the text input
unit = "1000000000"
b.select_from_dropdown(".size-unit > select", unit)
self.dialog_wait_val("size", "0.0267", unit)
self.dialog_wait_val("size", "0.0271", unit)

self.dialog_apply()
self.dialog_wait_close()

# With old Udisks2 versions, the partition will end up being
# 25.1M while newer versions give us 26M or 25M.
testlib.wait(lambda: m.execute(f"lsblk -no SIZE {disk}1").strip() in ["25M", "25.1M", "26M"])
# 27.1 MB is about 25.84 MiB. Some versions of
# UDisks2/libblockdev/libparted/... round this up to 26 MiB
# when creating the partition, some (newer ones) round it down
# to 25 MiB.
#
testlib.wait(lambda: m.execute(f"lsblk -no SIZE {disk}1").strip() in ["26M", "25M"])

def testResize(self):
m = self.machine
Expand Down