[web] [Storage] Allow setting/editing volume sizes#590
Conversation
d4b5d4d to
9c4c9e4
Compare
b9a233c to
d6367ea
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
89778f6 to
ce104a2
Compare
| * | ||
| * @returns {ReactComponent} | ||
| */ | ||
| export default function NumericTextInput({ value = "", onChange = noop, ...textInputProps }) { |
There was a problem hiding this comment.
We could go further and do this helper more generic by receiving the pattern via prop. But let's wait until we really need it. Do you agree?
BTW, we are not using directly the HTML pattern attribute because it's not intended for limiting the input from the user but for performing validations before send the form. But since we're preventing the form submission, it is not as direct as the proposed solution. To learn more, read https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation#constraint_validation_process
Of course, we can evaluate the use of pattern attribute in the future.
Until now, the form for adding an additional volume was an internal
component inside agama/storage/ProposalVolumes.jsx. But this commit
extracted it to its own file since it has grown considerably after
- Add the ability to specify the volume size by choosing among two or
three options, depending on the volume itself: "Auto", "Manual", and
"Range".
- Support not only adding but also editing existing volumes, which
allows resizing.
This commit also drops the `filesize`[1] dependency in favor of
`xbytes`[2] because the latter allows parsing human readable sizes into
bytes too, although the former has more development activity.
[1] filesize - https://github.com/avoidwork/filesize.js
[2] xbytes - https://github.com/miraclx/xbytes
Co-Authored-By: José Iván López González <jlopez@suse.com>
By renaming it from "Size limits" to "Size" and changing how the desired
size is rendered:
- "X SizeUnit" when the volume is configured for having an exact size
(min === max)
- "At least X SizeUnit" when only the desired min size was specified
- "X SizeUnit - Y SizeUnit" when both the min and max size limits have
been set.
Additionally, it removes the word "Unlimited", which we found odd when
talking about size.
Co-Authored-By: José Iván López González <jlopez@suse.com>
For limiting entered values to not signed numbers and empty string. This helps to avoid mistakes like entering "100O GiB" instead of "1000 GiB" withoug noticing it (the library parsing the human readable size will ignore from 0 onwards, interpreting the size as 100 B).
imobachgs
left a comment
There was a problem hiding this comment.
In general, it looks good. Great job! Otherwise, I have a few comments.
Because there were a hidden bug when initializating the form with a missing size unit for either, minSize or maxSize. Changes introduced in this commit fixes the problem.
Co-authored-by: Imobach González Sosa <igonzalezsosa@suse.com>
It was using a NumericTextInput by mistake.
Problem
For now, users can only add volumes/filesystems that come from the product definition, but nothing else. They cannot even adjust the sizes of these predefined volumes.
Solution
Allow users to modify the volume size by letting them choose among "Auto" (only when possible), "Manual", and "Range".
This approach satisfies the requirements from the Trello card linked above:
Testing
Notes
This PR also drops the filesize dependency in favor of xbytes because the latter allows parsing human-readable sizes into bytes too, although the former has more development activity.
We can change it again at any time if a better alternative is found. Maybe we could write our own DiskSize in JavaScript or TypeScript. Let's see.
Screenshots
Size options
Size validations