Skip to content

feat: admin ability feed detail page#88

Open
Alessandro100 wants to merge 7 commits intomainfrom
feat/36-admin-ability-feed-detail-page
Open

feat: admin ability feed detail page#88
Alessandro100 wants to merge 7 commits intomainfrom
feat/36-admin-ability-feed-detail-page

Conversation

@Alessandro100
Copy link
Copy Markdown
Contributor

Summary:

closes #36

Added an admin view in the feed detail page only accessible to users with @mobilitydata.org email addresses

Expected behavior:

When you are logged in with a mobilitydata email address you will see an admin section at the bottom of each feed detail page

Testing tips:

Open 2 different browser
Browser 1: Do not log in, go to a feed detail page (mark down the 'generated at' value)
Browser 2: Log into your mobility data account, go to the same feed detail page, you should see the admin section at the bottom

In browser 2, revalidate the cache, then refresh browser 1, you should see the 'generated at' value update

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Run the unit tests with yarn test to make sure you didn't break anything
  • Add or update any needed documentation to the repo
  • Format the title like "feat: [new feature short description]". Title must follow the Conventional Commit Specification(https://www.conventionalcommits.org/en/v1.0.0/).
  • Linked all relevant issues
  • Include screenshot(s) showing how this pull request works and fixes the issue(s)
Screenshot 2026-03-25 at 09 02 24

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
mobilitydatabase-web Ready Ready Preview, Comment Mar 25, 2026 2:19pm

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an admin-only tool section to the Feed Detail page (served via the authed feed route rewrite) that allows MobilityData staff to trigger ISR cache revalidation for a specific feed, and refactors existing revalidation logic into a shared utility.

Changes:

  • Add an admin check (@mobilitydata.org) and plumb an isMobilityDatabaseAdmin flag into the authed feed page → FeedView.
  • Introduce a server action + client button to trigger revalidation for a specific feed.
  • Extract revalidation helpers into src/app/utils/revalidate-feeds.ts and reuse them from /api/revalidate.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
src/app/utils/revalidate-feeds.ts New shared helpers for revalidating feed-related paths/tags.
src/app/utils/auth-server.ts Adds isMobilityDatabaseAdmin helper used by page + server action.
src/app/screens/Feed/actions.ts New server action to revalidate a specific feed’s cache with admin gating.
src/app/screens/Feed/components/RevalidateCacheButton.tsx New client UI to call the server action and show result.
src/app/screens/Feed/FeedView.tsx Renders admin tools section when isMobilityDatabaseAdmin is true.
src/app/components/ContentBox.tsx Adds a new prop to support a subtitle-like section in ContentBox.
src/app/api/revalidate/route.ts Refactors to use the shared revalidation utilities.
src/app/[locale]/feeds/[feedDataType]/[feedId]/authed/page.tsx Computes admin status from cookie user and passes it to FeedView.

Applied skill: vercel-react-best-practices (server/client boundaries and server action usage).

Comment on lines +426 to +433
<ContentBox
title={'MobilityDatabase Admin Tools'}
subtile={
<>
This section is only visible to Mobility Data employees with an{' '}
<code>@mobilitydata.org</code> email address. It contains tools
for debugging and managing feed data
</>
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

The new admin section strings are hardcoded English, but this page already uses next-intl translations (getTranslations(...)). To keep localization consistent (especially for /fr), move these new strings into the message catalogs and render them via t(...).

Copilot uses AI. Check for mistakes.
Comment on lines +16 to +17
revalidateSpecificFeeds([feedId]);
return { ok: true, message: `Cache revalidated for feed ${feedId}` };
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

This server action assumes feedId is always a meaningful non-empty string. Given the UI currently passes feed.id ?? '', consider validating feedId (e.g., trim().length > 0) and returning an error instead of calling revalidateSpecificFeeds with an empty id.

Suggested change
revalidateSpecificFeeds([feedId]);
return { ok: true, message: `Cache revalidated for feed ${feedId}` };
const normalizedFeedId = feedId.trim();
if (normalizedFeedId.length === 0) {
return { ok: false, message: 'Invalid feed id: value is empty or whitespace' };
}
revalidateSpecificFeeds([normalizedFeedId]);
return { ok: true, message: `Cache revalidated for feed ${normalizedFeedId}` };

Copilot uses AI. Check for mistakes.
Comment on lines +38 to +40
<Button variant='contained' onClick={handleClick} disabled={isPending}>
{isPending ? 'Revalidating…' : 'Revalidate The Cache of This Page'}
</Button>
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

The button label / status text is hardcoded. Since the app is localized with next-intl, consider moving these strings into the message files and using translations so admin users on /fr don't see mixed-language UI.

Copilot uses AI. Check for mistakes.
Comment on lines +425 to +439
{isMobilityDatabaseAdmin && (
<ContentBox
title={'MobilityDatabase Admin Tools'}
subtile={
<>
This section is only visible to Mobility Data employees with an{' '}
<code>@mobilitydata.org</code> email address. It contains tools
for debugging and managing feed data
</>
}
outlineColor='background.paper'
sx={{ mt: 4, backgroundColor: 'background.paper' }}
>
<RevalidateCacheButton feedId={feed.id ?? ''} />
</ContentBox>
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

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

There are existing unit tests for the Feed screen (Feed.spec.tsx), but the new admin-only section and revalidation flow are currently untested. Consider adding tests that verify the admin tools render only when isMobilityDatabaseAdmin is true and that unauthorized users don’t see/can’t trigger revalidation.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 25, 2026

*Lighthouse ran on https://mobilitydatabase-ijl5r8khy-mobility-data.vercel.app/ * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🟢 96 🟢 96 🟢 100 🟢 100

*Lighthouse ran on https://mobilitydatabase-ijl5r8khy-mobility-data.vercel.app/feeds * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🟢 90 🟠 87 🟢 96 🟢 100

*Lighthouse ran on https://mobilitydatabase-ijl5r8khy-mobility-data.vercel.app/feeds/gtfs/mdb-2126 * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🟠 75 🟢 94 🟢 96 🟢 100

*Lighthouse ran on https://mobilitydatabase-ijl5r8khy-mobility-data.vercel.app/feeds/gtfs_rt/mdb-2585 * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🟠 78 🟠 83 🟢 100 🟢 100

*Lighthouse ran on https://mobilitydatabase-ijl5r8khy-mobility-data.vercel.app/feeds/gbfs/gbfs-flamingo_porirua * (Desktop)
⚡️ HTML Report Lighthouse report for the changes in this PR:

Performance Accessibility Best Practices SEO
🟠 81 🟢 94 🟢 96 🟢 100

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSR: Admin abilities in Feed Detail Page

2 participants