Feat: Edit PR Description (#22)
This MR makes it possible to edit the description. Non-breaking, will happen within the normal description popup.
This commit is contained in:
committed by
GitHub
parent
35d5b619ce
commit
2028be2154
@@ -1,13 +1,14 @@
|
||||
local state = require("gitlab.state")
|
||||
local Popup = require("nui.popup")
|
||||
local u = require("gitlab.utils")
|
||||
local keymaps = require("gitlab.keymaps")
|
||||
local summaryPopup = Popup(u.create_popup_state("Loading Summary...", "80%", "80%"))
|
||||
local M = {}
|
||||
local job = require("gitlab.job")
|
||||
local state = require("gitlab.state")
|
||||
local Popup = require("nui.popup")
|
||||
local u = require("gitlab.utils")
|
||||
local keymaps = require("gitlab.keymaps")
|
||||
local descriptionPopup = Popup(u.create_popup_state("Loading Description...", "80%", "80%"))
|
||||
local M = {}
|
||||
|
||||
M.summary = function()
|
||||
M.summary = function()
|
||||
if u.base_invalid() then return end
|
||||
summaryPopup:mount()
|
||||
descriptionPopup:mount()
|
||||
local currentBuffer = vim.api.nvim_get_current_buf()
|
||||
local title = state.INFO.title
|
||||
local description = state.INFO.description
|
||||
@@ -18,9 +19,17 @@ M.summary = function()
|
||||
end
|
||||
vim.schedule(function()
|
||||
vim.api.nvim_buf_set_lines(currentBuffer, 0, -1, false, lines)
|
||||
vim.api.nvim_buf_set_option(currentBuffer, "modifiable", false)
|
||||
summaryPopup.border:set_text("top", title, "center")
|
||||
keymaps.set_popup_keymaps(summaryPopup)
|
||||
descriptionPopup.border:set_text("top", title, "center")
|
||||
keymaps.set_popup_keymaps(descriptionPopup, M.edit_description)
|
||||
end)
|
||||
end
|
||||
|
||||
M.edit_description = function(text)
|
||||
local jsonTable = { description = text }
|
||||
local json = vim.json.encode(jsonTable)
|
||||
job.run_job("mr", "PUT", json, function(data)
|
||||
vim.notify(data.message, vim.log.levels.INFO)
|
||||
state.INFO.description = data.mr.description
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user