Repository navigation
Conversation
Add subject editing and merging for admins and lead verifiers. Move guide and objective revision tags together without deleting content. Refresh affected guide search cards after changes. Refs bluelearn-org#521 Signed-off-by: Damien <drdelgado9@outlook.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Admins and lead verifiers can now manage subjects from the dashboard.
The Subjects page lists each subject's name, summary and creation date, with the same filtering and sorting as the other dashboard tables. You can edit one subject's name and summary, or select several on the current page to merge.
Before merging, you see the selected subjects, choose which one to keep, and can edit its name and summary.
The API doesn't rely on hidden buttons. It checks the caller's role, and the database checks again before making changes. A merge runs as one transaction: guide and objective tags, including drafts and past revisions, move to the subject you're keeping, overlapping tags become one, and the duplicates are removed. Guides and objectives stay intact. If any selected subject is already gone, nothing changes.
The kept subject keeps its ID, URL, publication status and creation date. If the selection includes a published subject, you have to keep a published one. Removed subject URLs won't redirect, and the confirmation says so.
Navigation already mentioned
lead-verifier, but the database enum and API role schemas didn't define it. This adds the role without assigning it to anyone. Mobile dashboard tabs now use the same role checks as the desktop sidebar.After an edit or merge, the API starts the existing best-effort background search sync for affected guide search cards.
Refs #521
Type of change
Verification
Everything CI runs passes locally against upstream
deec6044, on Node 22 and pnpm 10.33.1: 345 app tests across 42 files, plus the API deploy dry run.I added 12 UI tests and 15 API integration tests covering picking subjects, editing, changing which subject to keep, cancellation, validation, retries, pending requests, permissions, filtering, pagination, stale selections, keeping guide and objective tags, and updating search-card tags. One test starts two merges sharing a source subject and checks that one succeeds while the other is rejected without losing the guide's tag.
All 65 tests in the five related API files pass against local Supabase, including the existing dashboard, identity, subject and objective-subject tests. The search-card test mocks Typesense rather than using a live search server.
For the October 24 browser pass, I signed in with a local lead-verifier account, filtered the table, edited a subject, and reloaded to confirm the edit stuck. I cancelled a merge with both Cancel and Escape, then merged three test subjects and reloaded. The duplicates stayed gone, and database checks confirmed the guide and objective drafts remained with one tag pointing to the kept subject. I also checked the layout at a narrow viewport.
The November 1 recheck brought the branch up to date and reran the automated tests. It wasn't a new browser pass.
An earlier run on
d54ae5d3failed the existing Markdown-import round-trip test because the returned Markdown had different italic markers and trailing whitespace. It passed alone and in the next full run. Upstream has since changed the editor and test, and the full run ondeec6044passes. This branch doesn't add editor changes, and I haven't pinned down the earlier intermittent failure.The existing
prefer-for-ofwarning inobjectiveGraphLayout.tsstill shows up. That file isn't touched here.What I didn't do: the full API integration suite, a fresh database reset, a live Typesense check, or testing on physical mobile devices or other browser engines.
Database and rollout
20261023115900_lead_verifier_role.sqlneeds to run before20261023120000_manage_dashboard_subjects.sql, and both need to be applied before the API and frontend go out. Both applied cleanly to the existing local test database. I checked the new function and role types against the generated database types.The merge function checks the caller's role before using elevated database permissions to move tags on revisions they might not otherwise see. It doesn't grant direct subject deletion permissions.
Merges can't be undone through the UI. Removed subject URLs won't redirect, and an already-open editor tab or browser-only draft can still hold an old subject ID; this doesn't rewrite those local copies. Search updates are best-effort, so a failed update needs a later resync.
This touches RLS policies, the database schema and roles, so per CONTRIBUTING it needs two maintainer approvals rather than one.