Skip to content

Commit

Permalink
Feat: Refresh the current table.
Browse files Browse the repository at this point in the history
  • Loading branch information
pro0o committed Oct 28, 2024
1 parent cc376a9 commit 6b9a0bf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ Support for multiple RDBMS is a work in progress.
| [ | Focus previous tab |
| ] | Focus next tab |
| X | Close current tab |
| R | Refresh the current table |

### Tree

Expand Down
1 change: 1 addition & 0 deletions app/Keymap.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ var Keymaps = KeymapSystem{
Bind{Key: Key{Char: 'y'}, Cmd: cmd.Copy, Description: "Copy cell to clipboard"},
Bind{Key: Key{Char: 'o'}, Cmd: cmd.AppendNewRow, Description: "Append new row"},
Bind{Key: Key{Char: 'J'}, Cmd: cmd.SortDesc, Description: "Sort descending"},
Bind{Key: Key{Char: 'R'}, Cmd: cmd.Refresh, Description: "Refresh the current table"},
Bind{Key: Key{Char: 'K'}, Cmd: cmd.SortAsc, Description: "Sort ascending"},
Bind{Key: Key{Char: 'C'}, Cmd: cmd.SetValue, Description: "Toggle value menu to put values like NULL, EMPTY or DEFAULT"},
// Tabs
Expand Down
1 change: 1 addition & 0 deletions commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const (
TabClose

// Operations
Refresh
UnfocusEditor
Copy
Edit
Expand Down
10 changes: 9 additions & 1 deletion components/ResultsTable.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ func (table *ResultsTable) tableInputCapture(event *tcell.EventKey) *tcell.Event

command := app.Keymaps.Group(app.TableGroup).Resolve(event)

menuCommands := []commands.Command{commands.RecordsMenu, commands.ColumnsMenu, commands.ConstraintsMenu, commands.ForeignKeysMenu, commands.IndexesMenu}
menuCommands := []commands.Command{commands.RecordsMenu, commands.ColumnsMenu, commands.ConstraintsMenu, commands.ForeignKeysMenu, commands.IndexesMenu, commands.Refresh}

if helpers.ContainsCommand(menuCommands, command) {
table.Select(1, 0)
Expand All @@ -350,6 +350,14 @@ func (table *ResultsTable) tableInputCapture(event *tcell.EventKey) *tcell.Event
case commands.IndexesMenu:
table.Menu.SetSelectedOption(5)
table.UpdateRows(table.GetIndexes())
case commands.Refresh:
if table.Loading != nil {
app.App.SetFocus(table.Loading)
}
table.Menu.SetSelectedOption(1)
if err := table.FetchRecords(nil); err != nil {
return event
}
}
}

Expand Down

0 comments on commit 6b9a0bf

Please sign in to comment.