Skip to content

Comments

Channels CRUD#4445

Merged
midigofrank merged 13 commits intochannelsfrom
channels-crud
Feb 25, 2026
Merged

Channels CRUD#4445
midigofrank merged 13 commits intochannelsfrom
channels-crud

Conversation

@midigofrank
Copy link
Collaborator

@midigofrank midigofrank commented Feb 20, 2026

Description

Channels CRUD UI. The channels menu item is only shown if you have enabled experimental features

Things yet to do:

  • Stats Summary at the top of index page
  • Delete confirm modal
  • Create Channel snapshots

Closes #4407
Closes #4400

Validation steps

AI Usage

Please disclose whether you've used AI anywhere in this PR (it's cool, we just
want to know!):

  • I have used Claude Code
  • I have used another model
  • I have not used AI

You can read more details in our
Responsible AI Policy

Pre-submission checklist

  • I have performed an AI review of my code (we recommend using /review
    with Claude Code)
  • I have implemented and tested all related authorization policies.
    (e.g., :owner, :admin, :editor, :viewer)
  • I have updated the changelog.
  • I have ticked a box in "AI usage" in this PR

@github-project-automation github-project-automation bot moved this to New Issues in v2 Feb 20, 2026
@midigofrank midigofrank changed the base branch from main to channels February 20, 2026 13:27
@codecov
Copy link

codecov bot commented Feb 20, 2026

Codecov Report

❌ Patch coverage is 94.69697% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.44%. Comparing base (23d42bb) to head (c7ba910).
⚠️ Report is 1 commits behind head on channels.

Files with missing lines Patch % Lines
lib/lightning_web/live/channel_live/index.ex 89.74% 12 Missing ⚠️
.../lightning_web/live/channel_live/form_component.ex 97.72% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           channels    #4445      +/-   ##
============================================
+ Coverage     89.38%   89.44%   +0.06%     
============================================
  Files           435      437       +2     
  Lines         20392    20650     +258     
============================================
+ Hits          18227    18471     +244     
- Misses         2165     2179      +14     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- Add `get_channel_stats_for_project/1` context function returning total
  channels and requests in a single LEFT JOIN query
- Render a 2-card metrics grid (Total Channels / Total Requests) above
  the channel table on the index page
- Fix delete confirmation: replace `phx-confirm` (silently dropped by
  the `<.button>` global-attrs whitelist) with `data-confirm`
- Move "Create one in project settings" links inline with section titles
  in the form, always visible regardless of list emptiness
- Add context unit tests for `get_channel_stats_for_project/1`
- Add LiveView tests: stats cards, delete confirm attribute, settings
  links always visible, pre-selected auth methods, and a remove/keep/add
  auth method scenario
@midigofrank midigofrank marked this pull request as ready for review February 20, 2026 15:46

defp apply_action(socket, :edit, %{"id" => id}) do
if socket.assigns.can_create_channel do
channel = Channels.get_channel!(id, include: [:channel_auth_methods])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to scope by project as well, the only check for the project's scope is on mount - you would be able to inject a different id in here and skip the checks.

%{"channel_state" => enabled?, "value_key" => channel_id},
socket
) do
channel = Channels.get_channel!(channel_id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, we aren't checking permissions here against the project. Even if the input/calling html is disabled, a crafted WS message could bypass security.

<.td class="text-right">
<div class="flex items-center justify-end gap-2">
<.link
:if={@can_delete_channel}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've got @can_create_channel being used for apply_action(socket, :edit, ...) and @can_delete_channel here on the template. Even if those permissions are the same, we should either pick one or make a @can_edit... and make sure we are consistent.

end
end

defp save_channel(socket, :edit, params) do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need some kind of check here and above as well for permissions.

@github-project-automation github-project-automation bot moved this from New Issues to In review in v2 Feb 24, 2026
- Add :update_channel permission to ProjectUsers policy
- Add Channels.get_channel_for_project/2 to scope fetches to the
  current project in a single query
- Add server-side authorization checks to toggle and delete handlers
- Fix apply_action(:edit) to check can_edit_channel, not can_create_channel
- Gate the enabled toggle on can_edit_channel in the template
- Fix merge_selections/2 truthy semantics bug (|| on booleans)
- Use to_form/1 for the changeset in the form component
- Refactor toggle/delete handlers with with and private helpers
@midigofrank midigofrank requested a review from stuartc February 24, 2026 11:58
midigofrank and others added 5 commits February 25, 2026 08:11
Allow configuring LiveDebugger's bind address and external URL for
remote/container access via optional env vars in dev mode.
Channel requests and snapshots have foreign keys that must be
cleared before their parent channels and projects are deleted.
The %Channel{id: nil} struct is truthy, so the && short-circuit
produced "edit-channel-" instead of falling through to :new. Add
an explicit check on selected_channel.id.
@midigofrank midigofrank merged commit 9c01b93 into channels Feb 25, 2026
7 checks passed
@midigofrank midigofrank deleted the channels-crud branch February 25, 2026 07:08
@github-project-automation github-project-automation bot moved this from In review to Done in v2 Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Channels: CRUD LiveViews Channels: Audit trail integration

2 participants