Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚨 feat: rework ui 🚨 #77

Merged
merged 47 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
e0ae7a3
fix: invalid keymap func signature
Mar 25, 2024
c09d39e
feat(api): add GetViewsFromWorkspace func
Apr 4, 2024
93b05b7
working
Apr 4, 2024
fc82e74
working
Apr 4, 2024
2689d64
working
Apr 4, 2024
7699c0e
working
Apr 4, 2024
781f451
working
Apr 4, 2024
345235c
working
Apr 4, 2024
8902c39
asd
Apr 4, 2024
99ba6c8
working
Apr 4, 2024
0059ff6
working
Apr 4, 2024
1e29d8e
working
Apr 4, 2024
96f63a7
working
Apr 4, 2024
48eab42
stash
Apr 5, 2024
bf353c0
chore: fix rendering empty enitites
prgres May 13, 2024
7af6465
fix: moreTabsIcon if no more
prgres May 15, 2024
1913bf4
chore: move componenet taskstable into tasks widget
prgres May 15, 2024
98ff9c6
chore: add navigator panes titles
prgres May 16, 2024
be51fb8
fix: preview msg log
prgres May 16, 2024
1a755b2
feat: change state to task on selecting list
prgres May 16, 2024
37b89a3
chore: remove enter as toogluing task keymap
prgres May 17, 2024
c7e556c
chore: remap open in url from p to u
prgres May 17, 2024
53977eb
feat: add default style and theme
prgres May 17, 2024
cc1cbf0
chore: use borders theme from ctx
prgres May 17, 2024
3534f56
chore: use borders style from ctx
prgres May 17, 2024
ea57326
chore: remove stashed comments
prgres May 17, 2024
643d21a
chore: deprecated old cache invalidation func to slower but stable
prgres May 17, 2024
fcfde39
chore: remove another stashed comments
prgres May 17, 2024
8a76100
fix: restore help widget
prgres May 17, 2024
c509afe
feat: add sidebar
prgres May 17, 2024
d6f105d
chore: remove unused resources
prgres May 17, 2024
a897849
chore: tidy
prgres May 17, 2024
b4d0742
chore: remove stashed comments
prgres May 17, 2024
80eb795
chore: unified keymap for url open
prgres May 17, 2024
ef5507f
cleanup
prgres May 17, 2024
34543b5
chore: hide keymap field
prgres May 17, 2024
b59e973
fix: hiding sidebar
prgres May 17, 2024
4db63f7
fix: lefover
prgres May 17, 2024
80f1f7c
chore: cleanup
prgres May 17, 2024
bdb8d07
fix: if list not empty, load task into sidebar (even if hidden)
prgres May 17, 2024
ca92f7a
fix: lint
prgres May 17, 2024
7c5a264
fix: workspace change preview
prgres May 17, 2024
1a6131b
fix
prgres May 17, 2024
45e812c
Merge remote-tracking branch 'origin/main' into feat/rework-ui
prgres May 19, 2024
9afd25d
Merge remote-tracking branch 'origin/main' into feat/rework-ui
prgres May 19, 2024
4fb43d4
Merge remote-tracking branch 'origin/main' into feat/rework-ui
prgres May 19, 2024
9c506e2
chore: remove unused taskstabs widget
prgres May 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ require (
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
golang.org/x/sync v0.4.0 // indirect
golang.org/x/sync v0.4.0
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
)
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E=
github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
github.com/evertras/bubble-table v0.15.4 h1:iqsVVnSKNcbVV0miLJhtME2S8SNHE/O7UL7n2OairJI=
github.com/evertras/bubble-table v0.15.4/go.mod h1:SPOZKbIpyYWPHBNki3fyNpiPBQkvkULAtOT7NTD5fKY=
github.com/evertras/bubble-table v0.15.5 h1:vMsjp0FI7lEyzJG8fT2WRmg0OhVfgMf1a0P7r/ekXPY=
github.com/evertras/bubble-table v0.15.5/go.mod h1:SPOZKbIpyYWPHBNki3fyNpiPBQkvkULAtOT7NTD5fKY=
github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4=
Expand Down
40 changes: 36 additions & 4 deletions ui/common/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,33 @@ func FocusCmd() tea.Cmd {

type SpaceChangeMsg string

func SpaceChangeCmd(space string) tea.Cmd {
func SpaceChangeCmd(id string) tea.Cmd {
return func() tea.Msg {
return SpaceChangeMsg(space)
return SpaceChangeMsg(id)
}
}

type SpacePreviewMsg string

func SpacePreviewCmd(id string) tea.Cmd {
return func() tea.Msg {
return SpacePreviewMsg(id)
}
}

type FolderChangeMsg string

func FolderChangeCmd(space string) tea.Cmd {
func FolderChangeCmd(id string) tea.Cmd {
return func() tea.Msg {
return FolderChangeMsg(id)
}
}

type FolderPreviewMsg string

func FolderPreviewCmd(id string) tea.Cmd {
return func() tea.Msg {
return FolderChangeMsg(space)
return FolderPreviewMsg(id)
}
}

Expand All @@ -36,6 +52,14 @@ func ListChangeCmd(id string) tea.Cmd {
}
}

type ListPreviewMsg string

func ListPreviewCmd(id string) tea.Cmd {
return func() tea.Msg {
return ListPreviewMsg(id)
}
}

type WorkspaceChangeMsg string

func WorkspaceChangeCmd(workspace string) tea.Cmd {
Expand All @@ -44,6 +68,14 @@ func WorkspaceChangeCmd(workspace string) tea.Cmd {
}
}

type WorkspacePreviewMsg string

func WorkspacePreviewCmd(workspace string) tea.Cmd {
return func() tea.Msg {
return WorkspacePreviewMsg(workspace)
}
}

type BackToPreviousViewMsg ViewId

func BackToPreviousViewCmd(currentView ViewId) tea.Cmd {
Expand Down
12 changes: 3 additions & 9 deletions ui/common/keymaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,9 @@ func NewEmptyKeyMap() help.KeyMap {
)
}

var (
KeyBindingBack = key.NewBinding(
key.WithKeys("escape"),
key.WithHelp("escape", "back to previous view"),
)
KeyBindingOpenInBrowser = key.NewBinding(
key.WithKeys("p"),
key.WithHelp("p", "open in browser"),
)
var KeyBindingBack = key.NewBinding(
key.WithKeys("escape"),
key.WithHelp("escape", "back to previous view"),
)

type KeyMap struct {
Expand Down
2 changes: 2 additions & 0 deletions ui/common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ type ViewId string

type WidgetId string

type ComponentId string

type View interface {
View() string
KeyMap() help.KeyMap
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package folders
package folderslist

import tea "github.com/charmbracelet/bubbletea"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package folders
package folderslist

import (
"github.com/charmbracelet/bubbles/help"
Expand All @@ -11,13 +11,13 @@ import (
"github.com/prgrs/clickup/ui/context"
)

const WidgetId = "widgetFoldersList"
const ComponentId = "widgetFoldersList"

type Model struct {
list list.Model
ctx *context.UserContext
log *log.Logger
WidgetId common.WidgetId
ComponentId common.ComponentId
SelectedSpace string
SelectedFolder string
folders []clickup.Folder
Expand All @@ -36,11 +36,12 @@ func InitialModel(ctx *context.UserContext, logger *log.Logger) Model {
0, 0)
l.KeyMap.Quit.Unbind()
l.SetShowHelp(false)
l.Title = "Folders"

log := logger.WithPrefix(logger.GetPrefix() + "/" + WidgetId)
log := logger.WithPrefix(logger.GetPrefix() + "/" + ComponentId)

return Model{
WidgetId: WidgetId,
ComponentId: ComponentId,
list: l,
ctx: ctx,
SelectedFolder: "",
Expand Down Expand Up @@ -83,7 +84,29 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
selectedFolder := listitem.BubblesItemToItem(m.list.SelectedItem()).Description()
m.log.Infof("Selected folder %s", selectedFolder)
m.SelectedFolder = selectedFolder
cmds = append(cmds, FolderChangeCmd(selectedFolder))
return m, FolderChangeCmd(selectedFolder)

case "J", "shift+down":
m.list.CursorDown()
if m.list.SelectedItem() == nil {
m.log.Info("List is empty")
break
}
selectedFolder := listitem.BubblesItemToItem(m.list.SelectedItem()).Description()
m.log.Infof("Selected folder %s", selectedFolder)
m.SelectedFolder = selectedFolder
return m, common.FolderPreviewCmd(selectedFolder)

case "K", "shift+up":
m.list.CursorUp()
if m.list.SelectedItem() == nil {
m.log.Info("List is empty")
break
}
selectedFolder := listitem.BubblesItemToItem(m.list.SelectedItem()).Description()
m.log.Infof("Selected folder %s", selectedFolder)
m.SelectedFolder = selectedFolder
return m, common.FolderPreviewCmd(selectedFolder)
}
}

Expand All @@ -102,13 +125,12 @@ func (m Model) Init() tea.Cmd {
return nil
}

func (m Model) SetSize(s common.Size) Model {
func (m *Model) SetSize(s common.Size) {
m.list.SetSize(s.Width, s.Height)
return m
}

func (m *Model) SpaceChange(id string) error {
m.log.Infof("Received: SpaceChangeMsg: %s", id)
func (m *Model) SpaceChanged(id string) error {
m.log.Infof("Received: SpaceChangedMsg: %s", id)
m.SelectedSpace = id

folders, err := m.ctx.Api.GetFolders(id)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package folders
package folderslist

import (
"github.com/prgrs/clickup/pkg/clickup"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lists
package listslist

import (
tea "github.com/charmbracelet/bubbletea"
Expand Down
38 changes: 30 additions & 8 deletions ui/widgets/lists/lists.go → ui/components/lists-list/lists.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lists
package listslist

import (
"github.com/charmbracelet/bubbles/help"
Expand All @@ -11,13 +11,13 @@ import (
"github.com/prgrs/clickup/ui/context"
)

const WidgetId = "viewLists"
const ComponentId = "viewLists"

type Model struct {
list list.Model
ctx *context.UserContext
log *log.Logger
WidgetId common.WidgetId
ComponentId common.ComponentId
SelectedList string
SelectedFolder string
lists []clickup.List
Expand All @@ -29,11 +29,12 @@ func InitialModel(ctx *context.UserContext, logger *log.Logger) Model {
0, 0)
l.KeyMap.Quit.Unbind()
l.SetShowHelp(false)
l.Title = "Lists"

log := logger.WithPrefix(logger.GetPrefix() + "/" + WidgetId)
log := logger.WithPrefix(logger.GetPrefix() + "/" + ComponentId)

return Model{
WidgetId: WidgetId,
ComponentId: ComponentId,
list: l,
ctx: ctx,
SelectedFolder: "",
Expand Down Expand Up @@ -77,7 +78,29 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
selectedList := listitem.BubblesItemToItem(m.list.SelectedItem()).Description()
m.log.Infof("Selected list %s", selectedList)
m.SelectedList = selectedList
cmds = append(cmds, ListChangedCmd(m.SelectedList))
return m, ListChangedCmd(m.SelectedList)

case "J", "shift+down":
m.list.CursorDown()
if m.list.SelectedItem() == nil {
m.log.Info("List is empty")
break
}
selectedList := listitem.BubblesItemToItem(m.list.SelectedItem()).Description()
m.log.Infof("Selected list %s", selectedList)
m.SelectedList = selectedList
return m, common.ListPreviewCmd(m.SelectedList)

case "K", "shift+up":
m.list.CursorUp()
if m.list.SelectedItem() == nil {
m.log.Info("List is empty")
break
}
selectedList := listitem.BubblesItemToItem(m.list.SelectedItem()).Description()
m.log.Infof("Selected list %s", selectedList)
m.SelectedList = selectedList
return m, common.ListPreviewCmd(m.SelectedList)
}
}

Expand All @@ -96,9 +119,8 @@ func (m Model) Init() tea.Cmd {
return nil
}

func (m Model) SetSize(size common.Size) Model {
func (m *Model) SetSize(size common.Size) {
m.list.SetSize(size.Width, size.Height)
return m
}

func (m *Model) SpaceChanged(id string) error {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package lists
package listslist

import (
"github.com/prgrs/clickup/pkg/clickup"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package spaces
package spaceslist

import tea "github.com/charmbracelet/bubbletea"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package spaces
package spaceslist

import (
"github.com/charmbracelet/bubbles/help"
Expand All @@ -11,13 +11,13 @@ import (
"github.com/prgrs/clickup/ui/context"
)

const WidgetId = "spacesList"
const ComponentId = "spacesList"

type Model struct {
list list.Model
ctx *context.UserContext
log *log.Logger
WidgetId common.WidgetId
ComponentId common.ComponentId
SelectedSpace string
SelectedWorkspace string
spaces []clickup.Space
Expand All @@ -36,11 +36,12 @@ func InitialModel(ctx *context.UserContext, logger *log.Logger) Model {
0, 0)
l.KeyMap.Quit.Unbind()
l.SetShowHelp(false)
l.Title = "Spaces"

log := logger.WithPrefix(logger.GetPrefix() + "/" + WidgetId)
log := logger.WithPrefix(logger.GetPrefix() + "/" + ComponentId)

return Model{
WidgetId: WidgetId,
ComponentId: ComponentId,
list: l,
ctx: ctx,
SelectedSpace: "",
Expand Down Expand Up @@ -84,7 +85,29 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
selectedSpace := listitem.BubblesItemToItem(m.list.SelectedItem()).Description()
m.log.Infof("Selected space %s", selectedSpace)
m.SelectedSpace = selectedSpace
cmds = append(cmds, SpaceChangedCmd(selectedSpace))
return m, SpaceChangedCmd(selectedSpace)

case "J", "shift+down":
m.list.CursorDown()
if m.list.SelectedItem() == nil {
m.log.Info("List is empty")
break
}
selectedSpace := listitem.BubblesItemToItem(m.list.SelectedItem()).Description()
m.log.Info("Selected space", "space", selectedSpace)
m.SelectedSpace = selectedSpace
return m, common.SpacePreviewCmd(selectedSpace)

case "K", "shift+up":
m.list.CursorUp()
if m.list.SelectedItem() == nil {
m.log.Info("List is empty")
break
}
selectedSpace := listitem.BubblesItemToItem(m.list.SelectedItem()).Description()
m.log.Info("Selected space", "space", selectedSpace)
m.SelectedSpace = selectedSpace
return m, common.SpacePreviewCmd(selectedSpace)
}
}

Expand All @@ -103,9 +126,8 @@ func (m Model) Init() tea.Cmd {
return nil
}

func (m Model) SetSize(s common.Size) Model {
func (m *Model) SetSize(s common.Size) {
m.list.SetSize(s.Width, s.Height)
return m
}

func (m *Model) WorkspaceChanged(id string) error {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package spaces
package spaceslist

import (
"github.com/prgrs/clickup/pkg/clickup"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package taskstable
package tabletasks

import (
tea "github.com/charmbracelet/bubbletea"
Expand Down
Loading
Loading