Skip to content

Commit

Permalink
refactor: routes to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
BiswaViraj committed May 6, 2024
1 parent 9ee9da5 commit 6f26218
Showing 1 changed file with 46 additions and 57 deletions.
103 changes: 46 additions & 57 deletions apps/web/src/SettingsRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,84 +21,73 @@ import { WebhookPage } from './pages/settings/WebhookPage';
export const useSettingsRoutes = () => {
const isInformationArchitectureEnabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_INFORMATION_ARCHITECTURE_ENABLED);

if (isInformationArchitectureEnabled) {
return (
<Route path={ROUTES.SETTINGS} element={<SettingsPage />}>
<Route path="" element={<Navigate to={ROUTES.PROFILE} replace />} />
<Route path={ROUTES.API_KEYS} element={<ApiKeysPage />} />
<Route path={ROUTES.BRAND_SETTINGS} element={<BrandingPage />} />
<Route path={ROUTES.ORGANIZATION} element={<OrganizationPage />} />
<Route path={ROUTES.TEAM_SETTINGS} element={<TeamPage />} />
<Route path={`${ROUTES.BILLING}/*`} element={<BillingPage />} />
<Route path={ROUTES.WEBHOOK} element={<WebhookPage />} />
<Route path={ROUTES.SECURITY} element={<AccessSecurityPage />} />
<Route path={`${ROUTES.SETTINGS}`} element={<Navigate to={ROUTES.PROFILE} replace />} />
<Route path="permissions" element={<Navigate to={ROUTES.SECURITY} replace />} />
<Route path="sso" element={<Navigate to={ROUTES.SETTINGS} replace />} />
<Route path="data-integrations" element={<Navigate to={ROUTES.SETTINGS} replace />} />
<Route path={ROUTES.PROFILE} element={<UserProfilePage />} />
<Route path={`${ROUTES.SETTINGS}/*`} element={<Navigate to={ROUTES.SETTINGS} replace />} />
</Route>
);
}

/* TODO: remove all routes above once information architecture is fully enabled */
return (
<>
<Route path={ROUTES.SETTINGS} element={isInformationArchitectureEnabled ? <SettingsPage /> : <SettingsPageOld />}>
<Route
path=""
element={isInformationArchitectureEnabled ? <Navigate to={ROUTES.PROFILE} replace /> : <ApiKeysCard />}
/>
<Route path={ROUTES.SETTINGS} element={<SettingsPageOld />}>
<Route path="" element={<ApiKeysCard />} />
<Route path="billing/*" element={<BillingRoutes />} />
<Route path="email" element={<EmailSettings />} />
<Route path="team" element={<MembersInvitePageNew />} />
<Route path="brand" element={<BrandingFormOld />} />
{/* ensure legacy routes re-route to base settings page */}
<Route
path="permissions"
element={
!isInformationArchitectureEnabled ? (
<ProductLead
icon={<UserAccess />}
id="rbac-permissions"
title="Role-based access control"
text="Securely manage users' permissions to access system resources."
closeable={false}
/>
) : (
<Navigate to={ROUTES.SECURITY} replace />
)
<ProductLead
icon={<UserAccess />}
id="rbac-permissions"
title="Role-based access control"
text="Securely manage users' permissions to access system resources."
closeable={false}
/>
}
/>
<Route
path="sso"
element={
!isInformationArchitectureEnabled ? (
<ProductLead
icon={<SSO />}
id="sso-settings"
title="Single Sign-On (SSO)"
text="Simplify user authentication and enhance security."
closeable={false}
/>
) : (
<Navigate to={ROUTES.SETTINGS} replace />
)
<ProductLead
icon={<SSO />}
id="sso-settings"
title="Single Sign-On (SSO)"
text="Simplify user authentication and enhance security."
closeable={false}
/>
}
/>
<Route
path="data-integrations"
element={
!isInformationArchitectureEnabled ? (
<ProductLead
icon={<Cloud />}
id="data-integrations-settings"
title="Data Integrations"
text="Share data with 3rd party services via Segment and Datadog integrations to monitor analytics."
closeable={false}
/>
) : (
<Navigate to={ROUTES.SETTINGS} replace />
)
<ProductLead
icon={<Cloud />}
id="data-integrations-settings"
title="Data Integrations"
text="Share data with 3rd party services via Segment and Datadog integrations to monitor analytics."
closeable={false}
/>
}
/>
{/* TODO: remove all routes above once information architecture is fully enabled */}
<Route
path={ROUTES.PROFILE}
// Note: this is unfortunately necessary for password reset redirects work properly with search params
element={isInformationArchitectureEnabled ? <UserProfilePage /> : <Navigate to={ROUTES.SETTINGS} replace />}
/>
{isInformationArchitectureEnabled && (
<>
<Route path={ROUTES.API_KEYS} element={<ApiKeysPage />} />
<Route path={ROUTES.BRAND_SETTINGS} element={<BrandingPage />} />
<Route path={ROUTES.ORGANIZATION} element={<OrganizationPage />} />
<Route path={ROUTES.TEAM_SETTINGS} element={<TeamPage />} />
<Route path={`${ROUTES.BILLING}/*`} element={<BillingPage />} />
<Route path={ROUTES.WEBHOOK} element={<WebhookPage />} />
<Route path={ROUTES.SECURITY} element={<AccessSecurityPage />} />
<Route path={`${ROUTES.SETTINGS}`} element={<Navigate to={ROUTES.PROFILE} replace />} />
</>
)}
<Route path={ROUTES.PROFILE} element={<Navigate to={ROUTES.SETTINGS} replace />} />
<Route path={`${ROUTES.SETTINGS}/*`} element={<Navigate to={ROUTES.SETTINGS} replace />} />
</Route>
</>
Expand Down

0 comments on commit 6f26218

Please sign in to comment.