The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
feat(usage-limit): list workspace limits in a billing tab (#25741)
Etienne66e94cbfc7b7
diff --git a/packages/twenty-front/src/generated-metadata/graphql.ts b/packages/twenty-front/src/generated-metadata/graphql.tsindex 2d468badd5a..9420a57f7db 100644--- a/packages/twenty-front/src/generated-metadata/graphql.ts+++ b/packages/twenty-front/src/generated-metadata/graphql.ts@@ -9163,6 +9163,11 @@ export type ListPlansQueryVariables = Exact<{ [key: string]: never; }>;export type ListPlansQuery = { __typename?: 'Query', listPlans: Array<{ __typename?: 'BillingPlan', planKey: BillingPlanKey, baseProducts: Array<{ __typename?: 'BillingLicensedProduct', name: string, description: string, images?: Array<string> | null, prices?: Array<{ __typename?: 'BillingPriceLicensed', stripePriceId: string, unitAmount: number, recurringInterval: SubscriptionInterval, priceUsageType: BillingUsageType, creditAmount?: number | null, isSellable: boolean }> | null, metadata: { __typename?: 'BillingProductMetadata', productKey: BillingProductKey, planKey: BillingPlanKey, priceUsageBased: BillingUsageType, isLegacy?: string | null } }>, resourceCreditProducts: Array<{ __typename?: 'BillingLicensedProduct', name: string, description: string, images?: Array<string> | null, prices?: Array<{ __typename?: 'BillingPriceLicensed', stripePriceId: string, unitAmount: number, recurringInterval: SubscriptionInterval, priceUsageType: BillingUsageType, creditAmount?: number | null, isSellable: boolean }> | null, metadata: { __typename?: 'BillingProductMetadata', productKey: BillingProductKey, planKey: BillingPlanKey, priceUsageBased: BillingUsageType, isLegacy?: string | null } }>, meteredProducts: Array<{ __typename?: 'BillingMeteredProduct', name: string, description: string, images?: Array<string> | null, prices?: Array<{ __typename?: 'BillingPriceMetered', priceUsageType: BillingUsageType, recurringInterval: SubscriptionInterval, stripePriceId: string, tiers: Array<{ __typename?: 'BillingPriceTier', flatAmount?: number | null, unitAmount?: number | null, upTo?: number | null }> }> | null, metadata: { __typename?: 'BillingProductMetadata', productKey: BillingProductKey, planKey: BillingPlanKey, priceUsageBased: BillingUsageType, isLegacy?: string | null } }> }> };+export type UsageQuotasWithConsumptionQueryVariables = Exact<{ [key: string]: never; }>;+++export type UsageQuotasWithConsumptionQuery = { __typename?: 'Query', usageQuotasWithConsumption: Array<{ __typename?: 'UsageQuotaWithConsumption', id: string, resourceType: UsageResourceType, operationType: UsageOperationType, spenderType: string, spenderId?: string | null, spenderLabel?: string | null, periodUnit: string, meter: string, limitValue: any, isEnforced: boolean, consumedValue?: any | null, remainingValue?: any | null, periodStart?: string | null, periodEnd?: string | null }> };+export type ApiKeyFragmentFragment = { __typename?: 'ApiKey', id: string, name: string, expiresAt: string, revokedAt?: string | null, role: { __typename?: 'Role', id: string, label: string, icon?: string | null } };export type WebhookFragmentFragment = { __typename?: 'Webhook', id: string, targetUrl: string, operations: Array<string>, description?: string | null, secret: string };@@ -10141,6 +10146,7 @@ export const SwitchSubscriptionIntervalDocument = {"kind":"Document","definitionexport const BillingPortalSessionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"BillingPortalSession"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"returnUrlPath"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"String"}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"forPaymentMethodUpdate"}},"type":{"kind":"NamedType","name":{"kind":"Name","value":"Boolean"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"billingPortalSession"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"returnUrlPath"},"value":{"kind":"Variable","name":{"kind":"Name","value":"returnUrlPath"}}},{"kind":"Argument","name":{"kind":"Name","value":"forPaymentMethodUpdate"},"value":{"kind":"Variable","name":{"kind":"Name","value":"forPaymentMethodUpdate"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"url"}}]}}]}}]} as unknown as DocumentNode<BillingPortalSessionQuery, BillingPortalSessionQueryVariables>;export const GetResourceCreditUsageDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"GetResourceCreditUsage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"getResourceCreditUsage"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"productKey"}},{"kind":"Field","name":{"kind":"Name","value":"usedCredits"}},{"kind":"Field","name":{"kind":"Name","value":"grantedCredits"}},{"kind":"Field","name":{"kind":"Name","value":"rolloverCredits"}},{"kind":"Field","name":{"kind":"Name","value":"totalGrantedCredits"}},{"kind":"Field","name":{"kind":"Name","value":"unitPriceCents"}}]}}]}}]} as unknown as DocumentNode<GetResourceCreditUsageQuery, GetResourceCreditUsageQueryVariables>;export const ListPlansDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"listPlans"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"listPlans"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"planKey"}},{"kind":"Field","name":{"kind":"Name","value":"baseProducts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"images"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"productKey"}},{"kind":"Field","name":{"kind":"Name","value":"planKey"}},{"kind":"Field","name":{"kind":"Name","value":"priceUsageBased"}},{"kind":"Field","name":{"kind":"Name","value":"isLegacy"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingLicensedProduct"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"prices"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"BillingPriceLicensedFragment"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"resourceCreditProducts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"images"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"productKey"}},{"kind":"Field","name":{"kind":"Name","value":"planKey"}},{"kind":"Field","name":{"kind":"Name","value":"priceUsageBased"}},{"kind":"Field","name":{"kind":"Name","value":"isLegacy"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingLicensedProduct"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"prices"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"BillingPriceLicensedFragment"}}]}}]}}]}},{"kind":"Field","name":{"kind":"Name","value":"meteredProducts"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"images"}},{"kind":"Field","name":{"kind":"Name","value":"metadata"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"productKey"}},{"kind":"Field","name":{"kind":"Name","value":"planKey"}},{"kind":"Field","name":{"kind":"Name","value":"priceUsageBased"}},{"kind":"Field","name":{"kind":"Name","value":"isLegacy"}}]}},{"kind":"InlineFragment","typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingMeteredProduct"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"prices"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"BillingPriceMeteredFragment"}}]}}]}}]}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"BillingPriceLicensedFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingPriceLicensed"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"stripePriceId"}},{"kind":"Field","name":{"kind":"Name","value":"unitAmount"}},{"kind":"Field","name":{"kind":"Name","value":"recurringInterval"}},{"kind":"Field","name":{"kind":"Name","value":"priceUsageType"}},{"kind":"Field","name":{"kind":"Name","value":"creditAmount"}},{"kind":"Field","name":{"kind":"Name","value":"isSellable"}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"BillingPriceMeteredFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"BillingPriceMetered"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"priceUsageType"}},{"kind":"Field","name":{"kind":"Name","value":"recurringInterval"}},{"kind":"Field","name":{"kind":"Name","value":"stripePriceId"}},{"kind":"Field","name":{"kind":"Name","value":"tiers"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"flatAmount"}},{"kind":"Field","name":{"kind":"Name","value":"unitAmount"}},{"kind":"Field","name":{"kind":"Name","value":"upTo"}}]}}]}}]} as unknown as DocumentNode<ListPlansQuery, ListPlansQueryVariables>;+export const UsageQuotasWithConsumptionDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","name":{"kind":"Name","value":"UsageQuotasWithConsumption"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"usageQuotasWithConsumption"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"resourceType"}},{"kind":"Field","name":{"kind":"Name","value":"operationType"}},{"kind":"Field","name":{"kind":"Name","value":"spenderType"}},{"kind":"Field","name":{"kind":"Name","value":"spenderId"}},{"kind":"Field","name":{"kind":"Name","value":"spenderLabel"}},{"kind":"Field","name":{"kind":"Name","value":"periodUnit"}},{"kind":"Field","name":{"kind":"Name","value":"meter"}},{"kind":"Field","name":{"kind":"Name","value":"limitValue"}},{"kind":"Field","name":{"kind":"Name","value":"isEnforced"}},{"kind":"Field","name":{"kind":"Name","value":"consumedValue"}},{"kind":"Field","name":{"kind":"Name","value":"remainingValue"}},{"kind":"Field","name":{"kind":"Name","value":"periodStart"}},{"kind":"Field","name":{"kind":"Name","value":"periodEnd"}}]}}]}}]} as unknown as DocumentNode<UsageQuotasWithConsumptionQuery, UsageQuotasWithConsumptionQueryVariables>;export const AssignRoleToApiKeyDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"AssignRoleToApiKey"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"apiKeyId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}},{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"roleId"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"UUID"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"assignRoleToApiKey"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"apiKeyId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"apiKeyId"}}},{"kind":"Argument","name":{"kind":"Name","value":"roleId"},"value":{"kind":"Variable","name":{"kind":"Name","value":"roleId"}}}]}]}}]} as unknown as DocumentNode<AssignRoleToApiKeyMutation, AssignRoleToApiKeyMutationVariables>;export const CreateApiKeyDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateApiKey"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreateApiKeyInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createApiKey"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"ApiKeyFragment"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"ApiKeyFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"ApiKey"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"name"}},{"kind":"Field","name":{"kind":"Name","value":"expiresAt"}},{"kind":"Field","name":{"kind":"Name","value":"revokedAt"}},{"kind":"Field","name":{"kind":"Name","value":"role"},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"label"}},{"kind":"Field","name":{"kind":"Name","value":"icon"}}]}}]}}]} as unknown as DocumentNode<CreateApiKeyMutation, CreateApiKeyMutationVariables>;export const CreateWebhookDocument = {"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"mutation","name":{"kind":"Name","value":"CreateWebhook"},"variableDefinitions":[{"kind":"VariableDefinition","variable":{"kind":"Variable","name":{"kind":"Name","value":"input"}},"type":{"kind":"NonNullType","type":{"kind":"NamedType","name":{"kind":"Name","value":"CreateWebhookInput"}}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"createWebhook"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"input"},"value":{"kind":"Variable","name":{"kind":"Name","value":"input"}}}],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"FragmentSpread","name":{"kind":"Name","value":"WebhookFragment"}}]}}]}},{"kind":"FragmentDefinition","name":{"kind":"Name","value":"WebhookFragment"},"typeCondition":{"kind":"NamedType","name":{"kind":"Name","value":"Webhook"}},"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"id"}},{"kind":"Field","name":{"kind":"Name","value":"targetUrl"}},{"kind":"Field","name":{"kind":"Name","value":"operations"}},{"kind":"Field","name":{"kind":"Name","value":"description"}},{"kind":"Field","name":{"kind":"Name","value":"secret"}}]}}]} as unknown as DocumentNode<CreateWebhookMutation, CreateWebhookMutationVariables>;diff --git a/packages/twenty-front/src/modules/ai/components/internal/ContextUsageProgressRing.tsx b/packages/twenty-front/src/modules/ai/components/internal/ContextUsageProgressRing.tsxindex fac99659f02..faa54b53d1b 100644--- a/packages/twenty-front/src/modules/ai/components/internal/ContextUsageProgressRing.tsx+++ b/packages/twenty-front/src/modules/ai/components/internal/ContextUsageProgressRing.tsx@@ -1,66 +1,31 @@-import { styled } from '@linaria/react';import { themeCssVariables } from 'twenty-ui/theme-constants';+import { ProgressRing } from '@/ui/feedback/progress-ring/components/ProgressRing';+type ContextUsageProgressRingProps = {percentage: number;size?: number;strokeWidth?: number;};-const StyledSvg = styled.svg`- transform: rotate(-90deg);-`;--const StyledBackgroundCircle = styled.circle`- fill: none;- stroke: color-mix(- in srgb,- ${themeCssVariables.border.color.strong} 50%,- ${themeCssVariables.background.quaternary} 50%- );-`;--const StyledProgressCircle = styled.circle`- fill: none;- transition: stroke-dashoffset 0.3s ease;-`;-export const ContextUsageProgressRing = ({percentage,- size = 16,- strokeWidth = 2,+ size,+ strokeWidth,}: ContextUsageProgressRingProps) => {- const normalizedPercentage = Math.min(Math.max(percentage, 0), 100);- const radius = (size - strokeWidth) / 2;- const circumference = 2 * Math.PI * radius;- const strokeDashoffset =- circumference - (normalizedPercentage / 100) * circumference;-- const progressColor =- normalizedPercentage > 80+ const barColor =+ percentage > 80? themeCssVariables.color.red- : normalizedPercentage > 60+ : percentage > 60? themeCssVariables.color.orange: themeCssVariables.color.blue;return (- <StyledSvg width={size} height={size}>- <StyledBackgroundCircle- cx={size / 2}- cy={size / 2}- r={radius}- strokeWidth={strokeWidth}- />- <StyledProgressCircle- cx={size / 2}- cy={size / 2}- r={radius}- strokeWidth={strokeWidth}- style={{ stroke: progressColor }}- strokeDasharray={circumference}- strokeDashoffset={strokeDashoffset}- strokeLinecap="round"- />- </StyledSvg>+ <ProgressRing+ value={percentage}+ size={size}+ strokeWidth={strokeWidth}+ barColor={barColor}+ />);};diff --git a/packages/twenty-front/src/modules/app/components/SettingsRoutes.tsx b/packages/twenty-front/src/modules/app/components/SettingsRoutes.tsxindex 5f129f979b2..ff4d0c21f64 100644--- a/packages/twenty-front/src/modules/app/components/SettingsRoutes.tsx+++ b/packages/twenty-front/src/modules/app/components/SettingsRoutes.tsx@@ -458,6 +458,12 @@ const SettingsUsage = lazy(() =>})),);+const SettingsBillingLimits = lazy(() =>+ import('~/pages/settings/billing/SettingsBillingLimits').then((module) => ({+ default: module.SettingsBillingLimits,+ })),+);+const SettingsUsageUserDetail = lazy(() =>import('~/pages/settings/billing/SettingsUsageUserDetail').then((module) => ({default: module.SettingsUsageUserDetail,@@ -787,6 +793,10 @@ const createSettingsRouteElements = ({path={SettingsPath.UsageUserDetail}element={<SettingsUsageUserDetail />}/>+ <Route+ path={SettingsPath.BillingLimits}+ element={<SettingsBillingLimits />}+ /><Routepath={SettingsPath.Subdomain}element={<SettingsSubdomainPage />}diff --git a/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingLimitSpenderCell.tsx b/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingLimitSpenderCell.tsxnew file mode 100644index 00000000000..35043f9dccb--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingLimitSpenderCell.tsx@@ -0,0 +1,107 @@+import { styled } from '@linaria/react';+import { useContext } from 'react';+import { Avatar } from 'twenty-ui/data-display';+import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants';++import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';+import { USAGE_LIMIT_SPENDER_TYPE_ICONS } from '@/settings/billing/constants/UsageLimitSpenderTypeIcons';+import { type UsageLimitRow } from '@/settings/billing/types/UsageLimitRow';+import { isKeyOfRecord } from '@/settings/billing/utils/isKeyOfRecord';+import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';+import { DEFAULT_WORKSPACE_LOGO } from '@/ui/navigation/navigation-drawer/constants/DefaultWorkspaceLogo';+import { getAbsoluteImageUrl } from '~/utils/image/getAbsoluteImageUrl';++const StyledContainer = styled.div`+ align-items: center;+ display: flex;+ gap: ${themeCssVariables.spacing[2]};+ min-width: 0;+`;++const StyledIcon = styled.div`+ color: ${themeCssVariables.font.color.tertiary};+ display: flex;+ flex-shrink: 0;+`;++const StyledName = styled.span`+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+`;++type SettingsBillingLimitSpenderCellProps = {+ row: UsageLimitRow;+};++export const SettingsBillingLimitSpenderCell = ({+ row,+}: SettingsBillingLimitSpenderCellProps) => {+ const { theme } = useContext(ThemeContext);+ const currentWorkspace = useAtomStateValue(currentWorkspaceState);++ const isWorkspaceWide = row.spenderType === 'workspace';+ const name = row.spenderName;++ const SpenderIcon = isKeyOfRecord(+ USAGE_LIMIT_SPENDER_TYPE_ICONS,+ row.spenderType,+ )+ ? USAGE_LIMIT_SPENDER_TYPE_ICONS[row.spenderType]+ : undefined;++ const renderVisual = () => {+ if (isWorkspaceWide) {+ return (+ <Avatar+ placeholder={name}+ avatarUrl={getAbsoluteImageUrl(+ currentWorkspace?.logo ?? DEFAULT_WORKSPACE_LOGO,+ )}+ type="squared"+ size="sm"+ />+ );+ }++ if (row.spenderType === 'userWorkspace') {+ return (+ <Avatar+ placeholder={name}+ avatarUrl={row.spenderAvatarUrl}+ type="rounded"+ size="sm"+ />+ );+ }++ if (row.spenderType === 'application') {+ return (+ <Avatar+ placeholder={name}+ avatarUrl={row.spenderAvatarUrl}+ type="squared"+ size="sm"+ />+ );+ }++ return (+ <StyledIcon>+ {SpenderIcon && (+ <SpenderIcon+ size={theme.icon.size.sm}+ stroke={theme.icon.stroke.sm}+ />+ )}+ </StyledIcon>+ );+ };++ return (+ <StyledContainer>+ {renderVisual()}+ <StyledName>{name}</StyledName>+ </StyledContainer>+ );+};diff --git a/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingLimitsContent.tsx b/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingLimitsContent.tsxnew file mode 100644index 00000000000..5c81e80ce40--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingLimitsContent.tsx@@ -0,0 +1,57 @@+import { useLingui } from '@lingui/react/macro';+import { isDefined } from 'twenty-shared/utils';+import { Section } from 'twenty-ui/layout';+import { H2Title } from 'twenty-ui/typography';++import { SettingsBillingLimitsTable } from '@/settings/billing/components/SettingsBillingLimitsTable';+import { useUsageQuotasWithConsumption } from '@/settings/billing/hooks/useUsageQuotasWithConsumption';+import { hasKnownUsageLimitSpender } from '@/settings/billing/utils/hasKnownUsageLimitSpender';+import { SettingsEmptyPlaceholder } from '@/settings/components/SettingsEmptyPlaceholder';+import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';++export const SettingsBillingLimitsContent = () => {+ const { t } = useLingui();+ const { usageQuotasWithConsumption, loading, error } =+ useUsageQuotasWithConsumption();++ const quotas = usageQuotasWithConsumption.filter(hasKnownUsageLimitSpender);++ if (loading) {+ return null;+ }++ if (isDefined(error)) {+ return (+ <SettingsPageContainer>+ <Section>+ <H2Title+ title={t`Limits`}+ description={t`Limits could not be loaded.`}+ />+ </Section>+ </SettingsPageContainer>+ );+ }++ if (quotas.length === 0) {+ return (+ <SettingsPageContainer>+ <Section>+ <H2Title+ title={t`Limits`}+ description={t`Caps on what your workspace can spend and who they apply to`}+ />+ <SettingsEmptyPlaceholder>+ {t`No limit yet.`}+ </SettingsEmptyPlaceholder>+ </Section>+ </SettingsPageContainer>+ );+ }++ return (+ <SettingsPageContainer>+ <SettingsBillingLimitsTable quotas={quotas} />+ </SettingsPageContainer>+ );+};diff --git a/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingLimitsFilterDropdown.tsx b/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingLimitsFilterDropdown.tsxnew file mode 100644index 00000000000..f40fe565a09--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingLimitsFilterDropdown.tsx@@ -0,0 +1,198 @@+import { useLingui } from '@lingui/react/macro';+import { type ReactNode, useState } from 'react';+import { isDefined } from 'twenty-shared/utils';+import {+ IconChevronLeft,+ IconCoins,+ IconList,+ IconTrash,+ IconUsers,+} from 'twenty-ui/icon';+import { MenuItem, MenuItemSelect } from 'twenty-ui/navigation';++import { USAGE_LIMIT_RESOURCE_TYPE_ICONS } from '@/settings/billing/constants/UsageLimitResourceTypeIcons';+import { USAGE_LIMIT_RESOURCE_TYPE_LABELS } from '@/settings/billing/constants/UsageLimitResourceTypeLabels';+import { USAGE_LIMIT_SPENDER_TYPE_ICONS } from '@/settings/billing/constants/UsageLimitSpenderTypeIcons';+import { USAGE_LIMIT_SPENDER_TYPE_LABELS } from '@/settings/billing/constants/UsageLimitSpenderTypeLabels';+import { getUsageLimitLabel } from '@/settings/billing/utils/getUsageLimitLabel';+import { isKeyOfRecord } from '@/settings/billing/utils/isKeyOfRecord';+import { Dropdown } from '@/ui/layout/dropdown/components/Dropdown';+import { DropdownContent } from '@/ui/layout/dropdown/components/DropdownContent';+import { DropdownMenuHeader } from '@/ui/layout/dropdown/components/DropdownMenuHeader/DropdownMenuHeader';+import { DropdownMenuHeaderLeftComponent } from '@/ui/layout/dropdown/components/DropdownMenuHeader/internal/DropdownMenuHeaderLeftComponent';+import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';+import { DropdownMenuSeparator } from '@/ui/layout/dropdown/components/DropdownMenuSeparator';+import { type UsageResourceType } from '~/generated-metadata/graphql';++const FILTER_DROPDOWN_ID = 'settings-billing-limits-filter';++type FilterContentId = 'usage' | 'spender';++type SettingsBillingLimitsFilterDropdownProps = {+ filterButton: ReactNode;+ resourceTypes: UsageResourceType[];+ spenderTypes: string[];+ selectedResourceType: UsageResourceType | null;+ selectedSpenderType: string | null;+ onSelectResourceType: (resourceType: UsageResourceType | null) => void;+ onSelectSpenderType: (spenderType: string | null) => void;+};++export const SettingsBillingLimitsFilterDropdown = ({+ filterButton,+ resourceTypes,+ spenderTypes,+ selectedResourceType,+ selectedSpenderType,+ onSelectResourceType,+ onSelectSpenderType,+}: SettingsBillingLimitsFilterDropdownProps) => {+ const { t } = useLingui();++ const [contentId, setContentId] = useState<FilterContentId | null>(null);++ const goToMenu = () => setContentId(null);++ const getSpenderTypeLabel = (spenderType: string): string => {+ const spenderLabel = getUsageLimitLabel(+ USAGE_LIMIT_SPENDER_TYPE_LABELS,+ spenderType,+ );++ return isDefined(spenderLabel) ? t(spenderLabel) : spenderType;+ };++ const hasActiveFilters =+ isDefined(selectedResourceType) || isDefined(selectedSpenderType);++ const renderBackHeader = (title: string) => (+ <DropdownMenuHeader+ StartComponent={+ <DropdownMenuHeaderLeftComponent+ onClick={goToMenu}+ Icon={IconChevronLeft}+ />+ }+ >+ {title}+ </DropdownMenuHeader>+ );++ const renderUsageContent = () => (+ <DropdownContent>+ {renderBackHeader(t`Usage`)}+ <DropdownMenuItemsContainer>+ <MenuItemSelect+ LeftIcon={IconList}+ text={t`All`}+ selected={!isDefined(selectedResourceType)}+ onClick={() => onSelectResourceType(null)}+ />+ {resourceTypes.map((resourceType) => (+ <MenuItemSelect+ key={resourceType}+ LeftIcon={USAGE_LIMIT_RESOURCE_TYPE_ICONS[resourceType]}+ text={t(USAGE_LIMIT_RESOURCE_TYPE_LABELS[resourceType])}+ selected={selectedResourceType === resourceType}+ onClick={() => onSelectResourceType(resourceType)}+ />+ ))}+ </DropdownMenuItemsContainer>+ </DropdownContent>+ );++ const renderSpenderContent = () => (+ <DropdownContent>+ {renderBackHeader(t`Spender`)}+ <DropdownMenuItemsContainer>+ <MenuItemSelect+ LeftIcon={IconList}+ text={t`All`}+ selected={!isDefined(selectedSpenderType)}+ onClick={() => onSelectSpenderType(null)}+ />+ {spenderTypes.map((spenderType) => (+ <MenuItemSelect+ key={spenderType}+ LeftIcon={+ isKeyOfRecord(USAGE_LIMIT_SPENDER_TYPE_ICONS, spenderType)+ ? USAGE_LIMIT_SPENDER_TYPE_ICONS[spenderType]+ : undefined+ }+ text={getSpenderTypeLabel(spenderType)}+ selected={selectedSpenderType === spenderType}+ onClick={() => onSelectSpenderType(spenderType)}+ />+ ))}+ </DropdownMenuItemsContainer>+ </DropdownContent>+ );++ const renderMenuContent = () => (+ <DropdownContent>+ <DropdownMenuItemsContainer>+ <MenuItem+ LeftIcon={IconCoins}+ text={t`Usage`}+ contextualText={+ isDefined(selectedResourceType)+ ? t(USAGE_LIMIT_RESOURCE_TYPE_LABELS[selectedResourceType])+ : t`All`+ }+ contextualTextPosition="right"+ hasSubMenu+ onClick={() => setContentId('usage')}+ />+ <MenuItem+ LeftIcon={IconUsers}+ text={t`Spender`}+ contextualText={+ isDefined(selectedSpenderType)+ ? getSpenderTypeLabel(selectedSpenderType)+ : t`All`+ }+ contextualTextPosition="right"+ hasSubMenu+ onClick={() => setContentId('spender')}+ />+ {hasActiveFilters && (+ <>+ <DropdownMenuSeparator />+ <MenuItem+ accent="danger"+ LeftIcon={IconTrash}+ text={t`Clear filters`}+ onClick={() => {+ onSelectResourceType(null);+ onSelectSpenderType(null);+ }}+ />+ </>+ )}+ </DropdownMenuItemsContainer>+ </DropdownContent>+ );++ const renderContent = () => {+ if (contentId === 'usage') {+ return renderUsageContent();+ }++ if (contentId === 'spender') {+ return renderSpenderContent();+ }++ return renderMenuContent();+ };++ return (+ <Dropdown+ dropdownId={FILTER_DROPDOWN_ID}+ dropdownPlacement="bottom-end"+ dropdownOffset={{ x: 0, y: 8 }}+ onClose={goToMenu}+ clickableComponent={filterButton}+ dropdownComponents={renderContent()}+ />+ );+};diff --git a/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingLimitsTable.tsx b/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingLimitsTable.tsxnew file mode 100644index 00000000000..e8eeb1ea55b--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingLimitsTable.tsx@@ -0,0 +1,253 @@+import { styled } from '@linaria/react';+import { useLingui } from '@lingui/react/macro';+import { type ReactNode, useContext, useState } from 'react';+import { isDefined } from 'twenty-shared/utils';+import { SearchInput } from 'twenty-ui/input';+import { AppTooltip, TooltipDelay } from 'twenty-ui/surfaces';+import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants';++import { SettingsBillingLimitSpenderCell } from '@/settings/billing/components/SettingsBillingLimitSpenderCell';+import { SettingsBillingLimitAmount } from '@/settings/billing/components/internal/SettingsBillingLimitAmount';+import { SettingsBillingLimitsFilterDropdown } from '@/settings/billing/components/SettingsBillingLimitsFilterDropdown';+import { useUsageLimitRows } from '@/settings/billing/hooks/useUsageLimitRows';+import { type UsageLimitRow } from '@/settings/billing/types/UsageLimitRow';+import { type UsageQuotaWithConsumption } from '@/settings/billing/types/UsageQuotaWithConsumption';+import { filterUsageLimitRows } from '@/settings/billing/utils/filterUsageLimitRows';+import { getUsageLimitRingColor } from '@/settings/billing/utils/getUsageLimitRingColor';+import { SettingsEmptyPlaceholder } from '@/settings/components/SettingsEmptyPlaceholder';+import { SettingsNameCellSecondaryLabel } from '@/settings/components/SettingsNameCellSecondaryLabel';+import { SettingsTableListSection } from '@/settings/components/SettingsTableListSection';+import { ProgressRing } from '@/ui/feedback/progress-ring/components/ProgressRing';+import { type UsageResourceType } from '~/generated-metadata/graphql';++const GRID_AUTO_COLUMNS = '1.2fr 1fr 120px 96px';++const USED_RING_SIZE = 14;++const StyledCell = styled.div`+ align-items: center;+ display: flex;+ gap: ${themeCssVariables.spacing[2]};+ min-width: 0;+`;++const StyledName = styled.span`+ color: ${themeCssVariables.font.color.primary};+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;+`;++const StyledNameContainer = styled.div`+ align-items: center;+ display: flex;+ flex: 1;+ gap: ${themeCssVariables.spacing[1]};+ min-width: 0;+`;++const StyledNameIcon = styled.div`+ color: ${themeCssVariables.font.color.primary};+ display: flex;+ flex-shrink: 0;+`;++const StyledUsed = styled.div`+ align-items: center;+ display: flex;+ gap: ${themeCssVariables.spacing[2]};+ justify-content: flex-end;+`;++const StyledEmptyValue = styled.span`+ color: ${themeCssVariables.font.color.light};+`;++const StyledToolbar = styled.div`+ padding-bottom: ${themeCssVariables.spacing[2]};+`;++const StyledTooltipRows = styled.div`+ display: flex;+ flex-direction: column;+ gap: ${themeCssVariables.spacing[1]};+`;++const StyledTooltipRow = styled.div`+ align-items: center;+ display: flex;+ gap: ${themeCssVariables.spacing[1]};+`;++const NameCell = ({ item }: { item: UsageLimitRow }) => {+ const { t } = useLingui();+ const { theme } = useContext(ThemeContext);++ const deactivatedAnchorId = `usage-limit-deactivated-${item.id}`;++ return (+ <StyledCell>+ <StyledNameIcon>+ <item.NameIcon+ size={theme.icon.size.md}+ stroke={theme.icon.stroke.sm}+ />+ </StyledNameIcon>+ <StyledNameContainer>+ <StyledName>{item.name}</StyledName>+ {!item.isEnforced && (+ <>+ <SettingsNameCellSecondaryLabel id={deactivatedAnchorId}>+ {t`Deactivated`}+ </SettingsNameCellSecondaryLabel>+ <AppTooltip+ anchorSelect={`#${deactivatedAnchorId}`}+ title={t`Limits on members, API keys and apps require the Organization plan.`}+ place="top"+ delay={TooltipDelay.shortDelay}+ positionStrategy="fixed"+ />+ </>+ )}+ </StyledNameContainer>+ </StyledCell>+ );+};++const UsedCell = ({ item }: { item: UsageLimitRow }) => {+ const { t } = useLingui();++ const anchorId = `usage-limit-ring-${item.id}`;++ return (+ <StyledUsed id={anchorId}>+ {isDefined(item.consumedPercentage) ? (+ <>+ <span>{item.consumedPercentage}%</span>+ <ProgressRing+ size={USED_RING_SIZE}+ value={item.consumedPercentage}+ barColor={getUsageLimitRingColor({+ consumedPercentage: item.consumedPercentage,+ isExhausted: item.isExhausted,+ })}+ />+ </>+ ) : (+ <StyledEmptyValue>—</StyledEmptyValue>+ )}+ <AppTooltip+ anchorSelect={`#${anchorId}`}+ place="top"+ delay={TooltipDelay.shortDelay}+ positionStrategy="fixed"+ >+ <StyledTooltipRows>+ {isDefined(item.consumedText) && (+ <StyledTooltipRow>+ {t`Used`}+ <SettingsBillingLimitAmount+ text={item.consumedText}+ isCreditsMeter={item.isCreditsMeter}+ />+ </StyledTooltipRow>+ )}+ <StyledTooltipRow>+ {t`Limit`}+ <SettingsBillingLimitAmount+ text={item.limitText}+ isCreditsMeter={item.isCreditsMeter}+ />+ </StyledTooltipRow>+ </StyledTooltipRows>+ </AppTooltip>+ </StyledUsed>+ );+};++type SettingsBillingLimitsTableProps = {+ quotas: UsageQuotaWithConsumption[];+};++export const SettingsBillingLimitsTable = ({+ quotas,+}: SettingsBillingLimitsTableProps) => {+ const { t } = useLingui();++ const [searchText, setSearchText] = useState('');+ const [resourceType, setResourceType] = useState<UsageResourceType | null>(+ null,+ );+ const [spenderType, setSpenderType] = useState<string | null>(null);++ const rows = useUsageLimitRows(quotas);++ const resourceTypes = [+ ...new Set(+ rows+ .map((row) => row.resourceType)+ .filter((candidate): candidate is UsageResourceType =>+ isDefined(candidate),+ ),+ ),+ ];++ const spenderTypes = [...new Set(rows.map((row) => row.spenderType))];++ const filteredRows = filterUsageLimitRows({+ rows,+ searchText,+ resourceType,+ spenderType,+ });++ return (+ <>+ <SettingsTableListSection<UsageLimitRow>+ title={t`Limits`}+ description={t`Caps on what your workspace can spend and who they apply to`}+ toolbar={+ <StyledToolbar>+ <SearchInput+ placeholder={t`Search a limit`}+ value={searchText}+ onChange={setSearchText}+ filterButtonAriaLabel={t`Filter limits`}+ filterDropdown={(filterButton: ReactNode) => (+ <SettingsBillingLimitsFilterDropdown+ filterButton={filterButton}+ resourceTypes={resourceTypes}+ spenderTypes={spenderTypes}+ selectedResourceType={resourceType}+ selectedSpenderType={spenderType}+ onSelectResourceType={setResourceType}+ onSelectSpenderType={setSpenderType}+ />+ )}+ />+ </StyledToolbar>+ }+ items={filteredRows}+ columns={[+ { label: t`Usage`, Cell: NameCell },+ {+ label: t`Applies to`,+ Cell: ({ item }) => <SettingsBillingLimitSpenderCell row={item} />,+ },+ {+ label: t`Period`,+ align: 'right',+ Cell: ({ item }) => <>{item.periodName}</>,+ },+ { label: t`Used`, align: 'right', Cell: UsedCell },+ ]}+ gridAutoColumns={GRID_AUTO_COLUMNS}+ />+ {filteredRows.length === 0 && (+ <SettingsEmptyPlaceholder>+ {t`No limit matches your search.`}+ </SettingsEmptyPlaceholder>+ )}+ </>+ );+};diff --git a/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingPageLayout.tsx b/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingPageLayout.tsxindex bbb2a40b54e..03f303cf004 100644--- a/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingPageLayout.tsx+++ b/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingPageLayout.tsx@@ -16,8 +16,10 @@ import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateexport const SettingsBillingPageLayout = ({children,+ actionButton,}: {children: ReactNode;+ actionButton?: ReactNode;}) => {const { t } = useLingui();@@ -50,6 +52,7 @@ export const SettingsBillingPageLayout = ({{ children: <Trans>Billing</Trans> },]}secondaryBar={<SettingsBillingTabBar />}+ actionButton={actionButton}>{!isDefined(currentWorkspace) ||!isBillingLoaded ||diff --git a/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingTabBar.tsx b/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingTabBar.tsxindex b24ded77552..e5cc5f5babc 100644--- a/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingTabBar.tsx+++ b/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingTabBar.tsx@@ -7,7 +7,7 @@ import { matchPath, useLocation } from 'react-router-dom';import { SettingsPath } from 'twenty-shared/types';import { getSettingsPath } from 'twenty-shared/utils';import { TabButton } from 'twenty-ui/input';-import { IconColorSwatch, IconCreditCard } from 'twenty-ui/icon';+import { IconColorSwatch, IconCreditCard, IconGauge } from 'twenty-ui/icon';const StyledTabBar = styled.div`display: flex;@@ -30,6 +30,7 @@ export const SettingsBillingTabBar = () => {const billingPath = getSettingsPath(SettingsPath.Billing);const plansPath = getSettingsPath(SettingsPath.BillingPlans);+ const limitsPath = getSettingsPath(SettingsPath.BillingLimits);const isTabActive = (path: string) =>matchPath({ path, end: true }, location.pathname) !== null;@@ -50,6 +51,13 @@ export const SettingsBillingTabBar = () => {active={isTabActive(plansPath)}to={plansPath}/>+ <TabButton+ id="limits"+ title={t`Limits`}+ LeftIcon={IconGauge}+ active={isTabActive(limitsPath)}+ to={limitsPath}+ /></StyledTabBar>);};diff --git a/packages/twenty-front/src/modules/settings/billing/components/__stories__/SettingsBillingLimitsTable.stories.tsx b/packages/twenty-front/src/modules/settings/billing/components/__stories__/SettingsBillingLimitsTable.stories.tsxnew file mode 100644index 00000000000..25f4b446d3b--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/components/__stories__/SettingsBillingLimitsTable.stories.tsx@@ -0,0 +1,122 @@+import { type Meta, type StoryObj } from '@storybook/react-vite';+import { expect, userEvent, waitFor, within } from 'storybook/test';+import { ComponentDecorator, RouterDecorator } from 'twenty-ui/testing';++import { SettingsBillingLimitsTable } from '@/settings/billing/components/SettingsBillingLimitsTable';+import { type UsageQuotaWithConsumption } from '@/settings/billing/types/UsageQuotaWithConsumption';+import {+ UsageOperationType,+ UsageResourceType,+} from '~/generated-metadata/graphql';++const buildQuota = (+ overrides: Partial<UsageQuotaWithConsumption>,+): UsageQuotaWithConsumption => ({+ __typename: 'UsageQuotaWithConsumption',+ id: 'limit-1',+ resourceType: UsageResourceType.AI,+ operationType: UsageOperationType.AI_CHAT_TOKEN,+ spenderType: 'workspace',+ spenderId: null,+ spenderLabel: null,+ periodUnit: 'month',+ meter: 'creditsUsedMicro',+ limitValue: 100_000_000,+ isEnforced: true,+ consumedValue: 23_860_000,+ remainingValue: 76_140_000,+ periodStart: '2026-09-01T00:00:00.000Z',+ periodEnd: '2026-10-01T00:00:00.000Z',+ ...overrides,+});++const ALL_OPERATIONS_QUOTA = buildQuota({+ id: 'limit-all-operations',+ operationType: UsageOperationType.ALL,+ periodUnit: 'allowancePeriod',+});++const CUSTOM_USER_QUOTA = buildQuota({+ spenderType: 'userWorkspace',+ spenderId: 'a1b2c3d4-0000-0000-0000-000000000000',+ spenderLabel: 'Tim Apple',+ isEnforced: false,+});++const API_KEY_QUOTA = buildQuota({+ id: 'limit-2',+ resourceType: UsageResourceType.API,+ operationType: UsageOperationType.API_REQUEST,+ spenderType: 'apiKey',+ spenderId: 'b1b2c3d4-0000-0000-0000-000000000000',+ spenderLabel: 'Production key',+ periodUnit: 'day',+ meter: 'quantity',+ limitValue: 10_000,+ consumedValue: 9_800,+ remainingValue: 200,+});++const meta: Meta<typeof SettingsBillingLimitsTable> = {+ title: 'Modules/Settings/Billing/SettingsBillingLimitsTable',+ component: SettingsBillingLimitsTable,+ decorators: [ComponentDecorator, RouterDecorator],+ args: { quotas: [ALL_OPERATIONS_QUOTA, CUSTOM_USER_QUOTA, API_KEY_QUOTA] },+};++export default meta;+type Story = StoryObj<typeof SettingsBillingLimitsTable>;++export const Default: Story = {+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);++ await userEvent.hover(await canvas.findByText('Deactivated'));++ const tooltip = await within(canvasElement.ownerDocument.body).findByRole(+ 'tooltip',+ {},+ { timeout: 2000 },+ );++ await waitFor(() =>+ expect(tooltip).toHaveTextContent('require the Organization plan'),+ );+ },+};++export const Exhausted: Story = {+ args: {+ quotas: [buildQuota({ consumedValue: 100_000_000, remainingValue: 0 })],+ },+ play: async ({ canvasElement }) => {+ expect(await within(canvasElement).findByText('100%')).toBeVisible();+ },+};++export const WithoutCountedUsage: Story = {+ args: {+ quotas: [+ {+ ...CUSTOM_USER_QUOTA,+ consumedValue: null,+ remainingValue: null,+ periodStart: null,+ periodEnd: null,+ },+ ],+ },+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);++ await userEvent.hover(await canvas.findByText('—'));++ const tooltip = await within(canvasElement.ownerDocument.body).findByRole(+ 'tooltip',+ {},+ { timeout: 2000 },+ );++ await waitFor(() => expect(tooltip).toHaveTextContent('Limit'));+ },+};diff --git a/packages/twenty-front/src/modules/settings/billing/components/internal/SettingsBillingLimitAmount.tsx b/packages/twenty-front/src/modules/settings/billing/components/internal/SettingsBillingLimitAmount.tsxnew file mode 100644index 00000000000..6095ed4d90d--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/components/internal/SettingsBillingLimitAmount.tsx@@ -0,0 +1,27 @@+import { styled } from '@linaria/react';+import { IconCoins } from 'twenty-ui/icon';+import { themeCssVariables } from 'twenty-ui/theme-constants';++const CREDITS_UNIT_ICON_SIZE = 12;++const StyledAmount = styled.span`+ align-items: center;+ display: inline-flex;+ gap: ${themeCssVariables.spacing[1]};+ white-space: nowrap;+`;++type SettingsBillingLimitAmountProps = {+ text: string;+ isCreditsMeter: boolean;+};++export const SettingsBillingLimitAmount = ({+ text,+ isCreditsMeter,+}: SettingsBillingLimitAmountProps) => (+ <StyledAmount>+ {text}+ {isCreditsMeter && <IconCoins size={CREDITS_UNIT_ICON_SIZE} />}+ </StyledAmount>+);diff --git a/packages/twenty-front/src/modules/settings/billing/constants/AvatarSpenderTypes.ts b/packages/twenty-front/src/modules/settings/billing/constants/AvatarSpenderTypes.tsnew file mode 100644index 00000000000..f82478d5f3e--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/constants/AvatarSpenderTypes.ts@@ -0,0 +1,6 @@+import { type UsageLimitSpenderType } from '@/settings/billing/types/UsageLimitSpenderType';++export const AVATAR_SPENDER_TYPES: UsageLimitSpenderType[] = [+ 'userWorkspace',+ 'application',+];diff --git a/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitOperationTypeIcons.ts b/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitOperationTypeIcons.tsnew file mode 100644index 00000000000..f0cbc676551--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitOperationTypeIcons.ts@@ -0,0 +1,33 @@+import {+ IconApi,+ IconCode,+ type IconComponent,+ IconMail,+ IconMessageCircle,+ IconPhone,+ IconPlayerPlay,+ IconRepeat,+ IconRobot,+ IconSearch,+ IconSettingsAutomation,+ IconWebhook,+} from 'twenty-ui/icon';++import { UsageOperationType } from '~/generated-metadata/graphql';++export const USAGE_LIMIT_OPERATION_TYPE_ICONS: Record<+ UsageOperationType,+ IconComponent+> = {+ [UsageOperationType.ALL]: IconPlayerPlay,+ [UsageOperationType.AI_CHAT_TOKEN]: IconMessageCircle,+ [UsageOperationType.AI_WORKFLOW_TOKEN]: IconRobot,+ [UsageOperationType.WORKFLOW_EXECUTION]: IconSettingsAutomation,+ [UsageOperationType.CODE_EXECUTION]: IconCode,+ [UsageOperationType.WEB_SEARCH]: IconSearch,+ [UsageOperationType.CALL_RECORDING]: IconPhone,+ [UsageOperationType.EMAIL_SEND]: IconMail,+ [UsageOperationType.API_REQUEST]: IconApi,+ [UsageOperationType.WEBHOOK_CALL]: IconWebhook,+ [UsageOperationType.SUBSCRIPTION]: IconRepeat,+};diff --git a/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitPeriodNameLabels.ts b/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitPeriodNameLabels.tsnew file mode 100644index 00000000000..eb6251bfffc--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitPeriodNameLabels.ts@@ -0,0 +1,14 @@+import { type MessageDescriptor } from '@lingui/core';+import { msg } from '@lingui/core/macro';++import { type UsageLimitPeriodUnit } from '@/settings/billing/types/UsageLimitPeriodUnit';++export const USAGE_LIMIT_PERIOD_NAME_LABELS: Record<+ UsageLimitPeriodUnit,+ MessageDescriptor+> = {+ day: msg`Daily`,+ week: msg`Weekly`,+ month: msg`Monthly`,+ allowancePeriod: msg`Billing period`,+};diff --git a/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitPeriodUnits.ts b/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitPeriodUnits.tsnew file mode 100644index 00000000000..29d455e0017--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitPeriodUnits.ts@@ -0,0 +1,6 @@+export const USAGE_LIMIT_PERIOD_UNITS = [+ 'day',+ 'week',+ 'month',+ 'allowancePeriod',+] as const;diff --git a/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitQuantityUnitLabels.ts b/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitQuantityUnitLabels.tsnew file mode 100644index 00000000000..a10841b8ab6--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitQuantityUnitLabels.ts@@ -0,0 +1,12 @@+import { type MessageDescriptor } from '@lingui/core';+import { msg } from '@lingui/core/macro';++import { UsageOperationType } from '~/generated-metadata/graphql';++export const USAGE_LIMIT_QUANTITY_UNIT_LABELS: Partial<+ Record<UsageOperationType, MessageDescriptor>+> = {+ [UsageOperationType.WEB_SEARCH]: msg`searches`,+ [UsageOperationType.WORKFLOW_EXECUTION]: msg`runs`,+ [UsageOperationType.CODE_EXECUTION]: msg`runs`,+};diff --git a/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitResourceTypeIcons.ts b/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitResourceTypeIcons.tsnew file mode 100644index 00000000000..77420460f2d--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitResourceTypeIcons.ts@@ -0,0 +1,26 @@+import {+ IconApi,+ IconApps,+ IconFiles,+ type IconComponent,+ IconMail,+ IconSettingsAutomation,+ IconSparkles,+ IconWebhook,+} from 'twenty-ui/icon';++import { UsageResourceType } from '~/generated-metadata/graphql';++export const USAGE_LIMIT_RESOURCE_TYPE_ICONS: Record<+ UsageResourceType,+ IconComponent+> = {+ [UsageResourceType.AI]: IconSparkles,+ [UsageResourceType.API]: IconApi,+ [UsageResourceType.APP]: IconApps,+ [UsageResourceType.EMAIL]: IconMail,+ [UsageResourceType.LOGIC_FUNCTION]: IconSettingsAutomation,+ [UsageResourceType.STORAGE]: IconFiles,+ [UsageResourceType.WEBHOOK]: IconWebhook,+ [UsageResourceType.WORKFLOW]: IconSettingsAutomation,+};diff --git a/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitResourceTypeLabels.ts b/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitResourceTypeLabels.tsnew file mode 100644index 00000000000..b613740ce5a--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitResourceTypeLabels.ts@@ -0,0 +1,18 @@+import { type MessageDescriptor } from '@lingui/core';+import { msg } from '@lingui/core/macro';++import { UsageResourceType } from '~/generated-metadata/graphql';++export const USAGE_LIMIT_RESOURCE_TYPE_LABELS: Record<+ UsageResourceType,+ MessageDescriptor+> = {+ [UsageResourceType.AI]: msg`AI`,+ [UsageResourceType.API]: msg`API`,+ [UsageResourceType.APP]: msg`Apps`,+ [UsageResourceType.EMAIL]: msg`Email`,+ [UsageResourceType.LOGIC_FUNCTION]: msg`Logic functions`,+ [UsageResourceType.STORAGE]: msg`Storage`,+ [UsageResourceType.WEBHOOK]: msg`Webhooks`,+ [UsageResourceType.WORKFLOW]: msg`Workflows`,+};diff --git a/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitSpenderTypeIcons.ts b/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitSpenderTypeIcons.tsnew file mode 100644index 00000000000..73cc03313cf--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitSpenderTypeIcons.ts@@ -0,0 +1,25 @@+import {+ IconApps,+ IconBrandTypescript,+ type IconComponent,+ IconKey,+ IconLego,+ IconSettings,+ IconSettingsAutomation,+ IconUsers,+} from 'twenty-ui/icon';++import { type UsageLimitSpenderType } from '@/settings/billing/types/UsageLimitSpenderType';++export const USAGE_LIMIT_SPENDER_TYPE_ICONS: Record<+ UsageLimitSpenderType,+ IconComponent+> = {+ workspace: IconSettings,+ userWorkspace: IconUsers,+ apiKey: IconKey,+ application: IconApps,+ agent: IconLego,+ workflow: IconSettingsAutomation,+ logicFunction: IconBrandTypescript,+};diff --git a/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitSpenderTypeLabels.ts b/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitSpenderTypeLabels.tsnew file mode 100644index 00000000000..b3000dabaf7--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitSpenderTypeLabels.ts@@ -0,0 +1,17 @@+import { type MessageDescriptor } from '@lingui/core';+import { msg } from '@lingui/core/macro';++import { type UsageLimitSpenderType } from '@/settings/billing/types/UsageLimitSpenderType';++export const USAGE_LIMIT_SPENDER_TYPE_LABELS: Record<+ UsageLimitSpenderType,+ MessageDescriptor+> = {+ workspace: msg`Workspace`,+ userWorkspace: msg`User`,+ apiKey: msg`API key`,+ application: msg`Application`,+ agent: msg`Agent`,+ workflow: msg`Workflow`,+ logicFunction: msg`Logic function`,+};diff --git a/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitSpenderTypePoolLabels.ts b/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitSpenderTypePoolLabels.tsnew file mode 100644index 00000000000..32a86ef6abb--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/constants/UsageLimitSpenderTypePoolLabels.ts@@ -0,0 +1,17 @@+import { type MessageDescriptor } from '@lingui/core';+import { msg } from '@lingui/core/macro';++import { type UsageLimitSpenderType } from '@/settings/billing/types/UsageLimitSpenderType';++export const USAGE_LIMIT_SPENDER_TYPE_POOL_LABELS: Record<+ UsageLimitSpenderType,+ MessageDescriptor+> = {+ workspace: msg`The whole workspace`,+ userWorkspace: msg`All users`,+ apiKey: msg`All API keys`,+ application: msg`All applications`,+ agent: msg`All agents`,+ workflow: msg`All workflows`,+ logicFunction: msg`All logic functions`,+};diff --git a/packages/twenty-front/src/modules/settings/billing/graphql/queries/usageQuotasWithConsumption.ts b/packages/twenty-front/src/modules/settings/billing/graphql/queries/usageQuotasWithConsumption.tsnew file mode 100644index 00000000000..de5fd84bf99--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/graphql/queries/usageQuotasWithConsumption.ts@@ -0,0 +1,22 @@+import { gql } from '@apollo/client';++export const USAGE_QUOTAS_WITH_CONSUMPTION = gql`+ query UsageQuotasWithConsumption {+ usageQuotasWithConsumption {+ id+ resourceType+ operationType+ spenderType+ spenderId+ spenderLabel+ periodUnit+ meter+ limitValue+ isEnforced+ consumedValue+ remainingValue+ periodStart+ periodEnd+ }+ }+`;diff --git a/packages/twenty-front/src/modules/settings/billing/hooks/useUsageLimitFormatter.ts b/packages/twenty-front/src/modules/settings/billing/hooks/useUsageLimitFormatter.tsnew file mode 100644index 00000000000..e1e70ea60b1--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/hooks/useUsageLimitFormatter.ts@@ -0,0 +1,43 @@+import { useLingui } from '@lingui/react/macro';+import { INTERNAL_CREDITS_PER_DISPLAY_CREDIT } from 'twenty-shared/constants';+import { isDefined } from 'twenty-shared/utils';++import { useNumberFormat } from '@/localization/hooks/useNumberFormat';+import { USAGE_LIMIT_QUANTITY_UNIT_LABELS } from '@/settings/billing/constants/UsageLimitQuantityUnitLabels';+import { isCreditsMeter } from '@/settings/billing/utils/isCreditsMeter';+import { getUsageLimitLabel } from '@/settings/billing/utils/getUsageLimitLabel';+import { useUsageValueFormatter } from '@/settings/usage/hooks/useUsageValueFormatter';+import { type UsageOperationType } from '~/generated-metadata/graphql';++export const useUsageLimitFormatter = () => {+ const { t } = useLingui();+ const { formatNumber } = useNumberFormat();+ const { formatUsageAmount } = useUsageValueFormatter();++ const formatLimitValue = ({+ value,+ meter,+ operationType,+ }: {+ value: number;+ meter: string;+ operationType: UsageOperationType;+ }): string => {+ if (isCreditsMeter(meter)) {+ return formatUsageAmount(value / INTERNAL_CREDITS_PER_DISPLAY_CREDIT, {+ abbreviate: true,+ });+ }++ const unitLabel = getUsageLimitLabel(+ USAGE_LIMIT_QUANTITY_UNIT_LABELS,+ operationType,+ );++ const unit = isDefined(unitLabel) ? t(unitLabel) : t`operations`;++ return `${formatNumber(value, { decimals: 1, abbreviate: true })} ${unit}`;+ };++ return { formatLimitValue };+};diff --git a/packages/twenty-front/src/modules/settings/billing/hooks/useUsageLimitRows.ts b/packages/twenty-front/src/modules/settings/billing/hooks/useUsageLimitRows.tsnew file mode 100644index 00000000000..d794ba30aec--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/hooks/useUsageLimitRows.ts@@ -0,0 +1,108 @@+import { useLingui } from '@lingui/react/macro';+import { isDefined } from 'twenty-shared/utils';+import { IconCoins } from 'twenty-ui/icon';++import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';+import { USAGE_LIMIT_OPERATION_TYPE_ICONS } from '@/settings/billing/constants/UsageLimitOperationTypeIcons';+import { USAGE_LIMIT_PERIOD_NAME_LABELS } from '@/settings/billing/constants/UsageLimitPeriodNameLabels';+import { USAGE_LIMIT_RESOURCE_TYPE_LABELS } from '@/settings/billing/constants/UsageLimitResourceTypeLabels';+import { AVATAR_SPENDER_TYPES } from '@/settings/billing/constants/AvatarSpenderTypes';+import { useUsageLimitFormatter } from '@/settings/billing/hooks/useUsageLimitFormatter';+import { useUsageLimitSpenderOptions } from '@/settings/billing/hooks/useUsageLimitSpenderOptions';+import { type UsageLimitRow } from '@/settings/billing/types/UsageLimitRow';+import { type UsageQuotaWithConsumption } from '@/settings/billing/types/UsageQuotaWithConsumption';+import { computeUsageLimitProgress } from '@/settings/billing/utils/computeUsageLimitProgress';+import { getUsageLimitLabel } from '@/settings/billing/utils/getUsageLimitLabel';+import { getUsageLimitSpenderName } from '@/settings/billing/utils/getUsageLimitSpenderName';+import { isCreditsMeter } from '@/settings/billing/utils/isCreditsMeter';+import { isKeyOfRecord } from '@/settings/billing/utils/isKeyOfRecord';+import { getUsageOperationTypeLabel } from '@/settings/usage/utils/getUsageOperationTypeLabel';+import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';++export const useUsageLimitRows = (+ quotas: UsageQuotaWithConsumption[],+): UsageLimitRow[] => {+ const { t } = useLingui();+ const { formatLimitValue } = useUsageLimitFormatter();+ const currentWorkspace = useAtomStateValue(currentWorkspaceState);++ const { spenderOptionsByType } = useUsageLimitSpenderOptions(+ AVATAR_SPENDER_TYPES.filter((spenderType) =>+ quotas.some((quota) => quota.spenderType === spenderType),+ ),+ );++ const avatarUrlBySpenderId = new Map(+ Object.values(spenderOptionsByType)+ .flat()+ .map((option) => [option.id, option.avatarUrl ?? null]),+ );++ const getName = (quota: UsageQuotaWithConsumption): string => {+ const operationLabel = getUsageOperationTypeLabel(quota.operationType);+ const resourceText = t(+ USAGE_LIMIT_RESOURCE_TYPE_LABELS[quota.resourceType],+ );+ const operationText = isDefined(operationLabel)+ ? t(operationLabel)+ : quota.operationType;++ return `${resourceText} · ${operationText}`;+ };++ const getSpenderName = (quota: UsageQuotaWithConsumption): string =>+ quota.spenderType === 'workspace'+ ? (currentWorkspace?.displayName ?? getUsageLimitSpenderName(quota))+ : getUsageLimitSpenderName(quota);++ const getPeriodName = (periodUnit: string): string => {+ const periodLabel = getUsageLimitLabel(+ USAGE_LIMIT_PERIOD_NAME_LABELS,+ periodUnit,+ );++ return isDefined(periodLabel) ? t(periodLabel) : periodUnit;+ };++ return quotas.map((quota) => {+ const limitValue = Number(quota.limitValue);+ const consumedValue = isDefined(quota.consumedValue)+ ? Number(quota.consumedValue)+ : null;+ const progress = computeUsageLimitProgress({ limitValue, consumedValue });++ return {+ id: quota.id,+ name: getName(quota),+ NameIcon: isKeyOfRecord(+ USAGE_LIMIT_OPERATION_TYPE_ICONS,+ quota.operationType,+ )+ ? USAGE_LIMIT_OPERATION_TYPE_ICONS[quota.operationType]+ : IconCoins,+ spenderName: getSpenderName(quota),+ spenderAvatarUrl: isDefined(quota.spenderId)+ ? (avatarUrlBySpenderId.get(quota.spenderId) ?? null)+ : null,+ spenderType: quota.spenderType,+ resourceType: quota.resourceType,+ isEnforced: quota.isEnforced,+ consumedPercentage: progress?.consumedPercentage ?? null,+ consumedText: isDefined(consumedValue)+ ? formatLimitValue({+ value: consumedValue,+ meter: quota.meter,+ operationType: quota.operationType,+ })+ : null,+ limitText: formatLimitValue({+ value: limitValue,+ meter: quota.meter,+ operationType: quota.operationType,+ }),+ isCreditsMeter: isCreditsMeter(quota.meter),+ isExhausted: progress?.remainingValue === 0,+ periodName: getPeriodName(quota.periodUnit),+ };+ });+};diff --git a/packages/twenty-front/src/modules/settings/billing/hooks/useUsageLimitSpenderOptions.ts b/packages/twenty-front/src/modules/settings/billing/hooks/useUsageLimitSpenderOptions.tsnew file mode 100644index 00000000000..4e8e6f1436a--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/hooks/useUsageLimitSpenderOptions.ts@@ -0,0 +1,112 @@+import { useQuery } from '@apollo/client/react';+import { isDefined } from 'twenty-shared/utils';++import { currentWorkspaceMembersState } from '@/auth/states/currentWorkspaceMembersState';+import { type UsageLimitSpenderType } from '@/settings/billing/types/UsageLimitSpenderType';+import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';+import {+ FindManyAgentsDocument,+ FindManyApplicationsDocument,+ FindManyLogicFunctionsDocument,+ GetApiKeysDocument,+} from '~/generated-metadata/graphql';++export type UsageLimitSpenderOption = {+ id: string;+ label: string;+ avatarUrl?: string | null;+};++type UsageLimitSpenderOptionsByType = Partial<+ Record<UsageLimitSpenderType, UsageLimitSpenderOption[]>+>;++export const useUsageLimitSpenderOptions = (+ spenderTypes: UsageLimitSpenderType[],+): {+ spenderOptionsByType: UsageLimitSpenderOptionsByType;+ loading: boolean;+} => {+ const currentWorkspaceMembers = useAtomStateValue(+ currentWorkspaceMembersState,+ );++ const { data: apiKeysData, loading: apiKeysLoading } = useQuery(+ GetApiKeysDocument,+ { skip: !spenderTypes.includes('apiKey') },+ );+ const { data: applicationsData, loading: applicationsLoading } = useQuery(+ FindManyApplicationsDocument,+ { skip: !spenderTypes.includes('application') },+ );+ const { data: agentsData, loading: agentsLoading } = useQuery(+ FindManyAgentsDocument,+ { skip: !spenderTypes.includes('agent') },+ );+ const { data: logicFunctionsData, loading: logicFunctionsLoading } = useQuery(+ FindManyLogicFunctionsDocument,+ { skip: !spenderTypes.includes('logicFunction') },+ );+ const buildOptions = (+ spenderType: UsageLimitSpenderType,+ ): UsageLimitSpenderOption[] => {+ switch (spenderType) {+ case 'userWorkspace':+ return currentWorkspaceMembers.flatMap((member) =>+ isDefined(member.userWorkspaceId)+ ? [+ {+ id: member.userWorkspaceId,+ label:+ `${member.name.firstName} ${member.name.lastName}`.trim() ||+ member.userEmail,+ avatarUrl: member.avatarUrl,+ },+ ]+ : [],+ );+ case 'apiKey':+ return (apiKeysData?.apiKeys ?? [])+ .filter((apiKey) => !isDefined(apiKey.revokedAt))+ .map((apiKey) => ({ id: apiKey.id, label: apiKey.name }));+ case 'application':+ return (applicationsData?.findManyApplications ?? []).map(+ (application) => ({+ id: application.id,+ label: application.name,+ avatarUrl: application.logoUrl,+ }),+ );+ case 'agent':+ return (agentsData?.findManyAgents ?? []).map((agent) => ({+ id: agent.id,+ label: agent.label,+ }));+ case 'workflow':+ return [];+ case 'logicFunction':+ return (logicFunctionsData?.findManyLogicFunctions ?? []).map(+ (logicFunction) => ({+ id: logicFunction.id,+ label: logicFunction.name,+ }),+ );+ case 'workspace':+ return [];+ }+ };++ return {+ spenderOptionsByType: Object.fromEntries(+ spenderTypes.map((spenderType) => [+ spenderType,+ buildOptions(spenderType),+ ]),+ ),+ loading:+ apiKeysLoading ||+ applicationsLoading ||+ agentsLoading ||+ logicFunctionsLoading,+ };+};diff --git a/packages/twenty-front/src/modules/settings/billing/hooks/useUsageQuotasWithConsumption.ts b/packages/twenty-front/src/modules/settings/billing/hooks/useUsageQuotasWithConsumption.tsnew file mode 100644index 00000000000..5a072afcbc3--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/hooks/useUsageQuotasWithConsumption.ts@@ -0,0 +1,13 @@+import { useQuery } from '@apollo/client/react';++import { UsageQuotasWithConsumptionDocument } from '~/generated-metadata/graphql';++export const useUsageQuotasWithConsumption = () => {+ const { data, loading, error } = useQuery(UsageQuotasWithConsumptionDocument);++ return {+ usageQuotasWithConsumption: data?.usageQuotasWithConsumption ?? [],+ loading,+ error,+ };+};diff --git a/packages/twenty-front/src/modules/settings/billing/types/UsageLimitMeter.ts b/packages/twenty-front/src/modules/settings/billing/types/UsageLimitMeter.tsnew file mode 100644index 00000000000..551fce45872--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/types/UsageLimitMeter.ts@@ -0,0 +1 @@+export type UsageLimitMeter = 'creditsUsedMicro' | 'quantity';diff --git a/packages/twenty-front/src/modules/settings/billing/types/UsageLimitPeriodUnit.ts b/packages/twenty-front/src/modules/settings/billing/types/UsageLimitPeriodUnit.tsnew file mode 100644index 00000000000..1aa11810d2c--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/types/UsageLimitPeriodUnit.ts@@ -0,0 +1,3 @@+import { type USAGE_LIMIT_PERIOD_UNITS } from '@/settings/billing/constants/UsageLimitPeriodUnits';++export type UsageLimitPeriodUnit = (typeof USAGE_LIMIT_PERIOD_UNITS)[number];diff --git a/packages/twenty-front/src/modules/settings/billing/types/UsageLimitRow.ts b/packages/twenty-front/src/modules/settings/billing/types/UsageLimitRow.tsnew file mode 100644index 00000000000..5073d99769b--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/types/UsageLimitRow.ts@@ -0,0 +1,20 @@+import { type IconComponent } from 'twenty-ui/icon';++import { type UsageResourceType } from '~/generated-metadata/graphql';++export type UsageLimitRow = {+ id: string;+ name: string;+ NameIcon: IconComponent;+ spenderName: string;+ spenderAvatarUrl: string | null;+ spenderType: string;+ resourceType: UsageResourceType | null;+ isEnforced: boolean;+ consumedPercentage: number | null;+ consumedText: string | null;+ limitText: string;+ isCreditsMeter: boolean;+ isExhausted: boolean;+ periodName: string;+};diff --git a/packages/twenty-front/src/modules/settings/billing/types/UsageLimitSpenderType.ts b/packages/twenty-front/src/modules/settings/billing/types/UsageLimitSpenderType.tsnew file mode 100644index 00000000000..7ffba8715a0--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/types/UsageLimitSpenderType.ts@@ -0,0 +1,8 @@+export type UsageLimitSpenderType =+ | 'workspace'+ | 'userWorkspace'+ | 'apiKey'+ | 'application'+ | 'agent'+ | 'workflow'+ | 'logicFunction';diff --git a/packages/twenty-front/src/modules/settings/billing/types/UsageQuotaWithConsumption.ts b/packages/twenty-front/src/modules/settings/billing/types/UsageQuotaWithConsumption.tsnew file mode 100644index 00000000000..ebe9bc24850--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/types/UsageQuotaWithConsumption.ts@@ -0,0 +1,4 @@+import { type UsageQuotasWithConsumptionQuery } from '~/generated-metadata/graphql';++export type UsageQuotaWithConsumption =+ UsageQuotasWithConsumptionQuery['usageQuotasWithConsumption'][number];diff --git a/packages/twenty-front/src/modules/settings/billing/utils/__tests__/computeUsageLimitProgress.test.ts b/packages/twenty-front/src/modules/settings/billing/utils/__tests__/computeUsageLimitProgress.test.tsnew file mode 100644index 00000000000..9d779bc202e--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/utils/__tests__/computeUsageLimitProgress.test.ts@@ -0,0 +1,45 @@+import { computeUsageLimitProgress } from '@/settings/billing/utils/computeUsageLimitProgress';++describe('computeUsageLimitProgress', () => {+ it('splits the limit between what is consumed and what is left', () => {+ expect(+ computeUsageLimitProgress({ limitValue: 100, consumedValue: 24 }),+ ).toEqual({+ remainingValue: 76,+ consumedPercentage: 24,+ remainingPercentage: 76,+ });+ });++ it('clamps consumption that went over the limit', () => {+ expect(+ computeUsageLimitProgress({ limitValue: 100, consumedValue: 250 }),+ ).toEqual({+ remainingValue: 0,+ consumedPercentage: 100,+ remainingPercentage: 0,+ });+ });++ it('keeps the remaining amount apart from the rounded percentage', () => {+ expect(+ computeUsageLimitProgress({ limitValue: 1000, consumedValue: 996 }),+ ).toEqual({+ remainingValue: 4,+ consumedPercentage: 100,+ remainingPercentage: 0,+ });+ });++ it('reports nothing when consumption was not counted', () => {+ expect(+ computeUsageLimitProgress({ limitValue: 100, consumedValue: null }),+ ).toBeNull();+ });++ it('reports nothing when the limit cannot be divided by', () => {+ expect(+ computeUsageLimitProgress({ limitValue: 0, consumedValue: 10 }),+ ).toBeNull();+ });+});diff --git a/packages/twenty-front/src/modules/settings/billing/utils/__tests__/filterUsageLimitRows.test.ts b/packages/twenty-front/src/modules/settings/billing/utils/__tests__/filterUsageLimitRows.test.tsnew file mode 100644index 00000000000..5e84f5203ae--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/utils/__tests__/filterUsageLimitRows.test.ts@@ -0,0 +1,113 @@+import { IconCoins } from 'twenty-ui/icon';++import { type UsageLimitRow } from '@/settings/billing/types/UsageLimitRow';+import { filterUsageLimitRows } from '@/settings/billing/utils/filterUsageLimitRows';+import { UsageResourceType } from '~/generated-metadata/graphql';++const buildRow = (overrides: Partial<UsageLimitRow> = {}): UsageLimitRow => ({+ id: 'row-id',+ name: 'AI · AI Chat',+ NameIcon: IconCoins,+ spenderName: 'Tim Cook',+ spenderAvatarUrl: null,+ spenderType: 'userWorkspace',+ resourceType: UsageResourceType.AI,+ isEnforced: true,+ consumedPercentage: 60,+ consumedText: '60 credits',+ limitText: '100 credits',+ isCreditsMeter: true,+ isExhausted: false,+ periodName: 'Monthly',+ ...overrides,+});++const filter = (+ rows: UsageLimitRow[],+ overrides: {+ searchText?: string;+ resourceType?: UsageResourceType | null;+ spenderType?: string | null;+ } = {},+) =>+ filterUsageLimitRows({+ rows,+ searchText: '',+ resourceType: null,+ spenderType: null,+ ...overrides,+ });++describe('filterUsageLimitRows', () => {+ it('keeps every row when nothing is searched or filtered', () => {+ const rows = [buildRow(), buildRow({ id: 'other' })];++ expect(filter(rows)).toEqual(rows);+ });++ it('matches the usage regardless of case and accents', () => {+ const rows = [buildRow({ name: 'AI · Résumé Generation' }), buildRow()];++ expect(filter(rows, { searchText: 'resume' })).toEqual([rows[0]]);+ });++ it('matches the resource named in the usage', () => {+ const rows = [+ buildRow(),+ buildRow({ id: 'api', name: 'API · API Request' }),+ ];++ expect(filter(rows, { searchText: 'api' })).toEqual([rows[1]]);+ });++ it('matches the spender name too', () => {+ const rows = [buildRow(), buildRow({ id: 'key', spenderName: 'Prod key' })];++ expect(filter(rows, { searchText: 'prod' })).toEqual([rows[1]]);+ });++ it('keeps only the chosen resource', () => {+ const rows = [+ buildRow(),+ buildRow({ id: 'api', resourceType: UsageResourceType.API }),+ ];++ expect(filter(rows, { resourceType: UsageResourceType.API })).toEqual([+ rows[1],+ ]);+ });++ it('keeps only the chosen spender type', () => {+ const rows = [+ buildRow(),+ buildRow({ id: 'workspace-wide', spenderType: 'workspace' }),+ ];++ expect(filter(rows, { spenderType: 'workspace' })).toEqual([rows[1]]);+ });++ it('applies the resource and the spender together', () => {+ const rows = [+ buildRow(),+ buildRow({ id: 'workspace-wide', spenderType: 'workspace' }),+ buildRow({+ id: 'api-workspace',+ resourceType: UsageResourceType.API,+ spenderType: 'workspace',+ }),+ ];++ expect(+ filter(rows, {+ resourceType: UsageResourceType.API,+ spenderType: 'workspace',+ }),+ ).toEqual([rows[2]]);+ });++ it('drops rows without a resource when one is chosen', () => {+ const rows = [buildRow({ resourceType: null })];++ expect(filter(rows, { resourceType: UsageResourceType.AI })).toEqual([]);+ });+});diff --git a/packages/twenty-front/src/modules/settings/billing/utils/__tests__/getUsageLimitRingColor.test.ts b/packages/twenty-front/src/modules/settings/billing/utils/__tests__/getUsageLimitRingColor.test.tsnew file mode 100644index 00000000000..b1d2c93fe12--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/utils/__tests__/getUsageLimitRingColor.test.ts@@ -0,0 +1,29 @@+import { themeCssVariables } from 'twenty-ui/theme-constants';++import { getUsageLimitRingColor } from '@/settings/billing/utils/getUsageLimitRingColor';++describe('getUsageLimitRingColor', () => {+ it('stays blue while the limit is comfortable', () => {+ expect(+ getUsageLimitRingColor({ consumedPercentage: 60, isExhausted: false }),+ ).toBe(themeCssVariables.color.blue);+ });++ it('turns orange past 60%', () => {+ expect(+ getUsageLimitRingColor({ consumedPercentage: 61, isExhausted: false }),+ ).toBe(themeCssVariables.color.orange);+ });++ it('turns red past 80%', () => {+ expect(+ getUsageLimitRingColor({ consumedPercentage: 81, isExhausted: false }),+ ).toBe(themeCssVariables.color.red);+ });++ it('turns red as soon as nothing is left, whatever the rounded percentage', () => {+ expect(+ getUsageLimitRingColor({ consumedPercentage: 12, isExhausted: true }),+ ).toBe(themeCssVariables.color.red);+ });+});diff --git a/packages/twenty-front/src/modules/settings/billing/utils/__tests__/getUsageLimitSpenderName.test.ts b/packages/twenty-front/src/modules/settings/billing/utils/__tests__/getUsageLimitSpenderName.test.tsnew file mode 100644index 00000000000..30251c5a403--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/utils/__tests__/getUsageLimitSpenderName.test.ts@@ -0,0 +1,39 @@+import { getUsageLimitSpenderName } from '@/settings/billing/utils/getUsageLimitSpenderName';++describe('getUsageLimitSpenderName', () => {+ it('uses the resolved name when the limit targets one spender', () => {+ expect(+ getUsageLimitSpenderName({+ spenderType: 'userWorkspace',+ spenderLabel: 'Tim Apple',+ }),+ ).toBe('Tim Apple');+ });++ it('names the pool when every spender of the type shares the limit', () => {+ expect(+ getUsageLimitSpenderName({+ spenderType: 'userWorkspace',+ spenderLabel: null,+ }),+ ).toBe('All users');+ expect(+ getUsageLimitSpenderName({ spenderType: 'apiKey', spenderLabel: null }),+ ).toBe('All API keys');+ });++ it('speaks of the workspace itself for a workspace-wide limit', () => {+ expect(+ getUsageLimitSpenderName({+ spenderType: 'workspace',+ spenderLabel: null,+ }),+ ).toBe('The whole workspace');+ });++ it('falls back to the raw type when the API sends an unknown one', () => {+ expect(+ getUsageLimitSpenderName({ spenderType: 'martian', spenderLabel: null }),+ ).toBe('martian');+ });+});diff --git a/packages/twenty-front/src/modules/settings/billing/utils/__tests__/hasKnownUsageLimitSpender.test.ts b/packages/twenty-front/src/modules/settings/billing/utils/__tests__/hasKnownUsageLimitSpender.test.tsnew file mode 100644index 00000000000..c2539bf38b9--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/utils/__tests__/hasKnownUsageLimitSpender.test.ts@@ -0,0 +1,27 @@+import { hasKnownUsageLimitSpender } from '@/settings/billing/utils/hasKnownUsageLimitSpender';++describe('hasKnownUsageLimitSpender', () => {+ it('keeps a limit whose spender the API named', () => {+ expect(+ hasKnownUsageLimitSpender({+ spenderId: 'a-member-id',+ spenderLabel: 'Tim Apple',+ }),+ ).toBe(true);+ });++ it('keeps a limit shared by a whole pool', () => {+ expect(+ hasKnownUsageLimitSpender({ spenderId: null, spenderLabel: null }),+ ).toBe(true);+ });++ it('drops a limit whose spender is gone', () => {+ expect(+ hasKnownUsageLimitSpender({+ spenderId: 'a-deleted-member-id',+ spenderLabel: null,+ }),+ ).toBe(false);+ });+});diff --git a/packages/twenty-front/src/modules/settings/billing/utils/__tests__/isKeyOfRecord.test.ts b/packages/twenty-front/src/modules/settings/billing/utils/__tests__/isKeyOfRecord.test.tsnew file mode 100644index 00000000000..ddf34c8865f--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/utils/__tests__/isKeyOfRecord.test.ts@@ -0,0 +1,19 @@+import { isKeyOfRecord } from '@/settings/billing/utils/isKeyOfRecord';++const RECORD = { workspace: 1, apiKey: 2 };++describe('isKeyOfRecord', () => {+ it('accepts a key the record owns', () => {+ expect(isKeyOfRecord(RECORD, 'workspace')).toBe(true);+ });++ it('rejects a key the record does not own', () => {+ expect(isKeyOfRecord(RECORD, 'martian')).toBe(false);+ });++ it('rejects inherited properties', () => {+ expect(isKeyOfRecord(RECORD, 'constructor')).toBe(false);+ expect(isKeyOfRecord(RECORD, 'toString')).toBe(false);+ expect(isKeyOfRecord(RECORD, '__proto__')).toBe(false);+ });+});diff --git a/packages/twenty-front/src/modules/settings/billing/utils/computeUsageLimitProgress.ts b/packages/twenty-front/src/modules/settings/billing/utils/computeUsageLimitProgress.tsnew file mode 100644index 00000000000..c3b198d8018--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/utils/computeUsageLimitProgress.ts@@ -0,0 +1,30 @@+import { isDefined } from 'twenty-shared/utils';++type UsageLimitProgress = {+ remainingValue: number;+ consumedPercentage: number;+ remainingPercentage: number;+};++export const computeUsageLimitProgress = ({+ limitValue,+ consumedValue,+}: {+ limitValue: number;+ consumedValue: number | null;+}): UsageLimitProgress | null => {+ if (!isDefined(consumedValue) || limitValue <= 0) {+ return null;+ }++ const consumedPercentage = Math.min(+ 100,+ Math.max(0, Math.round((consumedValue / limitValue) * 100)),+ );++ return {+ remainingValue: Math.max(0, limitValue - consumedValue),+ consumedPercentage,+ remainingPercentage: 100 - consumedPercentage,+ };+};diff --git a/packages/twenty-front/src/modules/settings/billing/utils/filterUsageLimitRows.ts b/packages/twenty-front/src/modules/settings/billing/utils/filterUsageLimitRows.tsnew file mode 100644index 00000000000..21cabcf601f--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/utils/filterUsageLimitRows.ts@@ -0,0 +1,31 @@+import { isDefined } from 'twenty-shared/utils';++import { type UsageLimitRow } from '@/settings/billing/types/UsageLimitRow';+import { type UsageResourceType } from '~/generated-metadata/graphql';+import { normalizeSearchText } from '~/utils/normalizeSearchText';++export const filterUsageLimitRows = ({+ rows,+ searchText,+ resourceType,+ spenderType,+}: {+ rows: UsageLimitRow[];+ searchText: string;+ resourceType: UsageResourceType | null;+ spenderType: string | null;+}): UsageLimitRow[] => {+ const normalizedSearchText = normalizeSearchText(searchText);++ return rows+ .filter(+ (row) => !isDefined(resourceType) || row.resourceType === resourceType,+ )+ .filter((row) => !isDefined(spenderType) || row.spenderType === spenderType)+ .filter(+ (row) =>+ normalizedSearchText.length === 0 ||+ normalizeSearchText(row.name).includes(normalizedSearchText) ||+ normalizeSearchText(row.spenderName).includes(normalizedSearchText),+ );+};diff --git a/packages/twenty-front/src/modules/settings/billing/utils/getUsageLimitLabel.ts b/packages/twenty-front/src/modules/settings/billing/utils/getUsageLimitLabel.tsnew file mode 100644index 00000000000..f52090d82e9--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/utils/getUsageLimitLabel.ts@@ -0,0 +1,9 @@+import { type MessageDescriptor } from '@lingui/core';++import { isKeyOfRecord } from '@/settings/billing/utils/isKeyOfRecord';++export const getUsageLimitLabel = (+ labels: Record<string, MessageDescriptor>,+ key: string,+): MessageDescriptor | undefined =>+ isKeyOfRecord(labels, key) ? labels[key] : undefined;diff --git a/packages/twenty-front/src/modules/settings/billing/utils/getUsageLimitRingColor.ts b/packages/twenty-front/src/modules/settings/billing/utils/getUsageLimitRingColor.tsnew file mode 100644index 00000000000..392d04372fe--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/utils/getUsageLimitRingColor.ts@@ -0,0 +1,19 @@+import { themeCssVariables } from 'twenty-ui/theme-constants';++export const getUsageLimitRingColor = ({+ consumedPercentage,+ isExhausted,+}: {+ consumedPercentage: number;+ isExhausted: boolean;+}): string => {+ if (isExhausted || consumedPercentage > 80) {+ return themeCssVariables.color.red;+ }++ if (consumedPercentage > 60) {+ return themeCssVariables.color.orange;+ }++ return themeCssVariables.color.blue;+};diff --git a/packages/twenty-front/src/modules/settings/billing/utils/getUsageLimitSpenderName.ts b/packages/twenty-front/src/modules/settings/billing/utils/getUsageLimitSpenderName.tsnew file mode 100644index 00000000000..11cecb9d2da--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/utils/getUsageLimitSpenderName.ts@@ -0,0 +1,21 @@+import { t } from '@lingui/core/macro';+import { isDefined } from 'twenty-shared/utils';++import { USAGE_LIMIT_SPENDER_TYPE_POOL_LABELS } from '@/settings/billing/constants/UsageLimitSpenderTypePoolLabels';+import { type UsageQuotaWithConsumption } from '@/settings/billing/types/UsageQuotaWithConsumption';+import { getUsageLimitLabel } from '@/settings/billing/utils/getUsageLimitLabel';++export const getUsageLimitSpenderName = (+ item: Pick<UsageQuotaWithConsumption, 'spenderType' | 'spenderLabel'>,+): string => {+ if (isDefined(item.spenderLabel)) {+ return item.spenderLabel;+ }++ const poolLabel = getUsageLimitLabel(+ USAGE_LIMIT_SPENDER_TYPE_POOL_LABELS,+ item.spenderType,+ );++ return isDefined(poolLabel) ? t(poolLabel) : item.spenderType;+};diff --git a/packages/twenty-front/src/modules/settings/billing/utils/hasKnownUsageLimitSpender.ts b/packages/twenty-front/src/modules/settings/billing/utils/hasKnownUsageLimitSpender.tsnew file mode 100644index 00000000000..c7393d370bb--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/utils/hasKnownUsageLimitSpender.ts@@ -0,0 +1,10 @@+import { isNonEmptyString } from '@sniptt/guards';+import { isDefined } from 'twenty-shared/utils';++import { type UsageQuotaWithConsumption } from '@/settings/billing/types/UsageQuotaWithConsumption';++// a limit outlives the user or key it targets, and the API sends no label once it is gone+export const hasKnownUsageLimitSpender = (+ quota: Pick<UsageQuotaWithConsumption, 'spenderId' | 'spenderLabel'>,+): boolean =>+ !isNonEmptyString(quota.spenderId) || isDefined(quota.spenderLabel);diff --git a/packages/twenty-front/src/modules/settings/billing/utils/isCreditsMeter.ts b/packages/twenty-front/src/modules/settings/billing/utils/isCreditsMeter.tsnew file mode 100644index 00000000000..92c713654c3--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/utils/isCreditsMeter.ts@@ -0,0 +1,6 @@+import { type UsageLimitMeter } from '@/settings/billing/types/UsageLimitMeter';++const CREDITS_METER: UsageLimitMeter = 'creditsUsedMicro';++export const isCreditsMeter = (meter: string): boolean =>+ meter === CREDITS_METER;diff --git a/packages/twenty-front/src/modules/settings/billing/utils/isKeyOfRecord.ts b/packages/twenty-front/src/modules/settings/billing/utils/isKeyOfRecord.tsnew file mode 100644index 00000000000..a535581ec52--- /dev/null+++ b/packages/twenty-front/src/modules/settings/billing/utils/isKeyOfRecord.ts@@ -0,0 +1,4 @@+export const isKeyOfRecord = <TKey extends string>(+ record: Record<TKey, unknown>,+ value: string,+): value is TKey => Object.prototype.hasOwnProperty.call(record, value);diff --git a/packages/twenty-front/src/modules/settings/usage/hooks/useUsageValueFormatter.ts b/packages/twenty-front/src/modules/settings/usage/hooks/useUsageValueFormatter.tsindex b24428d09b2..8c0230258db 100644--- a/packages/twenty-front/src/modules/settings/usage/hooks/useUsageValueFormatter.ts+++ b/packages/twenty-front/src/modules/settings/usage/hooks/useUsageValueFormatter.ts@@ -14,17 +14,29 @@ export const useUsageValueFormatter = () => {const isBillingEnabled = billing?.isBillingEnabled ?? false;const { formatNumber } = useNumberFormat();- const formatUsageValue = (value: number): string => {+ const formatUsageValue = (+ value: number,+ { abbreviate = false }: { abbreviate?: boolean } = {},+ ): string => {if (isBillingEnabled) {const decimals = getDecimalsNeeded(value);- return `${formatNumber(value, { decimals })} credits`;+ return `${formatNumber(value, { decimals, abbreviate })} credits`;}- return `$${formatNumber(value, { decimals: 2 })}`;+ return `$${formatNumber(value, { decimals: 2, abbreviate })}`;};+ const formatUsageAmount = (+ value: number,+ { abbreviate = false }: { abbreviate?: boolean } = {},+ ): string =>+ formatNumber(value, {+ decimals: isBillingEnabled ? getDecimalsNeeded(value) : 2,+ abbreviate,+ });+const unitLabel = isBillingEnabled ? 'credits' : '$';- return { formatUsageValue, isBillingEnabled, unitLabel };+ return { formatUsageValue, formatUsageAmount, isBillingEnabled, unitLabel };};diff --git a/packages/twenty-front/src/modules/ui/feedback/progress-ring/components/ProgressRing.tsx b/packages/twenty-front/src/modules/ui/feedback/progress-ring/components/ProgressRing.tsxnew file mode 100644index 00000000000..0435dc076a9--- /dev/null+++ b/packages/twenty-front/src/modules/ui/feedback/progress-ring/components/ProgressRing.tsx@@ -0,0 +1,59 @@+import { styled } from '@linaria/react';+import { themeCssVariables } from 'twenty-ui/theme-constants';++type ProgressRingProps = {+ value: number;+ size?: number;+ strokeWidth?: number;+ barColor?: string;+};++const StyledSvg = styled.svg`+ transform: rotate(-90deg);+`;++const StyledTrackCircle = styled.circle`+ fill: none;+ stroke: color-mix(+ in srgb,+ ${themeCssVariables.border.color.strong} 50%,+ ${themeCssVariables.background.quaternary} 50%+ );+`;++const StyledValueCircle = styled.circle`+ fill: none;+ transition: stroke-dashoffset 0.3s ease;+`;++export const ProgressRing = ({+ value,+ size = 16,+ strokeWidth = 2,+ barColor = themeCssVariables.color.blue,+}: ProgressRingProps) => {+ const boundedValue = Math.min(Math.max(value, 0), 100);+ const radius = (size - strokeWidth) / 2;+ const circumference = 2 * Math.PI * radius;++ return (+ <StyledSvg width={size} height={size}>+ <StyledTrackCircle+ cx={size / 2}+ cy={size / 2}+ r={radius}+ strokeWidth={strokeWidth}+ />+ <StyledValueCircle+ cx={size / 2}+ cy={size / 2}+ r={radius}+ strokeWidth={strokeWidth}+ style={{ stroke: barColor }}+ strokeDasharray={circumference}+ strokeDashoffset={circumference - (boundedValue / 100) * circumference}+ strokeLinecap="round"+ />+ </StyledSvg>+ );+};diff --git a/packages/twenty-front/src/modules/ui/input/components/SelectControl.tsx b/packages/twenty-front/src/modules/ui/input/components/SelectControl.tsxindex 3515f5a087f..dbe78ff6c68 100644--- a/packages/twenty-front/src/modules/ui/input/components/SelectControl.tsx+++ b/packages/twenty-front/src/modules/ui/input/components/SelectControl.tsx@@ -1,7 +1,7 @@import { type SelectSizeVariant } from '@/ui/input/components/Select';import { type FormFieldInputVariant } from '@/ui/input/types/FormFieldInputVariant';import { styled } from '@linaria/react';-import { useContext } from 'react';+import { type ReactNode, useContext } from 'react';import { isDefined } from 'twenty-shared/utils';import { TintedIconTile } from 'twenty-ui/data-display';import { IconChevronDown } from 'twenty-ui/icon';@@ -89,6 +89,7 @@ const StyledIconChevronDownWrapper = styled.div<{export type SelectControlProps = {selectedOption: SelectOption<string | number | boolean | null>;+ LeftComponent?: ReactNode;isDisabled?: boolean;selectSizeVariant?: SelectSizeVariant;textAccent?: SelectControlTextAccent;@@ -98,6 +99,7 @@ export type SelectControlProps = {export const SelectControl = ({selectedOption,+ LeftComponent,isDisabled,selectSizeVariant,textAccent = 'default',@@ -108,14 +110,16 @@ export const SelectControl = ({return (<StyledControlContainerdisabled={isDisabled}- hasIcon={isDefined(selectedOption?.Icon)}+ hasIcon={isDefined(LeftComponent) || isDefined(selectedOption?.Icon)}selectSizeVariant={selectSizeVariant}textAccent={textAccent}hasRightElement={hasRightElement}$variant={variant}title={selectedOption.fullLabel}>- {isDefined(selectedOption?.Icon) ? (+ {isDefined(LeftComponent) ? (+ LeftComponent+ ) : isDefined(selectedOption?.Icon) ? (isDefined(selectedOption.iconThemeColor) ? (<TintedIconTileIcon={selectedOption.Icon}diff --git a/packages/twenty-front/src/pages/settings/billing/SettingsBillingLimits.tsx b/packages/twenty-front/src/pages/settings/billing/SettingsBillingLimits.tsxnew file mode 100644index 00000000000..0c9782a2e45--- /dev/null+++ b/packages/twenty-front/src/pages/settings/billing/SettingsBillingLimits.tsx@@ -0,0 +1,8 @@+import { SettingsBillingLimitsContent } from '@/settings/billing/components/SettingsBillingLimitsContent';+import { SettingsBillingPageLayout } from '@/settings/billing/components/SettingsBillingPageLayout';++export const SettingsBillingLimits = () => (+ <SettingsBillingPageLayout>+ <SettingsBillingLimitsContent />+ </SettingsBillingPageLayout>+);diff --git a/packages/twenty-shared/src/types/SettingsPath.ts b/packages/twenty-shared/src/types/SettingsPath.tsindex 43b50cea4b0..0eaf318ddec 100644--- a/packages/twenty-shared/src/types/SettingsPath.ts+++ b/packages/twenty-shared/src/types/SettingsPath.ts@@ -14,8 +14,6 @@ export enum SettingsPath {Usage = 'billing/usage',UsageUserDetail = 'billing/usage/user/:userWorkspaceId',BillingLimits = 'billing/limits',- BillingNewLimit = 'billing/limits/new',- BillingLimitEdit = 'billing/limits/:usageLimitId/edit',Enterprise = 'enterprise',Objects = 'objects',ObjectOverview = 'objects/overview',