-
-
Notifications
You must be signed in to change notification settings - Fork 438
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(console,core,phrases): add quota guard for cloud collaboration i…
…n console
- Loading branch information
1 parent
3160b40
commit febb18f
Showing
75 changed files
with
736 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,6 @@ | |
"access": "public" | ||
}, | ||
"devDependencies": { | ||
"@logto/cloud": "0.2.5-1807f9c" | ||
"@logto/cloud": "0.2.5-ab8a489" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...console/src/pages/TenantSettings/TenantMembers/InviteMemberModal/Footer/index.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@use '@/scss/underscore' as _; | ||
|
||
.container { | ||
display: flex; | ||
align-items: center; | ||
gap: _.unit(6); | ||
padding: _.unit(6); | ||
background-color: var(--color-info-container); | ||
margin: 0 _.unit(-6) _.unit(-6); | ||
|
||
.description { | ||
flex: 1; | ||
flex-shrink: 0; | ||
font: var(--font-body-2); | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
packages/console/src/pages/TenantSettings/TenantMembers/InviteMemberModal/Footer/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { ReservedPlanId } from '@logto/schemas'; | ||
import { useContext } from 'react'; | ||
import { Trans, useTranslation } from 'react-i18next'; | ||
|
||
import ContactUsPhraseLink from '@/components/ContactUsPhraseLink'; | ||
import QuotaGuardFooter from '@/components/QuotaGuardFooter'; | ||
import { contactEmailLink } from '@/consts'; | ||
import { SubscriptionDataContext } from '@/contexts/SubscriptionDataProvider'; | ||
import Button, { LinkButton } from '@/ds-components/Button'; | ||
|
||
import useTenantMembersUsage from '../../hooks'; | ||
|
||
import * as styles from './index.module.scss'; | ||
|
||
type Props = { | ||
newInvitationCount?: number; | ||
isLoading: boolean; | ||
onSubmit: () => void; | ||
}; | ||
|
||
function Footer({ newInvitationCount = 0, isLoading, onSubmit }: Props) { | ||
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console.upsell.paywall' }); | ||
|
||
const { currentPlan } = useContext(SubscriptionDataContext); | ||
const { id: planId, quota } = currentPlan; | ||
|
||
const { hasTenantMembersReachedLimit, limit, usage } = useTenantMembersUsage(); | ||
|
||
if (planId === ReservedPlanId.Free && hasTenantMembersReachedLimit) { | ||
return ( | ||
<QuotaGuardFooter> | ||
<Trans | ||
components={{ | ||
a: <ContactUsPhraseLink />, | ||
}} | ||
> | ||
{t('tenant_members')} | ||
</Trans> | ||
</QuotaGuardFooter> | ||
); | ||
} | ||
|
||
if ( | ||
planId === ReservedPlanId.Development && | ||
(hasTenantMembersReachedLimit || usage + newInvitationCount > limit) | ||
) { | ||
// Display a custom "Contact us" footer instead of asking for upgrade | ||
return ( | ||
<div className={styles.container}> | ||
<div className={styles.description}> | ||
{t('tenant_members_dev_plan', { limit: quota.tenantMembersLimit })} | ||
</div> | ||
<LinkButton | ||
size="large" | ||
type="primary" | ||
title="general.contact_us_action" | ||
href={contactEmailLink} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<Button | ||
size="large" | ||
type="primary" | ||
title="tenant_members.invite_members" | ||
isLoading={isLoading} | ||
onClick={onSubmit} | ||
/> | ||
); | ||
} | ||
|
||
export default Footer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.