Skip to content

feat(frontend): add PortfolioSettingsPage for opt-in public portfolios - #390

Open
Anshuu2004 wants to merge 1 commit into
VarshithReddy2006:mainfrom
Anshuu2004:feat/issue-338-portfolio-settings
Open

Anshuu2004 wants to merge 1 commit into
VarshithReddy2006:mainfrom
Anshuu2004:feat/issue-338-portfolio-settings

Conversation

@Anshuu2004

Copy link
Copy Markdown
Contributor

Summary

Adds the Portfolio Settings page at /profile/portfolio, built on the publication API from #381 (GET, PUT, DELETE /api/v1/profile/publication). Nothing is public until the user ticks consent and publishes.

Closes #338

Depends on #381: that PR is not on main yet, so this branch is based on main and the page degrades on a server without the route (a 404 shows "Public portfolios aren't available on this server yet" and does not retry). Once #381 lands the page works as is.

What changed

  • frontend/src/services/publicationService.ts: fetchPublication, publishProfile (PUT, also used to change handle or sections of a published profile), unpublishProfile, plus helpers that map the 400 / 409 answers.
  • frontend/src/pages/PortfolioSettingsPage.tsx and features/portfolio/*:
    • HandlePicker: 300ms debounced format feedback using the same slug rule as the backend (^[a-z0-9][a-z0-9-]{1,28}[a-z0-9]$, trimmed and lowercased first). The server only reports taken or reserved handles at publish time (409), so that message is shown on the handle field and cleared when the user edits it.
    • SectionToggles: one accessible switch per real section (streak, dsa, github, projects, activity). Everything starts off.
    • ConsentPanel: what becomes public, plus the checkbox. Once published it shows the consent version on record instead.
    • PublishBar: "Published at /u/slug" or "Draft / Private", View Live, Publish / Update handle, and a red Unpublish Immediately.
    • usePublication hook (react-query, no retry on 404).
  • Once published, a section switch saves right away using the live handle and rolls back with an error if the save fails, so hiding something takes effect immediately.
  • Route /profile/portfolio in router/index.tsx, and a "Manage your public portfolio" link on the profile page.

How I tested

Run from frontend/, one file at a time:

npx vitest run src/services/publicationService.test.ts                        # 6 passed
npx vitest run src/features/portfolio/utils/slug.test.ts                      # 14 passed
npx vitest run src/features/portfolio/components/HandlePicker.test.tsx        # 3 passed
npx vitest run src/features/portfolio/components/SectionToggles.test.tsx      # 2 passed
npx vitest run src/pages/PortfolioSettingsPage.test.tsx                       # 10 passed
npx vitest run src/pages/PortfolioSettingsPage.route.test.tsx                 # 1 passed

With the router change stashed the route test fails, and with the immediate-save branch removed two page tests fail (save on toggle, rollback on error). tsc -p tsconfig.app.json --noEmit shows no errors in the files touched here.

Notes

  • Left out on purpose, same as in my claim comment: dossier card and indexing toggle (no API for them), the 9 section names in the issue (the API has 5), and a client side availability check (/profile/handle/availability does not exist, only the 409 tells you).
  • The consent version sent on publish is the constant CONSENT_VERSION in ConsentPanel.tsx (the backend only validates its format); bump it if the consent text changes.
  • docs/v2/*.md named in the issue are not in the repo, so no docs change.
  • Not tested: against a real backend with feat(profile): make public profiles private by default with opt-in publication #381 applied (only mocked at the service layer), a real browser run, ESLint (config would not load in my environment). ProfilePage.public.test.tsx cannot run in my environment because of a missing @tailwindcss/postcss module; it fails the same way on an untouched checkout, and I only added a link to the owner-only part of ProfilePage.tsx.

New /profile/portfolio page on top of GET/PUT/DELETE /api/v1/profile/publication
(PR VarshithReddy2006#381). It has a handle field with 300ms debounced format feedback, one
switch for each of the five real sections (streak, dsa, github, projects,
activity), a consent panel, and a publish bar with the live status, View
Live and Unpublish Immediately.

Nothing is public until the user ticks consent and publishes. Once
published, a section switch saves right away with the live handle and rolls
back if the save fails. Reserved or taken handles are only known from the
409 on publish, so that answer is shown on the handle field. If the server
answers 404 for the route the page says portfolios are not available yet
instead of failing. ProfilePage gets a link to the new page.

No dossier card or indexing toggle, since there is no API for them yet.

Closes VarshithReddy2006#338

Signed-off-by: Abhishek <abhishekcse2004@gmail.com>
@VarshithReddy2006 VarshithReddy2006 added enhancement New feature or request help wanted Extra attention is needed nsoc26 level2 5 points - UI, frontend components, layouts, styling, and page-level changes. labels Nov 16, 2026
@VarshithReddy2006

Copy link
Copy Markdown
Owner

@Anshuu2004 CI/CD checks are currently failing on Unit Tests:

AssertionError: expected undefined to match object { achievements: [], trust: { underReview: true } }
 ❯ src/__tests__/modules/profile/antiGaming.worker.test.ts:138:18

This failure occurs because public profiles are now private by default with opt-in publication (from PR #381).

Please rebase/merge the latest main into your branch and fix this issue immediately so that CI checks turn green.

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

Labels

enhancement New feature or request help wanted Extra attention is needed level2 5 points - UI, frontend components, layouts, styling, and page-level changes. nsoc26

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(frontend,m8): build PortfolioSettingsPage with section toggles, handle availability picker, and signed dossier card

2 participants