Skip to content
Open
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
16 changes: 8 additions & 8 deletions lua/gitlab/actions/draft_notes/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ local List = require("gitlab.utils.list")
local u = require("gitlab.utils")
local state = require("gitlab.state")

local branch_not_in_sync_comment = " (even if local branch not in sync with remote)"

local M = {}

---Re-fetches all draft notes (and non-draft notes) and re-renders the relevant views
Expand Down Expand Up @@ -64,8 +66,10 @@ end

-- This function will trigger a popup prompting you to publish the current draft comment
M.publish_draft = function(tree)
local branch_in_sync = git.check_current_branch_up_to_date_on_remote(vim.log.levels.ERROR)
local sync_comment = branch_in_sync and "" or branch_not_in_sync_comment
vim.ui.select({ "Confirm", "Cancel" }, {
prompt = "Publish current draft comment?",
prompt = string.format("Publish current draft comment%s?", sync_comment),
}, function(choice)
if choice == "Confirm" then
M.confirm_publish_draft(tree)
Expand All @@ -75,8 +79,10 @@ end

-- This function will trigger a popup prompting you to publish all draft notes
M.publish_all_drafts = function()
local branch_in_sync = git.check_current_branch_up_to_date_on_remote(vim.log.levels.ERROR)
local sync_comment = branch_in_sync and "" or branch_not_in_sync_comment
vim.ui.select({ "Confirm", "Cancel" }, {
prompt = "Publish all drafts?",
prompt = string.format("Publish all drafts%s?", sync_comment),
}, function(choice)
if choice == "Confirm" then
M.confirm_publish_all_drafts()
Expand All @@ -86,9 +92,6 @@ end

---Publishes all draft notes and comments. Re-renders all discussion views.
M.confirm_publish_all_drafts = function()
if not git.check_current_branch_up_to_date_on_remote(vim.log.levels.ERROR) then
return
end
local body = { publish_all = true }
job.run_job("/mr/draft_notes/publish", "POST", body, function(data)
u.notify(data.message, vim.log.levels.INFO)
Expand All @@ -108,9 +111,6 @@ end
---and re-render it.
---@param tree NuiTree
M.confirm_publish_draft = function(tree)
if not git.check_current_branch_up_to_date_on_remote(vim.log.levels.ERROR) then
return
end
local current_node = tree:get_node()
local note_node = common.get_note_node(tree, current_node)
local root_node = common.get_root_node(tree, current_node)
Expand Down
Loading