Commit 9ba210b
UN-2781 [FEAT] Add admin custom Stripe product creation support (#1651)
* feat: Add admin custom Stripe product creation support
This commit adds comprehensive support for admins to create custom Stripe
subscription products for both Unstract and LLM Whisperer platforms.
## Frontend Changes
### Router Updates (Router.jsx)
- Added dynamic import for LlmWhispererCustomCheckoutPage plugin component
- Added public route `/llm-whisperer/custom-checkout` for LLM Whisperer
custom plan checkout flow
- Follows existing pattern with try/catch for Cloud-only features
### Main App Routes (useMainAppRoutes.js)
- Added Unstract administration route at `/administration`
- Protected with RequireAdmin wrapper (admin-only access)
- Imported UnstractAdministrationPage component
### New Administration Page (UnstractAdministrationPage.jsx)
- Plugin-loader pattern with try/catch for Cloud-only component
- Falls back to "feature not available" message in OSS builds
- Dynamically imports UnstractAdministration from Cloud plugins
## Backend Changes (Already Committed)
The backend infrastructure was already added in previous commits:
### Subscription Routes (cloud_urls_v2.py)
- Unstract admin endpoint: `/api/v1/unstract/admin/stripe/products/dynamic/`
- LLM Whisperer admin endpoint: `/api/v1/llmwhisperer/admin/stripe/products/dynamic/portal/`
### Portal Proxy (subscription_v2/views.py)
- `create_dynamic_stripe_product_portal_proxy()` method forwards LLM Whisperer
admin requests to Portal service
- Follows existing LLMWhispererService pattern for multi-backend architecture
- Includes proper error handling and logging
### URL Patterns (subscription_v2/urls.py)
- Added `admin_stripe_product_portal_proxy` view and URL pattern
- Both endpoints protected with IsAuthenticated + IsAdmin permissions
## Architecture
This implementation follows Unstract's plugin-based architecture:
- OSS repo contains base routing and plugin-loader patterns
- Cloud repo contains actual admin UI components (subscription-admin plugin)
- Multi-backend support: Unstract uses local backend, LLM Whisperer proxies
to Portal service
- Graceful degradation for OSS builds (shows "Cloud-only feature" message)
## Related
- Supersedes PR #1087 (monolithic admin UI)
- Integrates checkout functionality from PR #1016
- Consolidates router changes from PR #1558
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* chore: Add NOSONAR comments for plugin loading pattern
Suppress SonarQube warnings for intentional empty catch blocks used in
plugin loading architecture. These catch blocks are part of the graceful
degradation pattern for Cloud-only features - when plugins are not available,
the component remains undefined and React Router triggers NotFound page.
This pattern is used throughout the codebase for optional plugin loading.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* style: Fix Prettier formatting for NOSONAR comments
Move NOSONAR comments to separate lines to comply with Prettier formatting rules.
Format multi-line Route component in useMainAppRoutes.js.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* fix: Correct NOSONAR comment placement for SonarQube
Place NOSONAR comment inline with catch statement for proper recognition.
SonarQube requires the suppression comment on the same line as the issue.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* fix: Add NOSONAR comments to suppress empty catch warnings
Add minimal NOSONAR comments to suppress SonarQube warnings for intentional
empty catch blocks in plugin loading pattern. These catch blocks are part of
the graceful degradation architecture for Cloud-only features.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* path modified admin cusotm plans
* UN-2861 [FEAT] Add RequireStaff permission for custom plans administration
Add platform staff-only access control for custom Unstract subscription plans:
- Add RequireStaff component to enforce platform staff access
- Update custom plans route to use RequireStaff instead of RequireAdmin
- Block access for open-source deployments (mock_org)
Frontend Changes:
- New RequireStaff.js component with isStaff and orgName validation
- Update useMainAppRoutes.js to use RequireStaff for /admin/custom-plans route
- Shows Unauthorized for non-staff users, NotFound for OSS deployments
This complements the backend IsStaff permission class to ensure only platform
staff can create custom Stripe products with dual pricing structure.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Remove unused RequireStaff component
Remove RequireStaff component as it's been replaced with inline staff
checking pattern in route files. This avoids component dependency issues
and follows the established Verticals pattern.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Remove RequireStaff dependency from OSS routes
Replace RequireStaff component wrapper with inline staff check using
useSessionStore in an IIFE. This matches the pattern used in Cloud
plugin routes and fixes the build error where RequireStaff component
was deleted but still referenced.
The inline check ensures:
- Staff-only access to admin custom plans route
- Hidden in open-source deployments (orgName === "mock_org")
- No component import dependencies
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>
* Fix Prettier formatting for staff check return statement
* Refactor inline CSS to classes in UnstractAdministrationPage
- Create UnstractAdministrationPage.css for fallback UI styling
- Replace inline styles with className in UnstractAdministrationPage.jsx
- Improves code maintainability and follows project's CSS patterns
* Fix React Rules of Hooks violation in useMainAppRoutes
- Move useSessionStore hook call to top level of function
- Remove IIFE pattern that violated hooks rules
- Simplify conditional rendering logic
Fixes CodeRabbit review comment about hooks being called inside nested function.
---------
Co-authored-by: Claude <[email protected]>
Co-authored-by: Rahul Johny <[email protected]>1 parent 9cc47bd commit 9ba210b
File tree
4 files changed
+57
-0
lines changed- frontend/src
- pages
- routes
4 files changed
+57
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
89 | 98 | | |
90 | 99 | | |
91 | 100 | | |
| |||
147 | 156 | | |
148 | 157 | | |
149 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
150 | 165 | | |
151 | 166 | | |
152 | 167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
98 | 100 | | |
99 | 101 | | |
100 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
101 | 108 | | |
102 | 109 | | |
103 | 110 | | |
| |||
117 | 124 | | |
118 | 125 | | |
119 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
120 | 133 | | |
121 | 134 | | |
122 | 135 | | |
| |||
0 commit comments