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

Refactor installer UI #222

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

johnliu55tw
Copy link
Contributor

@johnliu55tw johnliu55tw commented Jan 27, 2022

Key idea

Replace key binding configuration with event callback

We shouldn't have to configure the key bindings of each input element (Input, Select, and DropDown) when creating a "page". Instead, these input elements should provide an interface for setting up event callbacks. Each input element should only have two events:

  • On Confirm: Triggered when users decided to submit the result. For example: Pressed Enter or ArrowDown.
  • On Leave: Triggered when users decided to cancel the current operation. For example: Pressed Esc or ArrowUp

The event handler callback has type func (data interface{}, key gocui.Key) error. You can create a handler to:

  • Validate the data sent by the input element, then decide whether go to the next input element.
  • Check what key triggered the event. For instance, if it's Esc that triggered the On Leave event, then the UI should go to the previous page. But if it's ArrowUp, then we should go to the previous input element on the same page.

Create a "Page" widget to create a page with ease

A Page element is responsible for:

  • Manage the page-wise components, such as:
    • Title
    • Footer
    • Validator message and the busy-spinner
    • Additional notes for each input element
  • Manage the layout of input elements on this page dynamically
  • Manage the interaction between input elements on this page, i.e.:
    • Go to the next input element if the current one triggered the On Confirm event and passed the validation
    • Go to the previous input element if the current one triggered the On Leave event
    • Update Validator status (and maybe turn on the busy-spinner) while validating the input

Some PoC

  • Re-create the Network configuration page without any key bindings configuration, only relies on the On Confirm and On Leave event LINK
  • Use the Page widget to create the DNS configuration page LINK
  • A simple page with all three types of input element LINK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant