feat: add contract admin view link for B2B managers#3369
Open
daniellefrappier18 wants to merge 2 commits into
Open
feat: add contract admin view link for B2B managers#3369daniellefrappier18 wants to merge 2 commits into
daniellefrappier18 wants to merge 2 commits into
Conversation
OpenAPI ChangesNo changes detected Unexpected changes? Ensure your branch is up-to-date with |
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an organization contract “admin” view for B2B managers and exposes navigation to it from the learner contract dashboard, with rollout controlled via a PostHog feature flag.
Changes:
- Introduces
/organization/[orgSlug]/contract/[contractSlug]/admin(authenticated route) and a newContractAdminPagethat loads manager orgs + contract detail. - Adds a feature-flagged “Manage” button on the contract dashboard header, shown only when the viewer is a manager for that org.
- Fixes
matchOrganizationBySlugto only strip theorg-prefix when it appears at the start of the slug.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| frontends/main/src/common/utils.ts | Anchors org- prefix stripping in matchOrganizationBySlug. |
| frontends/main/src/common/urls.ts | Adds CONTRACT_ADMIN_VIEW + contractAdminView() URL helper. |
| frontends/main/src/common/feature_flags.ts | Registers B2BContractManagerDashboard feature flag. |
| frontends/main/src/app/(site)/organization/[orgSlug]/contract/[contractSlug]/admin/page.tsx | Adds App Router page wiring to ContractAdminPage. |
| frontends/main/src/app/(site)/organization/[orgSlug]/contract/[contractSlug]/admin/layout.tsx | Adds auth restriction + metadata for the admin route. |
| frontends/main/src/app-pages/DashboardPage/ContractContent.tsx | Adds manager/flag-gated “Manage” button and supporting query. |
| frontends/main/src/app-pages/ContractAdminPage/ContractAdminPage.tsx | Implements initial admin page header + seat count fetch, flag-gated. |
| frontends/api/src/mitxonline/hooks/organizations/queries.ts | Adds manager org/contract query options + keys; refactors prior attach mutation out. |
| frontends/api/src/mitxonline/hooks/organizations/index.ts | Re-homes useB2BAttachMutation, exports manager org queries. |
Comment on lines
408
to
+463
| @@ -436,6 +453,14 @@ const ContractContentInternal: React.FC<ContractContentInternalProps> = ({ | |||
| <Stack> | |||
| <ContractHeaderSection> | |||
| <ContractHeader org={org} contract={contract} /> | |||
| {managerDashboardFlag && isManager && ( | |||
| <ButtonLink | |||
| size="small" | |||
| href={contractAdminView(orgSlug, contractSlug)} | |||
| > | |||
| Manage | |||
| </ButtonLink> | |||
| )} | |||
Comment on lines
+159
to
+173
| const ContractAdminPage: React.FC<ContractAdminPageProps> = ({ | ||
| orgSlug, | ||
| contractSlug, | ||
| }) => { | ||
| const flagEnabled = useFeatureFlagEnabled( | ||
| FeatureFlags.B2BContractManagerDashboard, | ||
| ) | ||
|
|
||
| if (flagEnabled === false) { | ||
| throw new ForbiddenError("Not enabled.") | ||
| } | ||
|
|
||
| if (!flagEnabled) { | ||
| return null | ||
| } |
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.
What are the relevant tickets?
Closes https://github.com/mitodl/hq/issues/11446
Description (What does it do?)
The admin page currently shows: org logo, org name, contract name, and total seat count (loading skeleton while fetching detail). More content will follow in subsequent phases.
Screenshots (if appropriate):
How can this be tested?
Setup: You'll need a user account that is a manager of at least one B2B org in MITxOnline, and the b2b-contract-manager-dashboard feature flag toggled in PostHog.
Feature flag off (default state)
Feature flag on, authenticated manager
Feature flag on, authenticated non-manager
Feature flag on, unauthenticated user
Error states
Regression
Additional Context