Skip to content

Commit

Permalink
chore: make constants private
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgerojas26 committed Sep 8, 2024
1 parent 9e8fd49 commit 9792cca
Show file tree
Hide file tree
Showing 13 changed files with 104 additions and 104 deletions.
8 changes: 4 additions & 4 deletions components/ConnectionForm.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func NewConnectionForm(connectionPages *models.ConnectionPages) *ConnectionForm
func (form *ConnectionForm) inputCapture(connectionPages *models.ConnectionPages) func(event *tcell.EventKey) *tcell.EventKey {
return func(event *tcell.EventKey) *tcell.EventKey {
if event.Key() == tcell.KeyEsc {
connectionPages.SwitchToPage(ConnectionsPageName)
connectionPages.SwitchToPage(connectionsPageName)
} else if event.Key() == tcell.KeyF1 || event.Key() == tcell.KeyEnter {
connectionName := form.GetFormItem(0).(*tview.InputField).GetText()

Expand Down Expand Up @@ -111,7 +111,7 @@ func (form *ConnectionForm) inputCapture(connectionPages *models.ConnectionPages
}

switch form.Action {
case NewConnection:
case newConnection:

newDatabases = append(databases, parsedDatabaseData)
err := helpers.SaveConnectionConfig(newDatabases)
Expand All @@ -120,7 +120,7 @@ func (form *ConnectionForm) inputCapture(connectionPages *models.ConnectionPages
return event
}

case EditConnection:
case editConnection:
newDatabases = make([]models.Connection, len(databases))
row, _ := ConnectionListTable.GetSelection()

Expand Down Expand Up @@ -151,7 +151,7 @@ func (form *ConnectionForm) inputCapture(connectionPages *models.ConnectionPages
}

ConnectionListTable.SetConnections(newDatabases)
connectionPages.SwitchToPage(ConnectionsPageName)
connectionPages.SwitchToPage(connectionsPageName)

} else if event.Key() == tcell.KeyF2 {
connectionString := form.GetFormItem(1).(*tview.InputField).GetText()
Expand Down
4 changes: 2 additions & 2 deletions components/ConnectionPage.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ func NewConnectionPages() *models.ConnectionPages {
connectionForm := NewConnectionForm(cp)
connectionSelection := NewConnectionSelection(connectionForm, cp)

cp.AddPage(ConnectionsSelectionPageName, connectionSelection.Flex, true, true)
cp.AddPage(ConnectionsFormPageName, connectionForm.Flex, true, false)
cp.AddPage(connectionsSelectionPageName, connectionSelection.Flex, true, true)
cp.AddPage(connectionsFormPageName, connectionForm.Flex, true, false)

return cp
}
12 changes: 6 additions & 6 deletions components/ConnectionSelection.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,18 @@ func NewConnectionSelection(connectionForm *ConnectionForm, connectionPages *mod
case commands.Connect:
go cs.Connect(selectedConnection)
case commands.EditConnection:
connectionPages.SwitchToPage(ConnectionsFormPageName)
connectionPages.SwitchToPage(connectionsFormPageName)
connectionForm.GetFormItemByLabel("Name").(*tview.InputField).SetText(selectedConnection.Name)
connectionForm.GetFormItemByLabel("URL").(*tview.InputField).SetText(selectedConnection.URL)
connectionForm.StatusText.SetText("")

connectionForm.SetAction(EditConnection)
connectionForm.SetAction(editConnection)
return nil
case commands.DeleteConnection:
confirmationModal := NewConfirmationModal("")

confirmationModal.SetDoneFunc(func(_ int, buttonLabel string) {
MainPages.RemovePage(ConfirmationPageName)
MainPages.RemovePage(confirmationPageName)
confirmationModal = nil

if buttonLabel == "Yes" {
Expand All @@ -115,19 +115,19 @@ func NewConnectionSelection(connectionForm *ConnectionForm, connectionPages *mod
}
})

MainPages.AddPage(ConfirmationPageName, confirmationModal, true, true)
MainPages.AddPage(confirmationPageName, confirmationModal, true, true)

return nil
}
}

switch command {
case commands.NewConnection:
connectionForm.SetAction(NewConnection)
connectionForm.SetAction(newConnection)
connectionForm.GetFormItemByLabel("Name").(*tview.InputField).SetText("")
connectionForm.GetFormItemByLabel("URL").(*tview.InputField).SetText("")
connectionForm.StatusText.SetText("")
connectionPages.SwitchToPage(ConnectionsFormPageName)
connectionPages.SwitchToPage(connectionsFormPageName)
case commands.Quit:
if wrapper.HasFocus() {
app.App.Stop()
Expand Down
2 changes: 1 addition & 1 deletion components/HelpModal.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func NewHelpModal() *HelpModal {
table.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
command := app.Keymaps.Group(app.HomeGroup).Resolve(event)
if command == commands.Quit || command == commands.HelpPopup {
MainPages.RemovePage(HelpPageName)
MainPages.RemovePage(helpPageName)
}
return event
})
Expand Down
30 changes: 15 additions & 15 deletions components/Home.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func NewHomePage(connection models.Connection, dbdriver drivers.Driver) *Home {
home.SetInputCapture(home.homeInputCapture)

home.SetFocusFunc(func() {
if home.FocusedWrapper == FocusedWrapperLeft || home.FocusedWrapper == "" {
if home.FocusedWrapper == focusedWrapperLeft || home.FocusedWrapper == "" {
home.focusLeftWrapper()
} else {
home.focusRightWrapper()
Expand All @@ -82,7 +82,7 @@ func (home *Home) subscribeToTreeChanges() {

for stateChange := range ch {
switch stateChange.Key {
case SelectedTableTree:
case selectedTableTree:
databaseName := home.Tree.GetSelectedDatabase()
tableName := stateChange.Value.(string)

Expand Down Expand Up @@ -117,7 +117,7 @@ func (home *Home) subscribeToTreeChanges() {
}

app.App.ForceDraw()
case IsFilteringTree:
case isFilteringTree:
isFiltering := stateChange.Value.(bool)
if isFiltering {
home.SetInputCapture(nil)
Expand All @@ -140,7 +140,7 @@ func (home *Home) focusRightWrapper() {
home.focusTab(tab)
}

home.FocusedWrapper = FocusedWrapperRight
home.FocusedWrapper = focusedWrapperRight
}

func (home *Home) focusTab(tab *Tab) {
Expand All @@ -166,7 +166,7 @@ func (home *Home) focusTab(tab *Tab) {
App.SetFocus(table)
}

if tab.Name == EditorTabName {
if tab.Name == editorTabName {
home.HelpStatus.SetStatusOnEditorView()
} else {
home.HelpStatus.SetStatusOnTableView()
Expand All @@ -193,7 +193,7 @@ func (home *Home) focusLeftWrapper() {

App.SetFocus(home.Tree)

home.FocusedWrapper = FocusedWrapperLeft
home.FocusedWrapper = focusedWrapperLeft
}

func (home *Home) rightWrapperInputCapture(event *tcell.EventKey) *tcell.EventKey {
Expand Down Expand Up @@ -272,30 +272,30 @@ func (home *Home) homeInputCapture(event *tcell.EventKey) *tcell.EventKey {

switch command {
case commands.MoveLeft:
if table != nil && !table.GetIsEditing() && !table.GetIsFiltering() && home.FocusedWrapper == FocusedWrapperRight {
if table != nil && !table.GetIsEditing() && !table.GetIsFiltering() && home.FocusedWrapper == focusedWrapperRight {
home.focusLeftWrapper()
}
case commands.MoveRight:
if table != nil && !table.GetIsEditing() && !table.GetIsFiltering() && home.FocusedWrapper == FocusedWrapperLeft {
if table != nil && !table.GetIsEditing() && !table.GetIsFiltering() && home.FocusedWrapper == focusedWrapperLeft {
home.focusRightWrapper()
}
case commands.SwitchToEditorView:
tab := home.TabbedPane.GetTabByName(EditorTabName)
tab := home.TabbedPane.GetTabByName(editorTabName)

if tab != nil {
home.TabbedPane.SwitchToTabByName(EditorTabName)
home.TabbedPane.SwitchToTabByName(editorTabName)
tab.Content.SetIsFiltering(true)
} else {
tableWithEditor := NewResultsTable(&home.ListOfDbChanges, home.Tree, home.DBDriver).WithEditor()
home.TabbedPane.AppendTab(EditorTabName, tableWithEditor, EditorTabName)
home.TabbedPane.AppendTab(editorTabName, tableWithEditor, editorTabName)
tableWithEditor.SetIsFiltering(true)
}
home.HelpStatus.SetStatusOnEditorView()
home.focusRightWrapper()
App.ForceDraw()
case commands.SwitchToConnectionsView:
if (table != nil && !table.GetIsEditing() && !table.GetIsFiltering() && !table.GetIsLoading()) || table == nil {
MainPages.SwitchToPage(ConnectionsPageName)
MainPages.SwitchToPage(connectionsPageName)
}
case commands.Quit:
if tab != nil {
Expand All @@ -312,7 +312,7 @@ func (home *Home) homeInputCapture(event *tcell.EventKey) *tcell.EventKey {
confirmationModal := NewConfirmationModal("")

confirmationModal.SetDoneFunc(func(_ int, buttonLabel string) {
MainPages.RemovePage(ConfirmationPageName)
MainPages.RemovePage(confirmationPageName)
confirmationModal = nil

if buttonLabel == "Yes" {
Expand All @@ -332,7 +332,7 @@ func (home *Home) homeInputCapture(event *tcell.EventKey) *tcell.EventKey {
}
})

MainPages.AddPage(ConfirmationPageName, confirmationModal, true, true)
MainPages.AddPage(confirmationPageName, confirmationModal, true, true)
}
case commands.HelpPopup:
if table == nil || !table.GetIsEditing() {
Expand All @@ -345,7 +345,7 @@ func (home *Home) homeInputCapture(event *tcell.EventKey) *tcell.EventKey {
// }
// return event
// })
MainPages.AddPage(HelpPageName, home.HelpModal, true, true)
MainPages.AddPage(helpPageName, home.HelpModal, true, true)
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/Pages.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ var MainPages = tview.NewPages()

func init() {
MainPages.SetBackgroundColor(tview.Styles.PrimitiveBackgroundColor)
MainPages.AddPage(ConnectionsPageName, NewConnectionPages().Flex, true, true)
MainPages.AddPage(connectionsPageName, NewConnectionPages().Flex, true, true)
}
2 changes: 1 addition & 1 deletion components/ResultTableFilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (filter *ResultsTableFilter) Subscribe() chan models.StateChange {
func (filter *ResultsTableFilter) Publish(message string) {
for _, sub := range filter.subscribers {
sub <- models.StateChange{
Key: FilteringResultsTable,
Key: filteringResultsTable,
Value: message,
}
}
Expand Down
Loading

0 comments on commit 9792cca

Please sign in to comment.