Skip to content

Commit

Permalink
Fixes connection name edit
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgerojas26 committed Oct 14, 2023
1 parent dc4703b commit cd76672
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions pages/connectionList.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func renderConnectionList() *tview.Flex {
go connect(connectionUrl)
} else if event.Rune() == 101 { // E Key
ConnectionPages.SwitchToPage("NewConnection")
AddConnectionForm.GetFormItemByLabel("Name").(*tview.InputField).SetText(selectedConnection.Name)
AddConnectionForm.GetFormItemByLabel("URL").(*tview.InputField).SetText(connectionUrl)

AddConnectionFormWrapper.SetInputCapture(EditConnectionInputHandler(connections, row))
Expand Down
5 changes: 3 additions & 2 deletions pages/newConnection.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ func EditConnectionInputHandler(databases []utils.Connection, row int) func(even
ConnectionStatus.SetText("")
ConnectionPages.SwitchToPage("ConnectionList")
} else if event.Key() == tcell.KeyF1 || event.Key() == tcell.KeyEnter {
connectionString := AddConnectionForm.GetFormItem(0).(*tview.InputField).GetText()
connectionName := AddConnectionForm.GetFormItem(0).(*tview.InputField).GetText()
connectionString := AddConnectionForm.GetFormItem(1).(*tview.InputField).GetText()
parsed, err := drivers.MySQL.ParseConnectionString(connectionString)

if err != nil {
Expand All @@ -147,7 +148,7 @@ func EditConnectionInputHandler(databases []utils.Connection, row int) func(even
newDatabases := make([]utils.Connection, len(databases))
for i, database := range databases {
if i == row {
newDatabases[i].Name = database.Name
newDatabases[i].Name = connectionName
newDatabases[i].Provider = database.Provider
newDatabases[i].User = parsed.User.Username()
newDatabases[i].Password, _ = parsed.User.Password()
Expand Down

0 comments on commit cd76672

Please sign in to comment.