Skip to content

Commit

Permalink
Merge pull request #6 from mirislomovmirjalol/delete-project-from-ui
Browse files Browse the repository at this point in the history
feat: delete from UI
  • Loading branch information
mirislomovmirjalol authored May 21, 2024
2 parents 0ea7bd5 + 87bd602 commit 5159903
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
12 changes: 12 additions & 0 deletions internal/service/projectService.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,15 @@ func UpdateProject(projectName string, filePath string) error {

return nil
}

func DeleteProject(projectName string) error {
boltDBStore := store.GetStore()
defer boltDBStore.Close()

err := boltDBStore.Delete("Projects", projectName)
if err != nil {
return err
}

return nil
}
10 changes: 10 additions & 0 deletions ui/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,16 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch msg.Type {
case tea.KeyBackspace:
err := service.DeleteProject(m.projects[m.cursor])
if err != nil {
log.Fatal(err)
}
m.projects = append(m.projects[:m.cursor], m.projects[m.cursor+1:]...)
if m.cursor > 0 {
m.cursor--
}
return m, nil
case tea.KeyUp:
if m.cursor > 0 {
m.cursor--
Expand Down
2 changes: 1 addition & 1 deletion ui/style.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ var unfocused = lipgloss.NewStyle()
var focused = lipgloss.NewStyle().
Foreground(lipgloss.Color("#a78bfa"))
var navigationHelper = "" +
"Up / Down: Navigate | Enter: Select | Ctrl+C: Quit"
"Up / Down: Navigate | Enter: Select | Backspace: Delete | Ctrl+C: Quit"

var title = lipgloss.NewStyle().Padding(1, 8).Background(lipgloss.Color("#7e22ce"))

0 comments on commit 5159903

Please sign in to comment.