From 8e0d717781af8a24bd2e828bd4ed8a5239d01e07 Mon Sep 17 00:00:00 2001 From: Charles Zhao Date: Tue, 12 Nov 2024 11:20:58 +0800 Subject: [PATCH] refactor(console): update value of the last-visited tenant wildcard (#6787) --- .../console/src/containers/TenantAccess/index.tsx | 5 +++-- packages/console/src/contexts/TenantsProvider.tsx | 13 +++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/console/src/containers/TenantAccess/index.tsx b/packages/console/src/containers/TenantAccess/index.tsx index b779d6026..17e4cc066 100644 --- a/packages/console/src/containers/TenantAccess/index.tsx +++ b/packages/console/src/containers/TenantAccess/index.tsx @@ -71,8 +71,9 @@ export default function TenantAccess() { isAuthenticated && currentTenantId && // The current tenant is unavailable to the user, maybe a deleted tenant or a tenant that - // the user has no access to. Try with prepended default tenant ID, or if it's not available, - // redirect to the home page. + // the user has no access to. + // If the current tenant ID equals the reserved wildcard "to", replace it with the last + // visited tenant ID and keeping the rest of the URL path, otherwise redirect to home page. !currentTenant ) { if (isCloud && defaultTenantId && currentTenantId === reservedTenantIdWildcard) { diff --git a/packages/console/src/contexts/TenantsProvider.tsx b/packages/console/src/contexts/TenantsProvider.tsx index f7fdff34a..abfffc0de 100644 --- a/packages/console/src/contexts/TenantsProvider.tsx +++ b/packages/console/src/contexts/TenantsProvider.tsx @@ -35,11 +35,16 @@ const reservedRoutes: Readonly = Object.freeze([ ]); /** - * The reserved tenant ID wildcard for the default tenant. Useful when specifying a console URL in - * the documentation or other places where the tenant ID is not known. Will be replaced with the - * actual default tenant ID in the runtime. + * The reserved tenant ID wildcard for the last-visited tenant. Useful when specifying a console URL in + * the documentation or other places where the actual user tenant ID is unknown. The wildcard value "to" + * will be replaced by the detected last-visited tenant ID in the runtime. + * + * @example + * ```md + * [Console > Applications](https://cloud.logto.io/to/applications) + * ``` */ -export const reservedTenantIdWildcard = 'default'; +export const reservedTenantIdWildcard = 'to'; /** @see {@link TenantsProvider} for why `useSWR()` is not applicable for this context. */ type Tenants = {