diff --git a/packages/console/src/hooks/use-console-routes/index.tsx b/packages/console/src/hooks/use-console-routes/index.tsx index 61d5db43e..47ee00f04 100644 --- a/packages/console/src/hooks/use-console-routes/index.tsx +++ b/packages/console/src/hooks/use-console-routes/index.tsx @@ -1,6 +1,6 @@ import { condArray } from '@silverhand/essentials'; import { useMemo } from 'react'; -import { type RouteObject } from 'react-router-dom'; +import { Navigate, type RouteObject } from 'react-router-dom'; import { isCloud, isDevFeaturesEnabled } from '@/consts/env'; import Dashboard from '@/pages/Dashboard'; @@ -8,6 +8,11 @@ import GetStarted from '@/pages/GetStarted'; import Mfa from '@/pages/Mfa'; import NotFound from '@/pages/NotFound'; import OrganizationGuide from '@/pages/Organizations/Guide'; +import Introduction from '@/pages/Organizations/Guide/Introduction'; +import OrganizationInfo from '@/pages/Organizations/Guide/OrganizationInfo'; +import OrganizationPermissions from '@/pages/Organizations/Guide/OrganizationPermissions'; +import OrganizationRoles from '@/pages/Organizations/Guide/OrganizationRoles'; +import { steps } from '@/pages/Organizations/Guide/const'; import SigningKeys from '@/pages/SigningKeys'; import { apiResources } from './routes/api-resources'; @@ -46,7 +51,17 @@ export const useConsoleRoutes = () => { roles, isDevFeaturesEnabled && organizationTemplate, organizations, - !isDevFeaturesEnabled && { path: 'organization-guide/*', element: }, + !isDevFeaturesEnabled && { + path: 'organization-guide/*', + element: , + children: [ + { index: true, element: }, + { path: steps.introduction, element: }, + { path: steps.permissions, element: }, + { path: steps.roles, element: }, + { path: steps.organizationInfo, element: }, + ], + }, profile, { path: 'signing-keys', element: }, isCloud && tenantSettings, diff --git a/packages/console/src/hooks/use-console-routes/routes/tenant-settings.tsx b/packages/console/src/hooks/use-console-routes/routes/tenant-settings.tsx index eb08de787..fd33b2384 100644 --- a/packages/console/src/hooks/use-console-routes/routes/tenant-settings.tsx +++ b/packages/console/src/hooks/use-console-routes/routes/tenant-settings.tsx @@ -5,17 +5,20 @@ import { Navigate, type RouteObject } from 'react-router-dom'; import { TenantSettingsTabs } from '@/consts'; import { TenantsContext } from '@/contexts/TenantsProvider'; import useCurrentTenantScopes from '@/hooks/use-current-tenant-scopes'; +import NotFound from '@/pages/NotFound'; import TenantSettings from '@/pages/TenantSettings'; import BillingHistory from '@/pages/TenantSettings/BillingHistory'; import Subscription from '@/pages/TenantSettings/Subscription'; import TenantBasicSettings from '@/pages/TenantSettings/TenantBasicSettings'; import TenantDomainSettings from '@/pages/TenantSettings/TenantDomainSettings'; import TenantMembers from '@/pages/TenantSettings/TenantMembers'; +import Invitations from '@/pages/TenantSettings/TenantMembers/Invitations'; +import Members from '@/pages/TenantSettings/TenantMembers/Members'; export const useTenantSettings = () => { const { isDevTenant } = useContext(TenantsContext); const { - access: { canManageTenant }, + access: { canInviteMember, canManageTenant }, } = useCurrentTenantScopes(); const tenantSettings: RouteObject = useMemo( @@ -33,7 +36,15 @@ export const useTenantSettings = () => { ), }, { path: TenantSettingsTabs.Settings, element: }, - { path: `${TenantSettingsTabs.Members}/*`, element: }, + { + path: `${TenantSettingsTabs.Members}/*`, + element: , + children: [ + { path: '*', element: }, + { index: true, element: }, + ...condArray(canInviteMember && [{ path: 'invitations', element: }]), + ], + }, { path: TenantSettingsTabs.Domains, element: }, !isDevTenant && canManageTenant && [ @@ -42,7 +53,7 @@ export const useTenantSettings = () => { ] ), }), - [canManageTenant, isDevTenant] + [canInviteMember, canManageTenant, isDevTenant] ); return tenantSettings; diff --git a/packages/console/src/pages/Organizations/Guide/index.tsx b/packages/console/src/pages/Organizations/Guide/index.tsx index e59e80ef1..618e9ec86 100644 --- a/packages/console/src/pages/Organizations/Guide/index.tsx +++ b/packages/console/src/pages/Organizations/Guide/index.tsx @@ -1,18 +1,11 @@ import { useCallback } from 'react'; import Modal from 'react-modal'; -// FIXME: @charles -// eslint-disable-next-line no-restricted-imports -import { Navigate, Route, Routes } from 'react-router-dom'; +import { Outlet } from 'react-router-dom'; import DsModalHeader from '@/ds-components/ModalHeader'; import useTenantPathname from '@/hooks/use-tenant-pathname'; import * as modalStyles from '@/scss/modal.module.scss'; -import Introduction from './Introduction'; -import OrganizationInfo from './OrganizationInfo'; -import OrganizationPermissions from './OrganizationPermissions'; -import OrganizationRoles from './OrganizationRoles'; -import { steps } from './const'; import * as styles from './index.module.scss'; function Guide() { @@ -30,13 +23,7 @@ function Guide() { subtitle="organizations.guide.subtitle" onClose={onClose} /> - - } /> - } /> - } /> - } /> - } /> - + ); diff --git a/packages/console/src/pages/TenantSettings/TenantMembers/index.tsx b/packages/console/src/pages/TenantSettings/TenantMembers/index.tsx index 43dd2c439..fe6c694d0 100644 --- a/packages/console/src/pages/TenantSettings/TenantMembers/index.tsx +++ b/packages/console/src/pages/TenantSettings/TenantMembers/index.tsx @@ -1,8 +1,6 @@ import classNames from 'classnames'; import { useContext, useState } from 'react'; -// FIXME: @charles -// eslint-disable-next-line no-restricted-imports -import { Route, Routes } from 'react-router-dom'; +import { Outlet } from 'react-router-dom'; import useSWRMutation from 'swr/mutation'; import InvitationIcon from '@/assets/icons/invitation.svg'; @@ -16,16 +14,11 @@ import Button from '@/ds-components/Button'; import Spacer from '@/ds-components/Spacer'; import useCurrentTenantScopes from '@/hooks/use-current-tenant-scopes'; import useTenantPathname from '@/hooks/use-tenant-pathname'; -import NotFound from '@/pages/NotFound'; -import Invitations from './Invitations'; import InviteMemberModal from './InviteMemberModal'; -import Members from './Members'; import useTenantMembersUsage from './hooks'; import * as styles from './index.module.scss'; -const invitationsRoute = 'invitations'; - function TenantMembers() { const { hasTenantMembersSurpassedLimit } = useTenantMembersUsage(); const { navigate, match } = useTenantPathname(); @@ -34,9 +27,7 @@ function TenantMembers() { access: { canInviteMember }, } = useCurrentTenantScopes(); - const isInvitationTab = match( - `/tenant-settings/${TenantSettingsTabs.Members}/${invitationsRoute}` - ); + const isInvitationTab = match(`/tenant-settings/${TenantSettingsTabs.Members}/invitations`); const { currentTenantId } = useContext(TenantsContext); const cloudApi = useAuthedCloudApi(); @@ -84,11 +75,7 @@ function TenantMembers() { /> )} - - } /> - } /> - {canInviteMember && } />} - + {canInviteMember && (