-
Notifications
You must be signed in to change notification settings - Fork 24
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
Bug 2119615: The unit field doesn't change in Disk modal #860
Bug 2119615: The unit field doesn't change in Disk modal #860
Conversation
@DanaOrr: This pull request references Bugzilla bug 2119615, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker. 3 validation(s) were run on this bug
Requesting review from QA contact: In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
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.
Great job! Just one small question and suggestion.
src/views/catalog/utils/quantity.ts
Outdated
@@ -14,7 +14,7 @@ export const bytesFromQuantity = ( | |||
quantity: string | number, | |||
precision = 0, | |||
): [value: number, unit: string] => { | |||
let byteSizeResult: ByteSizeResult = undefined; | |||
let byteSizeResult: ByteSizeResult = { value: undefined, unit: undefined, long: undefined }; |
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.
Why have you added the long
property? It doesn't look like it's used anywhere.
FYI, it's better to use null
when initializing a variable yourself. I didn't see the original when I was working on it or I would have changed it.
Here's a good explanation of the difference:
Null: It is the intentional absence of the value. It is one of the primitive values of JavaScript.
Undefined: It means the value does not exist in the compiler. It is the global object.
Source: https://www.geeksforgeeks.org/undefined-vs-null-in-javascript/
8a4451a
to
e381601
Compare
const [unit, setUnit] = useState<string>(); | ||
const [value, setValue] = useState<number>(0); | ||
|
||
const [value, quantityUnit] = bytesFromQuantity(size); | ||
useEffect(() => { | ||
if (size) { | ||
const [unitValue] = size.match(/[a-zA-Z]+/g); | ||
const [sizeValue = 0] = size.match(/[0-9]+/g) || []; | ||
setUnit(!unitValue?.endsWith('B') ? unitValue + 'B' : unitValue); | ||
setValue(+sizeValue); | ||
} | ||
}, [size]); |
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.
const [unit, setUnit] = useState<string>(); | |
const [value, setValue] = useState<number>(0); | |
const [value, quantityUnit] = bytesFromQuantity(size); | |
useEffect(() => { | |
if (size) { | |
const [unitValue] = size.match(/[a-zA-Z]+/g); | |
const [sizeValue = 0] = size.match(/[0-9]+/g) || []; | |
setUnit(!unitValue?.endsWith('B') ? unitValue + 'B' : unitValue); | |
setValue(+sizeValue); | |
} | |
}, [size]); | |
const [unitValue] = size?.match(/[a-zA-Z]+/g); | |
const [sizeValue = 0] = size?.match(/[0-9]+/g) || []; | |
const unit = !unitValue?.endsWith('B') ? unitValue + 'B' : unitValue; | |
const value = +sizeValue; |
What do you think about?
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.
It is better! Thank you :)
2b3ebe4
to
67a6981
Compare
Signed-off-by: Dana Orr <dorr@redhat.com>
67a6981
to
7569c75
Compare
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: DanaOrr, metalice, upalatucci The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
1 similar comment
/retest |
@DanaOrr: All pull requests linked via external trackers have merged: Bugzilla bug 2119615 has been moved to the MODIFIED state. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Signed-off-by: Dana Orr dorr@redhat.com
📝 Description
The unit field doesn't change when the size of the disk changes in Disk modal.
🎥 Demo
Before:
After: