ploomber / jupysql-plugin

BSD 3-Clause "New" or "Revised" License
16 stars 12 forks source link

connector widget: form resets when switching db #71

Closed edublancas closed 1 year ago

edublancas commented 1 year ago

if I fill out the form for a new connection:

image

and then switch the db from the dropdown, the form resets. it'll be better if it'd kept the values. note that some forms contain different fields (eg duckdb and sqlite only contain alias and database), so we should only fill out the ones that match

edublancas commented 1 year ago

one important detail is the alias: if the dropdown is changed, we should only keep the alias if the user modified it. if it didn't, then we should change it for the default alias that corresponds to the selected db in the dropdown

neelasha23 commented 1 year ago

Acceptance criteria:

  1. If user fills out a form for somedb and changes the DB selection, the previous fields input should be automatically stored in the session and relevant fields to be autopopulated.
  2. Only relevant fields to be filled , alias and database for DuckDB and SQLite.
  3. alias field to be saved only if user changed it, else default value of selected connection to be displayed.
  4. Test cases: This should work for both edit connection and create new connection flow.
  5. Changelog entry
neelasha23 commented 1 year ago

Need some clarifications:

  1. Is this applicable if user clicks the Create button or user types some fields and then selects some other DB (without clicking Create) and the expected behaviour is that the inputs should be retained? Scenario 1: User selects Postgres, fills out username, alias, etc and hits the Create button. creates another connection, Selects SQLite .. (should the previous inputs of postgres be auto-populated) ? Scenario 2: User selects Postgres, fills out username, alias, etc and changes the dropdown to SQLite. the same values should be visible instead of form resetting. (I think this is the scenario you meant in the issue?)
  2. The point that you mentioned about alias, is it not applicable for ports as well? @edublancas
edublancas commented 1 year ago

so the use case here is that a user might start editing connection details and then realize that they selected the wrong db. we want to prevent the issue of having to rewrite things from scratch.

  1. this is applicable only before clicking on create. once they click on create. it's fine to delete all existing info
  2. good catch, yes. if the user did not modify the port, then switching the dropdown should change the port as well