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: add copy mode for yanking task id, url and short md #89

Merged
merged 8 commits into from
May 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 9 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
module github.com/prgrs/clickup

go 1.18
go 1.21

require (
github.com/charmbracelet/bubbletea v0.24.2
github.com/charmbracelet/glamour v0.6.0
github.com/charmbracelet/lipgloss v0.9.1
github.com/charmbracelet/log v0.3.1
github.com/spf13/pflag v1.0.5
golang.design/x/clipboard v0.7.0
golang.org/x/term v0.13.0
)

Expand All @@ -25,6 +26,9 @@ require (
github.com/yuin/goldmark v1.5.2 // indirect
github.com/yuin/goldmark-emoji v1.0.1 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/exp/shiny v0.0.0-20240506185415-9bf2ced13842 // indirect
golang.org/x/image v0.14.0 // indirect
golang.org/x/mobile v0.0.0-20231127183840-76ac6878050a // indirect
golang.org/x/net v0.16.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Expand All @@ -42,10 +46,10 @@ require (
github.com/mattn/go-runewidth v0.0.15
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/reflow v0.3.0
github.com/muesli/termenv v0.15.2 // indirect
github.com/rivo/uniseg v0.2.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
golang.org/x/sync v0.5.0
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
)
22 changes: 16 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl
github.com/kkyr/fig v0.3.2 h1:+vMj52FL6RJUxeKOBB6JXIMyyi1/2j1ERDrZXjoBjzM=
github.com/kkyr/fig v0.3.2/go.mod h1:ItUILF8IIzgZOMhx5xpJ1W/bviQsWRKOwKXfE/tqUoA=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
Expand Down Expand Up @@ -74,31 +75,40 @@ github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.5.2 h1:ALmeCk/px5FSm1MAcFBAsVKZjDuMVj8Tm7FFIlMJnqU=
github.com/yuin/goldmark v1.5.2/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/yuin/goldmark-emoji v1.0.1 h1:ctuWEyzGBwiucEqxzwe0SOYDXPAucOrE9NQC18Wa1os=
github.com/yuin/goldmark-emoji v1.0.1/go.mod h1:2w1E6FEWLcDQkoTE+7HU6QF1F6SLlNGjRIBbIZQFqkQ=
golang.design/x/clipboard v0.7.0 h1:4Je8M/ys9AJumVnl8m+rZnIvstSnYj1fvzqYrU3TXvo=
golang.design/x/clipboard v0.7.0/go.mod h1:PQIvqYO9GP29yINEfsEn5zSQKAz3UgXmZKzDA6dnq2E=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
golang.org/x/exp/shiny v0.0.0-20240506185415-9bf2ced13842 h1:kEvPiBVeT1JJGw/3THfe1W1zvTAvU1V6pCFV0icZvQs=
golang.org/x/exp/shiny v0.0.0-20240506185415-9bf2ced13842/go.mod h1:3F+MieQB7dRYLTmnncoFbb1crS5lfQoTfDgQy6K4N0o=
golang.org/x/image v0.14.0 h1:tNgSxAFe3jC4uYqvZdTr84SZoM1KfwdC9SKIFrLjFn4=
golang.org/x/image v0.14.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
golang.org/x/mobile v0.0.0-20231127183840-76ac6878050a h1:sYbmY3FwUWCBTodZL1S3JUuOvaW6kM2o+clDzzDNBWg=
golang.org/x/mobile v0.0.0-20231127183840-76ac6878050a/go.mod h1:Ede7gF0KGoHlj822RtphAHK1jLdrcuRBZg0sF1Q+SPc=
golang.org/x/net v0.0.0-20221002022538-bcab6841153b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/net v0.16.0 h1:7eBu7KsSvFDtSXUIDbh3aqlK4DPsZ1rByC8PFfBThos=
golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ=
golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=
golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/prgrs/clickup/ui"
"github.com/prgrs/clickup/ui/context"
"github.com/spf13/pflag"
"golang.design/x/clipboard"
)

const (
Expand Down Expand Up @@ -140,10 +141,16 @@ func main() {
}
}

logger.Info("Loading cache...")
if err := cache.Load(); err != nil {
termLogger.Fatal(err)
}

logger.Info("Initializing clipboard...")
if err := clipboard.Init(); err != nil {
termLogger.Fatal(err)
}

