This commit is contained in:
Patrick Nisble
2026-06-01 09:56:50 +02:00
parent 7c6c3d7223
commit 5c2016a05c
14 changed files with 1140 additions and 261 deletions
+45 -14
View File
@@ -1,12 +1,15 @@
local curl = require("plenary.curl")
local notify = require("snacks.notifier").notify
local gitlab = require("eta.gitlab")
local clickup = require("eta.clickup")
local M = {}
local curl = require("plenary.curl")
local notifier = require("snacks.notifier")
local notify = require("snacks.notifier").notify
local gitlab = require("eta.gitlab")
local clickup = require("eta.clickup")
local helpers = require("eta.helpers")
local nio = require("nio")
local M = {}
---@param data table
---@return string | nil
M.table_to_yaml = function(data)
M.table_to_yaml = function(data)
local json = vim.json.encode(data)
-- Nutzt 'yq' um JSON zu YAML zu konvertieren
@@ -23,7 +26,7 @@ end
---@param yaml_string string
---@return table | nil
M.yaml_to_table = function(yaml_string)
M.yaml_to_table = function(yaml_string)
-- 1. YAML String in yq einspeisen und JSON ausgeben lassen
-- Das Flag -o=json sorgt für die Konvertierung
local temp_file = os.tmpname()
@@ -68,7 +71,7 @@ end
M.clickup_session = nil
---@type eta.gitlab.Session
M.gitlab_session = nil
M.gitlab_session = nil
---@param task eta.clickup.Task
@@ -82,6 +85,27 @@ M._update_task = function(task)
end
end
local last_task = clickup.task(M.clickup_session, task.id)
if task.status == "in review" and last_task.status.status == "in progress" then
local resp = curl.post(M.clickup_session.base_url .. "/task/" .. task.id .. "/comment", {
headers = {
['Authorization'] = M.clickup_session.auth,
["accept"] = "application/json",
["content-type"] = "application/json",
},
body = vim.json.encode({
comment_text = "pls review",
assignee = M.clickup_session.default_reviewer,
notify_all = "false",
})
})
if resp.status ~= 200 then
error("failed to comment " .. task.id .. "\n(" .. resp.body .. ")")
end
end
local resp = curl.put(M.clickup_session.base_url .. "/task/" .. task.id, {
headers = {
['Authorization'] = M.clickup_session.auth,
@@ -149,7 +173,7 @@ M._on_select_task = function(picker, item)
-- vim.api.nvim_set_option_value("buftype", "nofile", { buf = new_buf_no })
vim.api.nvim_set_option_value("filetype", "markdown", { buf = new_buf_no })
vim.api.nvim_create_autocmd({ "BufWriteCmd" }, { buffer = new_buf_no, callback = M._on_tempbuf_write })
local content = { "---"}
local content = { "---" }
local to_dump = {}
for _, k in ipairs({ "id", "name", "status", "tags", "list", "parent", "dependencies" }) do
to_dump[k] = item[k]
@@ -228,7 +252,7 @@ end
---@param id string
M.open_task = function(id)
if id:match("[a-z0-9]+") then
local notif_id = notify("opening #".. id, "info", { timeout = 1000, title = "ETA", style = 'fancy' })
local notif_id = notify("opening #" .. id, "info", { timeout = 1000, title = "ETA", style = 'fancy' })
local t = clickup.task(M.clickup_session, id)
---@type SelectionItem
local item = {
@@ -246,7 +270,7 @@ M.open_task = function(id)
},
action = nil
}
pcall(M._on_select_task,nil, item)
pcall(M._on_select_task, nil, item)
else
error("invalid id format")
end
@@ -255,12 +279,19 @@ end
---@param data vim.api.keyset.create_user_command.command_args
M.select_task = function(data)
local notif_id = notify("fetching tasks", "warn", { timeout = 10000, title = "ETA", style = 'fancy' })
if not pcall(M.open_task,vim.fn.expand("<cword>")) then
local tasks = clickup.latest_tasks(M.clickup_session)
local args = data.fargs
if args[1] == "start" then
return
end
if not pcall(M.open_task, vim.fn.expand("<cword>")) then
---@type SelectionItem[]
local items = {}
local tasks = clickup.latest_tasks(M.clickup_session)
for tix, t in ipairs(tasks) do
if string.sub(t.name, -7, -1) ~= "Absence" then
local preview_frontmatter = ""
@@ -288,7 +319,7 @@ M.select_task = function(data)
action = M._on_select_task
}
for _, k in ipairs({ "id", "name", "status", "tags", "parent"}) do
for _, k in ipairs({ "id", "name", "status", "tags", "parent" }) do
preview_frontmatter = preview_frontmatter .. "\n" .. k .. ": " .. vim.json.encode(prepared[k])
end