diff --git a/packages/console/src/App.tsx b/packages/console/src/App.tsx index 601db2e73..2c0dc1ab6 100644 --- a/packages/console/src/App.tsx +++ b/packages/console/src/App.tsx @@ -11,6 +11,7 @@ import './scss/overlayscrollbars.scss'; // eslint-disable-next-line import/no-unassigned-import import '@fontsource/roboto-mono'; +import CloudApp from '@/cloud/App'; import AppLoading from '@/components/AppLoading'; import Toast from '@/components/Toast'; import { getManagementApi, meApi } from '@/consts/management-api'; @@ -39,7 +40,6 @@ import UserDetails from '@/pages/UserDetails'; import Users from '@/pages/Users'; import Welcome from '@/pages/Welcome'; -import Cloud from './cloud/pages/Cloud'; import { ApiResourceDetailsTabs, ConnectorsTabs, @@ -50,7 +50,6 @@ import { getUserTenantId, getBasename, } from './consts'; -import { isCloud } from './consts/cloud'; import AppContent from './containers/AppContent'; import AppEndpointsProvider, { AppEndpointsContext } from './containers/AppEndpointsProvider'; import ApiResourcePermissions from './pages/ApiResourceDetails/ApiResourcePermissions'; @@ -82,7 +81,6 @@ const Main = () => { } /> } /> }> - {isCloud && } />} }> } /> } /> @@ -163,7 +161,13 @@ const Main = () => { }; const App = () => { - const managementApi = getManagementApi(getUserTenantId()); + const tenantId = getUserTenantId(); + + if (!tenantId) { + return ; + } + + const managementApi = getManagementApi(tenantId); return ( diff --git a/packages/console/src/cloud/App.module.scss b/packages/console/src/cloud/App.module.scss new file mode 100644 index 000000000..373cb4d67 --- /dev/null +++ b/packages/console/src/cloud/App.module.scss @@ -0,0 +1,4 @@ +.app { + position: absolute; + inset: 0; +} diff --git a/packages/console/src/cloud/App.tsx b/packages/console/src/cloud/App.tsx new file mode 100644 index 000000000..25005955e --- /dev/null +++ b/packages/console/src/cloud/App.tsx @@ -0,0 +1,21 @@ +import { BrowserRouter, Route, Routes } from 'react-router-dom'; + +import * as styles from './App.module.scss'; +import Main from './pages/Main'; +import Onboard from './pages/Onboard'; +import { CloudRoute } from './types'; + +const App = () => { + return ( + +
+ + } /> + } /> + +
+
+ ); +}; + +export default App; diff --git a/packages/console/src/cloud/pages/Cloud/index.module.scss b/packages/console/src/cloud/pages/Cloud/index.module.scss deleted file mode 100644 index 88871eb0f..000000000 --- a/packages/console/src/cloud/pages/Cloud/index.module.scss +++ /dev/null @@ -1,4 +0,0 @@ -.cloud { - flex-grow: 1; - overflow: hidden; -} diff --git a/packages/console/src/cloud/pages/Main/index.tsx b/packages/console/src/cloud/pages/Main/index.tsx new file mode 100644 index 000000000..0d344003b --- /dev/null +++ b/packages/console/src/cloud/pages/Main/index.tsx @@ -0,0 +1,5 @@ +const Main = () => { + return
Main
; +}; + +export default Main; diff --git a/packages/console/src/cloud/pages/Onboard/index.module.scss b/packages/console/src/cloud/pages/Onboard/index.module.scss new file mode 100644 index 000000000..65aff9d7d --- /dev/null +++ b/packages/console/src/cloud/pages/Onboard/index.module.scss @@ -0,0 +1,4 @@ +.onBoard { + height: 100%; + overflow: hidden; +} diff --git a/packages/console/src/cloud/pages/Cloud/index.tsx b/packages/console/src/cloud/pages/Onboard/index.tsx similarity index 93% rename from packages/console/src/cloud/pages/Cloud/index.tsx rename to packages/console/src/cloud/pages/Onboard/index.tsx index 9fce9b1a0..2b3b750b3 100644 --- a/packages/console/src/cloud/pages/Cloud/index.tsx +++ b/packages/console/src/cloud/pages/Onboard/index.tsx @@ -13,7 +13,7 @@ import * as styles from './index.module.scss'; const welcomePathname = getCloudPagePathname(CloudPage.Welcome); -const Cloud = () => { +const Onboard = () => { const { data: { questionnaire }, isLoaded, @@ -24,7 +24,7 @@ const Cloud = () => { } return ( -
+
} /> } /> @@ -46,4 +46,4 @@ const Cloud = () => { ); }; -export default Cloud; +export default Onboard; diff --git a/packages/console/src/cloud/types.ts b/packages/console/src/cloud/types.ts index 5eb33d24a..95c60d08f 100644 --- a/packages/console/src/cloud/types.ts +++ b/packages/console/src/cloud/types.ts @@ -1,5 +1,9 @@ import { z } from 'zod'; +export enum CloudRoute { + Onboard = 'onboard', +} + export enum CloudPage { Welcome = 'welcome', AboutUser = 'about-user', diff --git a/packages/console/src/consts/tenants.ts b/packages/console/src/consts/tenants.ts index 156a585ac..935034f6c 100644 --- a/packages/console/src/consts/tenants.ts +++ b/packages/console/src/consts/tenants.ts @@ -1,5 +1,7 @@ import { defaultTenantId, ossConsolePath } from '@logto/schemas'; +import { CloudRoute } from '@/cloud/types'; + import { isCloud } from './cloud'; const isProduction = process.env.NODE_ENV === 'production'; @@ -10,7 +12,14 @@ export const adminTenantEndpoint = export const getUserTenantId = () => { if (isCloud) { - return window.location.pathname.split('/')[1] ?? ''; + const segment = window.location.pathname.split('/')[1]; + + // eslint-disable-next-line no-restricted-syntax + if (Object.values(CloudRoute).includes(segment as CloudRoute)) { + return ''; + } + + return segment ?? ''; } return defaultTenantId;