This MR is a #MAJOR breaking change to the plugin. While the plugin will continue to work for users with their existing settings, they will be informed of outdated configuration (diagnostics and signs have been simplified) the next time they open the reviewer. Fix: Trim trailing slash from custom URLs Update: .github/CONTRIBUTING.md, .github/ISSUE_TEMPLATE/bug_report.md Feat: Improve discussion tree toggling (#192) Fix: Toggle modified notes (#188) Fix: Toggle discussion nodes correctly Feat: Show Help keymap in discussion tree winbar Fix: Enable toggling nodes from the note body Fix: Enable toggling resolved status from child nodes Fix: Only try to show emoji popup on note nodes Feat: Add keymap for toggling tree type Fix: Disable tree type toggling in Notes Fix Multi Line Issues (Large Refactor) (#197) Fix: Multi-line discussions. The calculation of a range for a multiline comment has been consolidated and moved into the location.lua file. This does not attempt to fix diagnostics. Refactor: It refactors the discussions code to split hunk parsing and management into a separate module Fix: Don't allow comments on modified buffers #194 by preventing comments on the reviewer when using --imply-local and when the working tree is dirty entirely. Refactor: It introduces a new List class for data aggregation, filtering, etc. Fix: It removes redundant API calls and refreshes from the discussion pane Fix: Location provider (#198) Fix: add nil check for Diffview performance issue (#199) Fix: Switch Tabs During Comment Creation (#200) Fix: Check if file is modified (#201) Fix: Off-By-One Issue in Old SHA (#202) Fix: Rebuild Diagnostics + Signs (#203) Fix: Off-By-One Issue in New SHA (#205) Fix: Reviewer Jumps to wrong location (#206) BREAKING CHANGE: Changes configuration of diagnostics and signs in the setup call.
81 lines
2.1 KiB
Lua
81 lines
2.1 KiB
Lua
-- This module is responsible for the creation, deletion,
|
|
-- and assignment and removeal of labels.
|
|
local u = require("gitlab.utils")
|
|
local job = require("gitlab.job")
|
|
local state = require("gitlab.state")
|
|
local List = require("gitlab.utils.list")
|
|
local M = {}
|
|
|
|
M.add_label = function()
|
|
M.add_popup("label")
|
|
end
|
|
|
|
M.delete_label = function()
|
|
M.delete_popup("label")
|
|
end
|
|
|
|
local refresh_label_state = function(labels)
|
|
state.INFO.labels = List.new(labels):reduce(function(agg, label)
|
|
return agg .. "," .. label
|
|
end, "")
|
|
end
|
|
|
|
local get_current_labels = function()
|
|
local label_string = state.INFO.labels
|
|
local current_labels = {}
|
|
for value in label_string:gmatch("[^,]+") do
|
|
table.insert(current_labels, value)
|
|
end
|
|
return current_labels
|
|
end
|
|
|
|
local get_all_labels = function()
|
|
return List.new(state.LABELS):map(function(label)
|
|
return label.Name
|
|
end)
|
|
end
|
|
|
|
M.add_popup = function(type)
|
|
local all_labels = get_all_labels()
|
|
local current_labels = get_current_labels()
|
|
local unused_labels = u.difference(all_labels, current_labels)
|
|
vim.ui.select(unused_labels, {
|
|
prompt = "Choose label to add",
|
|
}, function(choice)
|
|
if not choice then
|
|
return
|
|
end
|
|
local label_string = state.INFO.labels
|
|
local new_labels = {}
|
|
for value in label_string:gmatch("[^,]+") do
|
|
table.insert(new_labels, value)
|
|
end
|
|
|
|
table.insert(new_labels, choice)
|
|
local body = { labels = new_labels }
|
|
job.run_job("/mr/" .. type, "PUT", body, function(data)
|
|
u.notify(data.message, vim.log.levels.INFO)
|
|
refresh_label_state(data.labels)
|
|
end)
|
|
end)
|
|
end
|
|
|
|
M.delete_popup = function(type)
|
|
local current_labels = get_current_labels()
|
|
vim.ui.select(current_labels, {
|
|
prompt = "Choose label to delete",
|
|
}, function(choice)
|
|
if not choice then
|
|
return
|
|
end
|
|
local filtered_labels = u.filter(current_labels, choice)
|
|
local body = { labels = filtered_labels }
|
|
job.run_job("/mr/" .. type, "PUT", body, function(data)
|
|
u.notify(data.message, vim.log.levels.INFO)
|
|
refresh_label_state(data.labels)
|
|
end)
|
|
end)
|
|
end
|
|
|
|
return M
|