@@ -2,17 +2,21 @@ import { type AdminConsoleKey } from '@logto/phrases';
22import type { Role , ScopeResponse } from '@logto/schemas' ;
33import { RoleType , internalRolePrefix } from '@logto/schemas' ;
44import { conditional } from '@silverhand/essentials' ;
5+ import { useContext } from 'react' ;
56import { Controller , useForm } from 'react-hook-form' ;
67import { useTranslation } from 'react-i18next' ;
78
89import RoleScopesTransfer from '@/components/RoleScopesTransfer' ;
10+ import { isDevFeaturesEnabled } from '@/consts/env' ;
11+ import { SubscriptionDataContext } from '@/contexts/SubscriptionDataProvider' ;
912import DynamicT from '@/ds-components/DynamicT' ;
1013import FormField from '@/ds-components/FormField' ;
1114import ModalLayout from '@/ds-components/ModalLayout' ;
1215import RadioGroup , { Radio } from '@/ds-components/RadioGroup' ;
1316import TextInput from '@/ds-components/TextInput' ;
1417import useApi from '@/hooks/use-api' ;
1518import { trySubmitSafe } from '@/utils/form' ;
19+ import { isPaidPlan } from '@/utils/subscription' ;
1620
1721import Footer from './Footer' ;
1822import styles from './index.module.scss' ;
@@ -39,6 +43,15 @@ type CreateRolePayload = Pick<Role, 'name' | 'description' | 'type'> & {
3943function CreateRoleForm ( { onClose } : Props ) {
4044 const { t } = useTranslation ( undefined , { keyPrefix : 'admin_console' } ) ;
4145
46+ const {
47+ currentSubscription : { planId, isEnterprisePlan } ,
48+ currentSubscriptionBasicQuota : { userRolesLimit, machineToMachineRolesLimit } ,
49+ } = useContext ( SubscriptionDataContext ) ;
50+
51+ const isPaidTenant = isPaidPlan ( planId , isEnterprisePlan ) ;
52+ // We need to hide the add-on tag for legacy plans who has unlimited roles.
53+ const hasRolesIncluded = userRolesLimit === null && machineToMachineRolesLimit === null ;
54+
4255 const {
4356 control,
4457 handleSubmit,
@@ -71,6 +84,8 @@ function CreateRoleForm({ onClose }: Props) {
7184 < ModalLayout
7285 title = "roles.create_role_title"
7386 subtitle = "roles.create_role_description"
87+ // TODO: remove the dev feature when the new paywall logic is ready;
88+ hasAddOnTag = { isDevFeaturesEnabled && isPaidTenant && ! hasRolesIncluded }
7489 learnMoreLink = { {
7590 href : 'https://docs.logto.io/docs/recipes/rbac/manage-permissions-and-roles#manage-roles' ,
7691 targetBlank : 'noopener' ,
0 commit comments