Aditya - Fix primary 2 buttons on the Announcements email dashboard - #5464
Aditya - Fix primary 2 buttons on the Announcements email dashboard#5464AdiDubbs wants to merge 4 commits into
Conversation
The Announcements page drives its tabs from the URL and pushes sub-paths such as /announcements/email/templates. Registering /announcements as exact meant none of them matched, so every one fell through to the catch-all NotFoundPage and the email dashboard's two entry buttons led to a 404. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The twelve relative srcs resolved against the current directory, so they only worked at /announcements. Now that sub-paths render, they resolved to /announcements/email/... and 404'd. The four icons that already used a leading slash were the only ones still loading. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ouncements_routing
✅ Deploy Preview for highestgoodnetwork-dev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
iAbhi001
left a comment
There was a problem hiding this comment.
Hi @AdiDubbs,
Thanks for working on this fix!
During local testing, navigating to /announcements (as well as the sub-paths like /announcements/email/send) immediately redirects back to the main dashboard instead of rendering the announcements cards/views.
Could you clarify:
- Required Permissions/Role Setup: I noticed in the PR description that this requires the
sendEmailspermission. Is there a specific permission flag or seed data required locally aside from the Owner role to prevent the redirect to the dashboard? - Permission Guard: Is the route guard redirecting before permissions finish loading from the auth context/state?
Please let me know how to properly configure the local user/role so I can verify the sub-path routing and complete the review.
Thanks for the careful review - and both good questions. @iAbhi001 . I'll answer your questions below.
To test: log in as Owner, open /permissions once so the roles load, then go to /announcements. I've updated the testing steps so this doesn't catch anyone else. The guard behaviour is pre-existing and affects every route with routePermissions, not just this one, so I'll log it on the bugs doc rather than widen this PR. Thanks for working out what was actually happening. |





Description
The Announcements email dashboard has two cards, Email (Send, Outbox) and Manage Templates, and they are the only route into the email module. Clicking either one returned the Not Found page.
/announcementswas registered as an exact match inroutes.jsx, so every path beneath it -/announcements/email/send,/announcements/email/outbox,/announcements/email/templates, and the platform tabs - matched no route at all and fell through to the catch-allNotFoundPageat the end of the Switch.Related PRS (if any):
Replaces #4726, now closed. No backend changes.
Main changes explained:
exactfrom the/announcementsroute so sub-paths match. It is the only route with that prefix, so nothing is shadowed. Added a comment explaining why it must not be exact, since it now reads as inconsistent with its neighbours.Announcements/index.jsxfrom relative to root-relative. They resolved only at the parent route, so once the sub-paths began working they returned 404s. Four icons already used a leading slash and were unaffected.src/__tests__/routes.test.jsx, covering the four email sub-paths against the real route table. Verified that it fails ifexactis reintroduced.src/components/Announcements/platforms/email/__tests__/index.test.jsx, which clicks each of the two dashboard cards and asserts the resulting path and view.How to test:
This page requires the
sendEmailspermission. It comes from the Owner role, not from a personal permission — which matters for step 3 below.npm install, thennpm run start:local/permissionsonce before going anywhere else. Clearing site data wipes the cached role list, and it is only refetched by User Management or Permissions Management. Until it loads,ProtectedRoutecannot see what the Owner role grants and redirects every permission-gated route to the dashboard — on any account. If you skip the clear-site-data step at 2, you can skip this too./announcements- both cards should be visible/announcements/email/sendwith the sender/announcements/email/outbox/announcements/email/templates/announcements/email/templatesinto the address bar and reload - it should load rather than 404/announcementsfooshould still show Not Found, and a signed-out visitor to/announcements/email/sendshould be redirected to login rather than the 404 pagenpm run test:changedIf you are redirected to the dashboard at step 4, that is the role list not having loaded rather than this change - see step 3. It is a pre-existing issue in
ProtectedRouteaffecting every route withroutePermissions, being logged separately.Screenshots of changes:
Note:
The four files #4726 added are already on development - that work was carried forward through #4492, #4731 and #4762. What remained outstanding was the routing fault, which this PR fixes.
Separate pre-existing issues found while testing, not addressed here, to be logged on the bugs doc:
/sendemailcrashes on direct navigation —EmailSender.jsxreadslocation.state.state, which is undefined unless the route is reached via ahistory.pushcarrying nested state.