-
-
Notifications
You must be signed in to change notification settings - Fork 466
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(console): add token usage exceed notification (#6907)
add token usage exceed notification for dev tenants
- Loading branch information
Showing
4 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
packages/console/src/pages/TenantSettings/DevTenantNotification/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,40 @@ | ||
/** | ||
* @file Since dev tenant does not have the subscription and billing history tabs, | ||
* we use this component to render the usage notification for dev tenants. | ||
*/ | ||
|
||
import { useContext } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { TenantsContext } from '@/contexts/TenantsProvider'; | ||
import InlineNotification from '@/ds-components/InlineNotification'; | ||
|
||
type Props = { | ||
readonly className?: string; | ||
}; | ||
|
||
function DevTenantNotification({ className }: Props) { | ||
const { currentTenant } = useContext(TenantsContext); | ||
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); | ||
|
||
if (!currentTenant) { | ||
return null; | ||
} | ||
|
||
const { | ||
usage: { tokenUsage }, | ||
quota: { tokenLimit }, | ||
} = currentTenant; | ||
|
||
if (tokenLimit === null || tokenUsage < tokenLimit) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<InlineNotification severity="error" className={className}> | ||
{t('subscription.token_usage_notification.dev_plan_exceeded')} | ||
</InlineNotification> | ||
); | ||
} | ||
|
||
export default DevTenantNotification; |
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 |
---|---|---|
|
@@ -14,3 +14,7 @@ | |
.tabs { | ||
margin: _.unit(4) 0; | ||
} | ||
|
||
.notification { | ||
margin-top: _.unit(4); | ||
} |
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