mirror of
https://github.com/logto-io/logto.git
synced 2024-12-30 20:33:54 -05:00
fix(console): should not block admin tenant owner from creating more tenants (#4066)
This commit is contained in:
parent
370b97ff36
commit
3a0944444a
2 changed files with 13 additions and 2 deletions
|
@ -37,3 +37,5 @@ export const getUserTenantId = () => {
|
|||
export const getBasename = () => (isCloud ? '/' + getUserTenantId() : ossConsolePath);
|
||||
|
||||
export const getSignOutRedirectPathname = () => (isCloud ? '/' : ossConsolePath);
|
||||
|
||||
export const maxFreeTenantNumbers = 3;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { adminTenantId } from '@logto/schemas';
|
||||
import { type TenantInfo } from '@logto/schemas/models';
|
||||
import classNames from 'classnames';
|
||||
import { useContext, useRef, useState, useEffect, useMemo } from 'react';
|
||||
|
@ -9,6 +10,7 @@ import Tick from '@/assets/icons/tick.svg';
|
|||
import { useCloudSwr } from '@/cloud/hooks/use-cloud-swr';
|
||||
import CreateTenantModal from '@/cloud/pages/Main/TenantLandingPage/TenantLandingPageContent/CreateTenantModal';
|
||||
import AppError from '@/components/AppError';
|
||||
import { maxFreeTenantNumbers } from '@/consts/tenants';
|
||||
import { TenantsContext } from '@/contexts/TenantsProvider';
|
||||
import Divider from '@/ds-components/Divider';
|
||||
import Dropdown, { DropdownItem } from '@/ds-components/Dropdown';
|
||||
|
@ -33,6 +35,15 @@ function TenantSelector() {
|
|||
return tenants?.find((tenant) => tenant.id === currentTenantId);
|
||||
}, [currentTenantId, tenants]);
|
||||
|
||||
const isCreateButtonDisabled = useMemo(
|
||||
() =>
|
||||
/** Should not block admin tenant owners from creating more than three tenants */
|
||||
tenants &&
|
||||
!tenants.some(({ id }) => id === adminTenantId) &&
|
||||
tenants.length >= maxFreeTenantNumbers,
|
||||
[tenants]
|
||||
);
|
||||
|
||||
const anchorRef = useRef<HTMLDivElement>(null);
|
||||
const [showDropdown, setShowDropdown] = useState(false);
|
||||
const [showCreateTenantModal, setShowCreateTenantModal] = useState(false);
|
||||
|
@ -45,8 +56,6 @@ function TenantSelector() {
|
|||
return null;
|
||||
}
|
||||
|
||||
const isCreateButtonDisabled = tenants.length >= 3;
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
|
|
Loading…
Reference in a new issue