logger.Info("Initializing api...")
api := api.NewApi(logger, cache, cfg.Token)

Expand Down
11 changes: 10 additions & 1 deletion ui/components/table-tasks/taskstable.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ func InitialModel(ctx *context.UserContext, logger *log.Logger) Model {
Column: table.NewFlexColumn("url", "url", 0),
Hidden: true,
},
{
Column: table.NewFlexColumn("id", "id", 0),
Hidden: true,
},
}
columnsVisible := []Column{
{
Expand Down Expand Up @@ -266,7 +270,12 @@ func (m Model) GetFocused() bool {
return m.Focused
}

func (m Model) SetFocused(f bool) Model {
func (m Model) WithFocused(f bool) Model {
m.Focused = f
return m
}

func (m *Model) SetFocused(f bool) *Model {
m.Focused = f
return m
}
Expand Down
20 changes: 4 additions & 16 deletions ui/components/table-tasks/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ func taskToRow(task clickup.Task, columns []string) table.Row {
values[column] = task.Name
case "url":
values[column] = task.Url
case "id":
values[column] = task.Id
// After migration from charm to evertras/bubble-table I temporary removed all columns
// except "status" and "name" since they are not supported yet. See autoColumns feature
// case "assignee":
Expand Down Expand Up @@ -55,22 +57,8 @@ func rowToTask(row table.Row, columns []string) clickup.Task {
task.Name = data[column].(string)
case "url":
task.Url = data[column].(string)
// After migration from charm to evertras/bubble-table I temporary removed all columns
// except "status" and "name" since they are not supported yet. See autoColumns feature
// case "assignee":
// values = append(values, task.GetAssignees())
// case "list":
// values = append(values, task.List.String())
// case "tags":
// values = append(values, task.GetTags())
// case "folder":
// values = append(values, task.Folder.String())
// case "url":
// values = append(values, task.Url)
// case "space":
// values = append(values, task.Space.Id)
// case "id":
// values = append(values, task.Id)
case "id":
task.Id = data[column].(string)
}
}

Expand Down
14 changes: 12 additions & 2 deletions ui/components/tasks-sidebar/tasksidebar.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,12 @@ func (m Model) GetFocused() bool {
return m.Focused
}

func (m Model) SetFocused(f bool) Model {
func (m Model) WithFocused(f bool) Model {
m.Focused = f
return m
}

func (m *Model) SetFocused(f bool) *Model {
m.Focused = f
return m
}
Expand All @@ -173,7 +178,12 @@ func (m Model) GetHidden() bool {
return m.Hidden
}

func (m Model) SetHidden(h bool) Model {
func (m *Model) SetHidden(h bool) *Model {
m.Hidden = h
return m
}

func (m Model) WithHidden(h bool) Model {
m.Hidden = h
return m
}
Expand Down
5 changes: 5 additions & 0 deletions ui/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ type WindowSize struct {
MetaHeight int
}

func (w *WindowSize) Set(width, height int) {
w.Width = width
w.Height = height
}

func NewUserContext(logger *log.Logger, api *api.Api, config *config.Config) UserContext {
return UserContext{
Style: theme.DefautlStyle,
Expand Down
7 changes: 7 additions & 0 deletions ui/theme/theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@ import (
"github.com/charmbracelet/lipgloss"
)

const (
ColorWhite = lipgloss.Color("#FFFFFF")
ColorBlack = lipgloss.Color("#000000")
)

type Theme struct {
BordersColorActive lipgloss.Color
BordersColorInactive lipgloss.Color
BordersColorCopyMode lipgloss.Color
}

var DefaultTheme = &Theme{
BordersColorActive: lipgloss.Color("#8909FF"),
BordersColorInactive: lipgloss.Color("#FFF"),
BordersColorCopyMode: lipgloss.Color("#e6cc00"),
}
6 changes: 1 addition & 5 deletions ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,8 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
"Received: tea.WindowSizeMsg",
"width", msg.Width,
"height", msg.Height)
m.ctx.WindowSize.Set(msg.Width, msg.Height)

m.ctx.WindowSize.Width = msg.Width
m.ctx.WindowSize.Height = msg.Height
m.ctx.WindowSize.Height = msg.Height
m.ctx.WindowSize.Height = msg.Height
m.ctx.WindowSize.Height = msg.Height
}

m.viewCompact, cmd = m.viewCompact.Update(msg)
Expand Down
Loading
Loading