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:
committed by
GitHub
parent
dba15127fe
commit
c3d7f26e3c
@@ -233,17 +233,14 @@ 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) {
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
fmt.Fprintln(w, "pong")
|
||||||
|
})
|
||||||
|
|
||||||
return LoggingServer{handler: m}
|
return LoggingServer{handler: m}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Used to check whether the server has started yet */
|
|
||||||
func pingHandler(w http.ResponseWriter, _ *http.Request) {
|
|
||||||
w.WriteHeader(http.StatusOK)
|
|
||||||
fmt.Fprintln(w, "pong")
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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 */
|
||||||
func checkServer(port int) error {
|
func checkServer(port int) error {
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -244,8 +244,16 @@ 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({
|
||||||
layout:mount()
|
ranged = false,
|
||||||
|
discussion_id = discussion_id,
|
||||||
|
unlinked = unlinked,
|
||||||
|
reply = true,
|
||||||
|
})
|
||||||
|
|
||||||
|
if layout then
|
||||||
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user