Fix: Refresh teams list automatically after team creation#2780
Fix: Refresh teams list automatically after team creation#2780crivetimihai merged 2 commits intomainfrom
Conversation
ac96537 to
130cfcf
Compare
130cfcf to
baee585
Compare
|
Nice fix, @shoummu1! Great root cause analysis — the existing |
gcgoncalves
left a comment
There was a problem hiding this comment.
Tested locally and worked well. Great seeing a fix with +5 -40 lines!
Signed-off-by: Shoumi <shoumimukherjee@gmail.com>
Signed-off-by: Shoumi <shoumimukherjee@gmail.com>
baee585 to
6c5a453
Compare
Code ReviewVerdict: Correct and well-designedFlow analysis:
Consistency: This pattern is consistent with how delete, leave, and cancel-join work (lines 14662-14680) — they all call Error handling: Error paths (validation, integrity, generic) all properly use No issues found
Minor observation (not a blocker)The removed code previously triggered Net change: +5 / -40 lines — a good simplification. |
* fix: refresh teams list automatically after team creation Signed-off-by: Shoumi <shoumimukherjee@gmail.com> * test fixes Signed-off-by: Shoumi <shoumimukherjee@gmail.com> --------- Signed-off-by: Shoumi <shoumimukherjee@gmail.com>
🐛 Bug-fix PR
📌 Summary
With this fix, teams list now updates automatically after creating a new team, eliminating the need for manual page refresh.
Why: The HTMX response after team creation wasn't triggering a list refresh, causing users to see an outdated teams list until they manually refreshed the page. This created a confusing UX where the create operation succeeded but the new team wasn't visible.
🔗 Related Issue
Closes #2690
🐞 Root Cause
The backend returned custom HTML that was inserted via
hx-swap="afterbegin", but this approach had two problems:HX-Trigger: adminTeamActionheader sentresetTeamCreateForm: truebut NOTrefreshUnifiedTeamsList: true, so the JavaScript refresh logic never executedLocation:
mcpgateway/admin.py:4065-4100andmcpgateway/templates/admin.html:14136💡 Fix Description
Implemented solution 2 from suggestion provided: "A trigger to refresh the teams table after successful creation"
Key changes:
Backend (
admin.py:4066-4068): Return empty 201 response instead of custom HTMLFrontend (
admin.html:14137-14139): Changed form target to error containerExisting handler (
admin.html:14737-14742): Leverages already-presenthtmx:afterRequestlistener that refreshes the list viainitializeTeamManagement()Design rationale:
teams_partial.html)hx-swap-oobapproach (no full table rendering in response)🧪 Verification
make lintmake testmake coverageTest updates:
test_admin_create_team_successto expect empty 201 response📐 MCP Compliance (if relevant)
✅ Checklist
make black isort pre-commit)