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

Disk page in Installer requires pressing Enter two times before switching to next page #650

Merged
merged 1 commit into from
May 23, 2024

Conversation

votdev
Copy link
Member

@votdev votdev commented Feb 2, 2024

Problem:
After the user entered all information in the disk page it is still necessary to press Enter or Key-Down twice at the Use MBR partitioning scheme form control before switching to the next (Hostname) page.

Solution:
Set the diskConfirmed after the Persistent size has been validated. Because of this, only one Key-Down or Enter is necessary to confirm the value and switch to the next page.

Related Issue:
harvester/harvester#5097

Test plan:

Case 1:

  • Go to the disk page.
  • Enter all data, so that the form is valid.
  • Navigate to Use MBR partitioning scheme. Do not modify the value (defaults to No). Press Enter or Key-Down.
  • The page should switch to the Hostname page.

Case 2:

  • Go to the disk page.
  • Enter all data, so that the form is valid.
  • Navigate to Use MBR partitioning scheme. Press Tab, choose Yes and confirm with Enter.
  • The page is NOT switched to the next page. The Use MBR partitioning scheme is still focused. Press Enter or Key-Down.
  • The page should switch to the Hostname page.

@votdev votdev added the enhancement New feature or request label Feb 2, 2024
@votdev votdev self-assigned this Feb 2, 2024
@votdev votdev marked this pull request as draft February 2, 2024 15:27
@votdev votdev force-pushed the issue_5097_press_enter_twice branch 2 times, most recently from 0b1096e to ce9bdff Compare February 5, 2024 13:33
@votdev votdev force-pushed the issue_5097_press_enter_twice branch from ce9bdff to 90e3b42 Compare March 22, 2024 09:33
@votdev votdev marked this pull request as ready for review March 22, 2024 10:10
Copy link
Contributor

@tserong tserong left a comment

Choose a reason for hiding this comment

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

LGTM, and I tested it too just for fun, and it works fine.

I wonder though, having looked at the rest of the code some more, if we could just get rid of the diskConfirmed variable entirely? AFAICT it's only checked in gotoNextPage() but by then it will always be true anyway given this change, which (unless I'm missing something) makes the variable redundant.

(Also, I suspect the calls to validateAllDiskSizes() and validatePersistentPartitionSize() in gotoNextPage() are also redundant, given those functions are called already from diskConfirm(), dataDiskConfirm() and persistentSizeConfirm() - that's unrelated to this change, I just happened to notice while re-reading everything.)

Copy link
Member

@starbops starbops left a comment

Choose a reason for hiding this comment

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

The functionality works fine. LGTM, thank you!

@bk201
Copy link
Member

bk201 commented Apr 3, 2024

Great work. The change works great if the "Use MBR partitioning scheme" dropdown is not changed. A single enter goes to next panel.

But if I change the field, it will immediately jump to the next panel. For example:

new2.mov

I feel it's more natural if the page can stay after changing the value (that is, the original "double click" behavior). The user has the time to review the values. For example:

old.mov

Is it possible to use a single enter if the value doesn't change, but two enters if the value changes?

@tserong
Copy link
Contributor

tserong commented Apr 24, 2024

Is it possible to use a single enter if the value doesn't change, but two enters if the value changes?

This might do it (untested, based on work in #717):

--- a/pkg/console/install_panels.go
+++ b/pkg/console/install_panels.go
@@ -681,7 +681,12 @@ func addDiskPanel(c *Console) error {
                        }
                }
 
+               currentVal := c.config.ForceMBR
                c.config.ForceMBR = forceMBR == "yes"
+               if c.config.ForceMBR != currentVal {
+                       // Force another ENTER hit to proceed if the value is chaned
+                       return nil
+               }
                return gotoNextPage(g, v)
        }
        askForceMBRV.KeyBindings = map[gocui.Key]func(*gocui.Gui, *gocui.View) error{

@votdev votdev force-pushed the issue_5097_press_enter_twice branch from 90e3b42 to b45ef30 Compare May 21, 2024 13:21
@votdev votdev requested a review from tserong May 21, 2024 13:45
Copy link
Contributor

@tserong tserong left a comment

Choose a reason for hiding this comment

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

LGTM, and that's a neat way to not bother with a temporary variable :-)

Copy link
Member

@FrankYang0529 FrankYang0529 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks.

@bk201 bk201 merged commit d4b17d4 into harvester:master May 23, 2024
5 checks passed
@votdev votdev deleted the issue_5097_press_enter_twice branch May 23, 2024 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants