fix: Allow reply on Gitlab buffer (#375)

Fixes issue where we were blocking reply creation due to a recent update

This is a #PATCH release
This commit is contained in:
Harrison (Harry) Cramer
2024-09-14 20:59:38 -04:00
committed by GitHub
parent dba15127fe
commit c3d7f26e3c
3 changed files with 17 additions and 11 deletions

View File

@@ -233,15 +233,12 @@ func CreateRouter(gitlabClient *Client, projectInfo *ProjectInfo, s *shutdownSer
withMethodCheck(http.MethodPost), withMethodCheck(http.MethodPost),
)) ))
m.Handle("/ping", http.HandlerFunc(pingHandler)) m.HandleFunc("/ping", func(w http.ResponseWriter, r *http.Request) {
return LoggingServer{handler: m}
}
/* Used to check whether the server has started yet */
func pingHandler(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
fmt.Fprintln(w, "pong") fmt.Fprintln(w, "pong")
})
return LoggingServer{handler: m}
} }
/* checkServer pings the server repeatedly for 1 full second after startup in order to notify the plugin that the server is ready */ /* checkServer pings the server repeatedly for 1 full second after startup in order to notify the plugin that the server is ready */

View File

@@ -156,6 +156,7 @@ end
---@field ranged boolean ---@field ranged boolean
---@field unlinked boolean ---@field unlinked boolean
---@field discussion_id string|nil ---@field discussion_id string|nil
---@field reply boolean|nil
---This function sets up the layout and popups needed to create a comment, note and ---This function sets up the layout and popups needed to create a comment, note and
---multi-line comment. It also sets up the basic keybindings for switching between ---multi-line comment. It also sets up the basic keybindings for switching between
@@ -172,7 +173,7 @@ M.create_comment_layout = function(opts)
-- Check that Diffview is the current view -- Check that Diffview is the current view
local view = diffview_lib.get_current_view() local view = diffview_lib.get_current_view()
if view == nil then if view == nil and not opts.reply then
u.notify("Comments should be left in the reviewer pane", vim.log.levels.ERROR) u.notify("Comments should be left in the reviewer pane", vim.log.levels.ERROR)
return return
end end
@@ -186,7 +187,7 @@ M.create_comment_layout = function(opts)
-- Check that we are hovering over the code -- Check that we are hovering over the code
local filetype = vim.bo[0].filetype local filetype = vim.bo[0].filetype
if filetype == "DiffviewFiles" or filetype == "gitlab" then if not opts.reply and (filetype == "DiffviewFiles" or filetype == "gitlab") then
u.notify( u.notify(
"Comments can only be left on the code. To leave unlinked comments, use gitlab.create_note() instead", "Comments can only be left on the code. To leave unlinked comments, use gitlab.create_note() instead",
vim.log.levels.ERROR vim.log.levels.ERROR

View File

@@ -244,9 +244,17 @@ M.reply = function(tree)
local discussion_id = tostring(discussion_node.id) local discussion_id = tostring(discussion_node.id)
local comment = require("gitlab.actions.comment") local comment = require("gitlab.actions.comment")
local unlinked = tree.bufnr == M.unlinked_bufnr local unlinked = tree.bufnr == M.unlinked_bufnr
local layout = comment.create_comment_layout({ ranged = false, discussion_id = discussion_id, unlinked = unlinked }) local layout = comment.create_comment_layout({
ranged = false,
discussion_id = discussion_id,
unlinked = unlinked,
reply = true,
})
if layout then
layout:mount() layout:mount()
end end
end
-- This function (settings.keymaps.discussion_tree.delete_comment) will trigger a popup prompting you to delete the current comment -- This function (settings.keymaps.discussion_tree.delete_comment) will trigger a popup prompting you to delete the current comment
M.delete_comment = function(tree, unlinked) M.delete_comment = function(tree, unlinked)