fix: empty outlet in admin org routes by rsbh · Pull Request #1407 · raystack/frontier
Summary
This PR moves the from sdk package to admin apps and both are getting different instance of router and screens are not getting rendered.
Changes
Technical Details
Test Plan
- Manual testing completed
- Build and type checking passes
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
web/sdk/admin/views/preferences/layout.tsx
💤 Files with no reviewable changes (1)
- web/sdk/admin/views/preferences/layout.tsx
📝 Walkthrough
Summary by CodeRabbit
- Refactor
- Reworked organization details to use a centralized context, improving reliability and maintainability without changing user workflows.
- New Features
- Added an "Add Domain" section on the organization security page.
- Bug Fixes
- Improved null-safety for organization data to prevent intermittent errors and ensure consistent titles and lists.
- Chores
- Removed the previous preferences layout implementation.
Walkthrough
Replaces React Router Outlet/OutletContext usage with a children-based OrganizationDetails API and OrganizationContext access. Parent page now renders OrganizationDetails wrapping an Outlet; nested views obtain organization from OrganizationContext and null-safe optional chaining was added.
Changes
| Cohort / File(s) | Summary |
|---|---|
Routing entry web/apps/admin/src/pages/organizations/details/index.tsx |
Switched OrganizationDetails from a self-closing component to a wrapper that contains an Outlet; imports reorganized to include Outlet. |
OrganizationDetails API web/sdk/admin/views/organizations/details/index.tsx |
Removed Outlet/OutletContext usage; added children?: React.ReactNode prop and now renders passed children inside layout. |
Child views — security web/sdk/admin/views/organizations/details/security/block-organization.tsx, web/sdk/admin/views/organizations/details/security/domains-list.tsx, web/sdk/admin/views/organizations/details/security/index.tsx |
Replaced useOutletContext with useContext(OrganizationContext); removed OutletContext imports; added optional chaining (organization?.id, organization?.title) where needed. |
Types cleanup web/sdk/admin/views/organizations/details/types.ts |
Removed exported OutletContext interface. |
Preferences layout removal web/sdk/admin/views/preferences/layout.tsx |
Deleted PreferencesLayout component and its data-fetching/Outlet context provisioning. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
- feat: export Organisations page as a component and consume it in apps/admin #1397: Similar migration away from
OutletContexttoOrganizationContextacross organization-details code paths. - fix: remove router reference #1403: Related changes to
OrganizationDetailsrouting API and removal of router hooks, overlapping on component API and navigation integration.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
web/sdk/admin/views/organizations/details/index.tsx (1)
286-296: ⚠️ Potential issue | 🔴 CriticalFix prop type mismatch for
children.
OrganizationDetailsLayoutrequireschildren: React.ReactNode(line 16 inlayout/index.tsx), butOrganizationDetailsdefines it as optional (children?: React.ReactNodeinOrganizationDetailsProps). This type mismatch means passingundefinedchildren violates the layout's type contract. Either makechildrenrequired inOrganizationDetailsPropsor optional inOrganizationDetailsLayoutProps.
🧹 Nitpick comments (2)
web/sdk/admin/views/organizations/details/security/index.tsx (2)
13-13: Duplicatereactimport — merge into one.Lines 13 and 24 both import from
'react'. These should be consolidated.♻️ Proposed fix
-import { useContext } from 'react'; +import { useContext, useEffect } from 'react'; import { OrganizationContext } from '../contexts/organization-context'; import { BlockOrganizationSection } from './block-organization'; import { DomainsList } from './domains-list'; import { PageTitle } from '../../../../components/PageTitle'; import { useQuery } from '@connectrpc/connect-query'; import { FrontierServiceQueries, ListOrganizationDomainsRequestSchema } from '@raystack/proton/frontier'; import { create } from '@bufbuild/protobuf'; -import { useEffect } from 'react';Also applies to: 24-24
82-85:?? []fallback is redundant.The
selectfunction already guaranteesdomainsis always an array (data?.domains || []), so the?? []at the call site is unreachable.♻️ Proposed fix
- domains={domains ?? []} + domains={domains}
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
web/apps/admin/src/pages/organizations/details/index.tsxweb/sdk/admin/views/organizations/details/index.tsxweb/sdk/admin/views/organizations/details/security/block-organization.tsxweb/sdk/admin/views/organizations/details/security/domains-list.tsxweb/sdk/admin/views/organizations/details/security/index.tsxweb/sdk/admin/views/organizations/details/types.ts
Pull Request Test Coverage Report for Build 22301602536
Details
- 0 of 0 changed or added relevant lines in 0 files are covered.
- No unchanged relevant lines lost coverage.
- Overall coverage remained the same at 38.457%
| Totals | |
|---|---|
| Change from base Build 22297745104: | 0.0% |
| Covered Lines: | 16200 |
| Relevant Lines: | 42125 |
💛 - Coveralls
rsbh
deleted the
fix_admin_ui_outlet
branch
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