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

Revert "feat: projects v2 support" #474

Merged
merged 1 commit into from
Jan 12, 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
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ Edit and review GitHub issues and pull requests from the comfort of your favorit

- Install [GitHub CLI](https://cli.github.com/)
- Install [plenary.nvim](https://github.com/nvim-lua/plenary.nvim)
- Install one of:
- [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim)
- [fzf-lua](https://github.com/ibhagwan/fzf-lua)
- Install [telescope.nvim](https://github.com/nvim-telescope/telescope.nvim)
- Install [nvim-web-devicons](https://github.com/nvim-tree/nvim-web-devicons)

## 📦 Installation
Expand All @@ -75,7 +73,6 @@ use {
requires = {
'nvim-lua/plenary.nvim',
'nvim-telescope/telescope.nvim',
-- OR 'ibhagwan/fzf-lua',
'nvim-tree/nvim-web-devicons',
},
config = function ()
Expand Down Expand Up @@ -115,14 +112,9 @@ require"octo".setup({
snippet_context_lines = 4; -- number or lines around commented lines
gh_env = {}, -- extra environment variables to pass on to GitHub CLI, can be a table or function returning a table
timeout = 5000, -- timeout for requests between the remote server
default_to_projects_v2 = false, -- use projects v2 for the `Octo card ...` command by default. Both legacy and v2 commands are available under `Octo cardlegacy ...` and `Octo cardv2 ...` respectively.
ui = {
use_signcolumn = true, -- show "modified" marks on the sign column
},
picker = "telescope", -- "telescope" | "fzf-lua"
picker_config = {
use_emojis = false, -- Only used in fzf-lua picker. If you want emojis when viewing the picker set to true.
},
issues = {
order_by = { -- criteria to sort results of `Octo issue list`
field = "CREATED_AT", -- either COMMENTS, CREATED_AT or UPDATED_AT (https://docs.github.com/en/graphql/reference/enums#issueorderfield)
Expand Down
111 changes: 1 addition & 110 deletions lua/octo/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,6 @@ function M.setup()
vim.api.nvim_create_user_command("Octo", function(opts)
require("octo.commands").octo(unpack(opts.fargs))
end, { complete = require("octo.completion").octo_command_complete, nargs = "*" })
local conf = config.values

local card_commands

if conf.default_to_projects_v2 then
card_commands = {
set = function()
M.set_project_v2_card()
end,
remove = function()
M.remove_project_v2_card()
end,
}
else
card_commands = {
add = function()
M.add_project_card()
end,
move = function()
M.move_project_card()
end,
remove = function()
M.remove_project_card()
end,
}
end

-- supported commands
M.commands = {
Expand Down Expand Up @@ -321,16 +295,7 @@ function M.setup()
M.reaction_action "HEART"
end,
},
card = card_commands,
cardv2 = {
set = function(...)
M.set_project_v2_card()
end,
remove = function()
M.remove_project_v2_card()
end,
},
cardlegacy = {
card = {
add = function()
M.add_project_card()
end,
Expand Down Expand Up @@ -1326,80 +1291,6 @@ function M.move_project_card()
end)
end

function M.set_project_v2_card()
local bufnr = vim.api.nvim_get_current_buf()
local buffer = octo_buffers[bufnr]
if not buffer then
return
end

-- show column selection picker
picker.project_columns_v2(function(project_id, field_id, value)
-- add new card
local add_query = graphql("add_project_v2_item_mutation", buffer.node.id, project_id)
gh.run {
args = { "api", "graphql", "--paginate", "-f", string.format("query=%s", add_query) },
cb = function(add_output, add_stderr)
if add_stderr and not utils.is_blank(add_stderr) then
utils.error(add_stderr)
elseif add_output then
local resp = vim.fn.json_decode(add_output)
local update_query = graphql(
"update_project_v2_item_mutation",
project_id,
resp.data.addProjectV2ItemById.item.id,
field_id,
value
)
gh.run {
args = { "api", "graphql", "--paginate", "-f", string.format("query=%s", update_query) },
cb = function(update_output, update_stderr)
if update_stderr and not utils.is_blank(update_stderr) then
utils.error(update_stderr)
elseif update_output then
-- TODO do update here
-- refresh issue/pr details
require("octo").load(buffer.repo, buffer.kind, buffer.number, function(obj)
writers.write_details(bufnr, obj, true)
buffer.node.projectCards = obj.projectCards
end)
end
end,
}
end
end,
}
end)
end

function M.remove_project_v2_card()
local bufnr = vim.api.nvim_get_current_buf()
local buffer = octo_buffers[bufnr]
if not buffer then
return
end

-- show card selection picker
picker.project_cards_v2(function(project_id, item_id)
-- delete card
local query = graphql("delete_project_v2_item_mutation", project_id, item_id)
gh.run {
args = { "api", "graphql", "--paginate", "-f", string.format("query=%s", query) },
cb = function(output, stderr)
if stderr and not utils.is_blank(stderr) then
utils.error(stderr)
elseif output then
-- refresh issue/pr details
require("octo").load(buffer.repo, buffer.kind, buffer.number, function(obj)
buffer.node.projectCards = obj.projectCards
writers.write_details(bufnr, obj, true)
end)
end
end,
}
end)
end

function M.reload(bufnr)
require("octo").load_buffer(bufnr)
end
Expand Down
6 changes: 4 additions & 2 deletions lua/octo/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ function M.octo_command_complete(argLead, cmdLine)
return get_options(command_keys)
elseif #parts == 2 and vim.tbl_contains(command_keys, parts[2]) or #parts == 3 then
local obj = octo_commands.commands[parts[2]]
if type(obj) == "table" then
return get_options(vim.tbl_keys(obj))
if obj then
if type(obj) == "table" then
return get_options(vim.tbl_keys(obj))
end
end
end
end
Expand Down
2 changes: 0 additions & 2 deletions lua/octo/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ local M = {}
---@field snippet_context_lines number
---@field gh_env table
---@field timeout number
---@field default_to_projects_v2 boolean
---@field ui OctoConfigUi
---@field issues OctoConfigIssues
---@field pull_requests OctoConfigPR
Expand Down Expand Up @@ -99,7 +98,6 @@ function M.get_default_values()
snippet_context_lines = 4,
gh_env = {},
timeout = 5000,
default_to_projects_v2 = false,
ui = {
use_signcolumn = true,
},
Expand Down
Loading
Loading