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

Bug 2119615: The unit field doesn't change in Disk modal #860

Merged

Conversation

DanaOrr
Copy link
Contributor

@DanaOrr DanaOrr commented Sep 6, 2022

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:
DiskSIzeBefore

After:
DiskSIzeAfter

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 6, 2022

@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
  • bug is open, matching expected state (open)
  • bug target release (4.12.0) matches configured target release for branch (4.12.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @gouyang

In response to this:

Bug 2119615: The unit field doesn't change in Disk modal

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.

@openshift-ci openshift-ci bot requested a review from gouyang September 6, 2022 08:56
Copy link
Member

@pcbailey pcbailey left a 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.

@@ -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 };
Copy link
Member

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/

@DanaOrr DanaOrr force-pushed the unit-field-in-disk-modal branch 2 times, most recently from 8a4451a to e381601 Compare September 12, 2022 09:42
Comment on lines 27 to 37
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]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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?

Copy link
Contributor Author

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 :)

@DanaOrr DanaOrr force-pushed the unit-field-in-disk-modal branch 2 times, most recently from 2b3ebe4 to 67a6981 Compare September 13, 2022 08:50
Signed-off-by: Dana Orr <dorr@redhat.com>
@openshift-ci openshift-ci bot added the lgtm Passed code review, ready for merge label Sep 13, 2022
@metalice
Copy link
Member

/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 19, 2022

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved This issue is something we want to fix label Sep 19, 2022
@DanaOrr
Copy link
Contributor Author

DanaOrr commented Sep 19, 2022

/retest

1 similar comment
@upalatucci
Copy link
Member

/retest

@openshift-merge-robot openshift-merge-robot merged commit 2b07ebc into kubevirt-ui:main Sep 20, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 20, 2022

@DanaOrr: All pull requests linked via external trackers have merged:

Bugzilla bug 2119615 has been moved to the MODIFIED state.

In response to this:

Bug 2119615: The unit field doesn't change in Disk modal

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.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved This issue is something we want to fix bugzilla/severity-high bugzilla/valid-bug lgtm Passed code review, ready for merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants