Skip to content

Aditya - Fix primary 2 buttons on the Announcements email dashboard - #5464

Open
AdiDubbs wants to merge 4 commits into
developmentfrom
Aditya_fix_announcements_routing
Open

Aditya - Fix primary 2 buttons on the Announcements email dashboard#5464
AdiDubbs wants to merge 4 commits into
developmentfrom
Aditya_fix_announcements_routing

Conversation

@AdiDubbs

@AdiDubbs AdiDubbs commented Aug 22, 2026

Copy link
Copy Markdown

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.

/announcements was registered as an exact match in routes.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-all NotFoundPage at the end of the Switch.

Related PRS (if any):

Replaces #4726, now closed. No backend changes.

Main changes explained:

  1. Removed exact from the /announcements route 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.
  2. Corrected twelve social platform icon paths in Announcements/index.jsx from 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.
  3. Added src/__tests__/routes.test.jsx, covering the four email sub-paths against the real route table. Verified that it fails if exact is reintroduced.
  4. Added 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 sendEmails permission. It comes from the Owner role, not from a personal permission — which matters for step 3 below.

  1. Check out this branch, run npm install, then npm run start:local
  2. Clear site data and cache
  3. Log in as an Owner, then open /permissions once 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, ProtectedRoute cannot 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.
  4. Go to /announcements - both cards should be visible
  5. Click Email - loads /announcements/email/send with the sender
  6. Switch to the Outbox tab - URL becomes /announcements/email/outbox
  7. Click Back to Dashboard, then Manage Templates - loads /announcements/email/templates
  8. Paste /announcements/email/templates into the address bar and reload - it should load rather than 404
  9. Confirm the social platform icons render on each of those pages
  10. Repeat steps 4-9 in dark mode
  11. Negative cases: /announcementsfoo should still show Not Found, and a signed-out visitor to /announcements/email/send should be redirected to login rather than the 404 page
  12. Run npm run test:changed

If 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 ProtectedRoute affecting every route with routePermissions, being logged separately.

Screenshots of changes:

Before — either card, or any email sub-path direct, returned Page Not Found

Page Not Found at an announcements email sub-path
After — the two dashboard cards, light mode

Announcements email dashboard showing both cards, light mode
The two dashboard cards, dark mode

Announcements email dashboard showing both cards, dark mode
Send Email — reachable for the first time

Send Email page
Outbox — rows populating, so the backend calls succeed

Outbox page with rows
Email Templates — also where the twelve social icons had been 404ing

Email Templates page with social platform icons rendering

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:

  • /sendemail crashes on direct navigation — EmailSender.jsx reads location.state.state, which is undefined unless the route is reached via a history.push carrying nested state.
  • A few of the social platform logo PNGs have no alpha channel, so they render as opaque white rectangles against the dark theme.

AdiDubbs and others added 4 commits August 21, 2026 17:55
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>
@netlify

netlify Bot commented Aug 22, 2026

Copy link
Copy Markdown

Deploy Preview for highestgoodnetwork-dev ready!

Name Link
🔨 Latest commit b305cf9
🔍 Latest deploy log https://app.netlify.com/projects/highestgoodnetwork-dev/deploys/6a8a31e251610e00082b2105
😎 Deploy Preview https://deploy-preview-5464--highestgoodnetwork-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@sonarqubecloud

Copy link
Copy Markdown

@iAbhi001 iAbhi001 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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


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:

  1. Required Permissions/Role Setup: I noticed in the PR description that this requires the sendEmails permission. Is there a specific permission flag or seed data required locally aside from the Owner role to prevent the redirect to the dashboard?
  2. 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.

@one-community one-community added the High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible label Aug 23, 2026

@DeMoliT1on DeMoliT1on left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tested on local with Owner/Admin and Member accounts. The routes seems to be working properly now. All the sub-routes for announcement page can be viewed when the user have the permission. And redirects to dashboard when the user does not have the required permission.

Image Image

@AdiDubbs

Copy link
Copy Markdown
Author

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:

  1. Required Permissions/Role Setup: I noticed in the PR description that this requires the sendEmails permission. Is there a specific permission flag or seed data required locally aside from the Owner role to prevent the redirect to the dashboard?
  2. 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.

  1. No extra seed data is needed. The page needs sendEmails, which only Owner has by default on dev. But I don't think that is what redirected you.

  2. Yes, you're right. ProtectedRoute builds the permission list from state.role.roles, and if that hasn't loaded it falls back to an empty array, so "not loaded yet" and "not allowed" look identical to it and it redirects. The role list is normally cached in the browser, but step 2 of testing steps says to clear site data, which wipes it, and nothing refetches it unless you visit User Management or Permissions Management. So you'd have been redirected on any account, including Owner.

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.

@AdiDubbs
AdiDubbs requested a review from iAbhi001 August 28, 2026 04:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants