Issue deletion needs project:admin (admins and up)

2f56e4f · gmorell · 2026-12-01 22:59

19 files +35 -14
Message
{commit_body(@commit)}

Files changed

modified ROADMAP.md
+1 −1
@@ -297,7 +297,7 @@ libraries to the images.
297 297 - Issue detail has event navigation, stack traces with system frames folded and source context, and the full interfaces. The share page shows the exception and stack only (no request, user, breadcrumbs, contexts or frame vars).
298 298 - The org dashboard has an events-per-hour chart (with a table view), 24h counts per project, and the latest unresolved issues.
299 299 - Keyboard shortcuts on the list (j/k/o/x/r/i, /) and on the detail page (r/i/u, j/k events, c). Neither has been tried in a browser yet.
300 − - **Permissions to revisit:** GlitchTip gives every role `event:admin`, so members can delete issues. Comment moderation was narrowed to `project:admin`.
300 + - **Permissions:** GlitchTip gives every role `event:admin`, so deleting issues and moderating comments need `project:admin` (admins and up) instead.
301 301
302 302 ### 4. Alerts and notifications · medium
303 303 - **Rules:** per project, "N events in M minutes", "new issue" and "regression". Recipients are email, a generic webhook (Slack-compatible), Discord, ntfy, Teams, Google Chat and Zulip, with GlitchTip's payload shapes.
modified lib/vigil/issues.ex
+8 −3
@@ -7,7 +7,8 @@ defmodule Vigil.Issues do
7 7 preview.
8 8
9 9 Changes need `event:write` in the issue's organization
10 − (`Vigil.Accounts.Scope`); deleting needs `event:admin`. Every change is
10 + (`Vigil.Accounts.Scope`); deleting needs `project:admin` (admins and up:
11 + GlitchTip gives every role `event:admin`). Every change is
11 12 broadcast on `project:<id>:issues` (and `issue:<id>`), as new events are.
12 13 """
13 14
@@ -438,9 +439,13 @@ defmodule Vigil.Issues do
438 439 def set_public(%Scope{} = scope, %Issue{} = issue, public?) when is_boolean(public?),
439 440 do: set(scope, issue, "event:write", is_public: public?)
440 441
441 − @doc "Removes an issue (soft; its events are swept with retention). Needs `event:admin`."
442 + @doc """
443 + Removes an issue (soft; its events are swept with retention). Needs
444 + `project:admin`, so admins and above: every role holds `event:admin` in
445 + GlitchTip's scopes, members included.
446 + """
442 447 def delete(%Scope{} = scope, %Issue{} = issue),
443 − do: set(scope, issue, "event:admin", deleted_at: DateTime.utc_now(:second))
448 + do: set(scope, issue, "project:admin", deleted_at: DateTime.utc_now(:second))
444 449
445 450 @doc """
446 451 One action on many issues of a project: `"resolve"`, `"ignore"`,
modified lib/vigil_web/components/issue_list_components.ex
+1 −1
@@ -167,7 +167,7 @@ defmodule VigilWeb.IssueListComponents do
167 167
168 168 @doc """
169 169 What can be done to the selected issues. Delete shows only to callers
170 − holding `event:admin`, and asks first.
170 + holding `project:admin` (admins and up), and asks first.
171 171 """
172 172 attr :count, :integer, required: true
173 173 attr :can_delete, :boolean, default: false
modified lib/vigil_web/live/issue_live/index.ex
+1 −1
@@ -58,7 +58,7 @@ defmodule VigilWeb.IssueLive.Index do
58 58 |> assign(:dsn, dsn)
59 59 |> assign(:snippet, dsn && Platforms.snippet(project.platform, dsn))
60 60 |> assign(:can_write, Scope.can?(scope, "event:write"))
61 − |> assign(:can_delete, Scope.can?(scope, "event:admin"))
61 + |> assign(:can_delete, Scope.can?(scope, "project:admin"))
62 62 |> assign(:ever?, project.first_event_at != nil)
63 63 |> assign(:selected, MapSet.new())
64 64 |> assign(:page_ids, [])
modified lib/vigil_web/live/issue_live/show.ex
+2 −2
@@ -15,7 +15,7 @@ defmodule VigilWeb.IssueLive.Show do
15 15
16 16 Keys (a colocated hook, ignored while typing): `r` resolve, `i` ignore,
17 17 `u` unresolve, `j` older event, `k` newer event, `c` the comment box.
18 − Changes need `event:write`; deleting needs `event:admin`.
18 + Changes need `event:write`; deleting needs `project:admin` (admins and up).
19 19 """
20 20 use VigilWeb, :live_view
21 21
@@ -43,7 +43,7 @@ defmodule VigilWeb.IssueLive.Show do
43 43 {:ok,
44 44 socket
45 45 |> assign(:can_write?, Scope.can?(scope, "event:write"))
46 − |> assign(:can_admin?, Scope.can?(scope, "event:admin"))
46 + |> assign(:can_admin?, Scope.can?(scope, "project:admin"))
47 47 |> assign(:can_moderate?, Scope.can?(scope, "project:admin"))
48 48 |> assign(:assignable, Issues.assignable_users(scope.organization.id))
49 49 |> assign(:new_events, 0)
modified test/vigil/issues_test.exs
+10 −0
@@ -99,6 +99,16 @@ defmodule Vigil.IssuesTest do
99 99 assert 2 = Issues.bulk(scope, project.id, [one.id, two.id], "resolve")
100 100 assert [] = Issues.search(scope, project.id, %{}).issues
101 101 assert 2 = length(Issues.search(scope, project.id, %{status: :resolved}).issues)
102 + member = member_fixture(scope.organization)
103 +
104 + assert 0 =
105 + Issues.bulk(
106 + org_scope(member.user, scope.organization),
107 + project.id,
108 + [one.id],
109 + "delete"
110 + )
111 +
102 112 assert 1 = Issues.bulk(scope, project.id, [one.id], "delete")
103 113 assert 1 = length(Issues.search(scope, project.id, %{status: :all}).issues)
104 114 end
modified test/vigil_web/live/issue_live/index_test.exs
+2 −2
@@ -183,7 +183,7 @@ defmodule VigilWeb.IssueLive.IndexTest do
183 183 assert Issues.search(scope, project.id, %{status: :all}).issues == []
184 184 end
185 185
186 − test "Delete shows only to callers with event:admin" do
186 + test "Delete shows only to callers with project:admin" do
187 187 html = render_component(&IssueListComponents.bulk_actions/1, count: 2, can_delete: false)
188 188 doc = LazyHTML.from_fragment(html)
189 189 assert LazyHTML.query(doc, "#bulk-resolve") |> Enum.count() == 1
@@ -193,7 +193,7 @@ defmodule VigilWeb.IssueLive.IndexTest do
193 193 assert LazyHTML.from_fragment(html) |> LazyHTML.query("#bulk-delete") |> Enum.count() == 1
194 194 end
195 195
196 − test "another member of the organization can triage, Delete included", ctx do
196 + test "a manager can triage, Delete included", ctx do
197 197 %{org: org, target: target, path: path} = ctx
198 198 manager = user_fixture()
199 199 member_fixture(org, manager, :manager)
modified test/vigil_web/live/issue_live/show_test.exs
+10 −4
@@ -190,7 +190,7 @@ defmodule VigilWeb.IssueLive.ShowTest do
190 190 assert has_element?(view, "#event-nav", "production")
191 191 end
192 192
193 − test "without event:write the context refuses; without event:admin no delete", %{
193 + test "without event:write the context refuses; without project:admin no delete", %{
194 194 project: project,
195 195 scope: scope
196 196 } do
@@ -215,7 +215,7 @@ defmodule VigilWeb.IssueLive.ShowTest do
215 215 assert LazyHTML.query(doc, "#delete-issue") |> Enum.count() == 0
216 216 end
217 217
218 − test "a member (event:admin) can delete", %{
218 + test "a member triages but can't delete; an admin can", %{
219 219 conn: conn,
220 220 org: org,
221 221 project: project,
@@ -225,9 +225,15 @@ defmodule VigilWeb.IssueLive.ShowTest do
225 225 member_fixture(org, member, :member)
226 226 {:ok, _} = Vigil.Organizations.update_organization(scope, org, %{open_membership: true})
227 227
228 − conn = log_in_user(conn, member)
229 − {view, _issue} = open_issue(conn, org, project)
228 + member_conn = log_in_user(conn, member)
229 + {view, issue} = open_issue(member_conn, org, project)
230 230 assert has_element?(view, "#resolve")
231 + refute has_element?(view, "#delete-issue")
232 + assert {:error, :forbidden} = Issues.delete(org_scope(member, org), issue)
233 +
234 + admin = user_fixture()
235 + member_fixture(org, admin, :admin)
236 + {view, _issue} = open_issue(log_in_user(conn, admin), org, project)
231 237 assert has_element?(view, "#delete-issue")
232 238 end
233 239 end

Parents: ce059fe