Skip to content

Commit

Permalink
feat: open workflow job
Browse files Browse the repository at this point in the history
  • Loading branch information
topaxi committed Apr 14, 2023
1 parent 9f2fcf1 commit 6206111
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lua/gh-actions/github.lua
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ end
---@field conclusion string
---@field name string
---@field steps GhWorkflowRunJobStep[]
---@field url string
---@field html_url string

---@class GhWorkflowRunJobsResponse
---@field total_count number
Expand Down
8 changes: 8 additions & 0 deletions lua/gh-actions/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@ function M.open()
ui.split:map('n', 'q', M.close, { noremap = true })

ui.split:map('n', '<cr>', function()
local workflow_job = ui.get_workflow_job()

if workflow_job then
utils.open(workflow_job.html_url)

return
end

local workflow_run = ui.get_workflow_run()

if workflow_run then
Expand Down
13 changes: 13 additions & 0 deletions lua/gh-actions/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ function M.get_workflow_run(line)
end
end

---TODO: This should be a local function
---@param line? integer
---@return GhWorkflowRunJob|nil
function M.get_workflow_job(line)
line = get_cursor_line(line)

for _, loc in ipairs(M.renderer.locations) do
if loc.kind == 'workflow_job' and line >= loc.from and line <= loc.to then
return loc.value
end
end
end

local function is_visible()
return M.split.bufnr ~= nil and vim.bo[M.split.bufnr] ~= nil
end
Expand Down

0 comments on commit 6206111

Please sign in to comment.