-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(billing): support initial billing limit for data warehouse (#23384)
- Loading branch information
1 parent
69dbda6
commit c2a6c45
Showing
8 changed files
with
91 additions
and
53 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
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,41 @@ | ||
import { useValues } from 'kea' | ||
import { LemonBanner } from 'lib/lemon-ui/LemonBanner' | ||
import { urls } from 'scenes/urls' | ||
|
||
import { BillingProductV2Type, ProductKey } from '~/types' | ||
|
||
import { billingLogic } from './billingLogic' | ||
import { billingProductLogic } from './billingProductLogic' | ||
|
||
const InitialBillingLimitNoticeContents = ({ product }: { product: BillingProductV2Type }): JSX.Element | null => { | ||
const { currentAndUpgradePlans, customLimitUsd } = useValues(billingProductLogic({ product })) | ||
const initialBillingLimit = currentAndUpgradePlans?.currentPlan?.initial_billing_limit | ||
const isUsingInitialBillingLimit = currentAndUpgradePlans?.currentPlan?.initial_billing_limit == customLimitUsd | ||
|
||
return isUsingInitialBillingLimit ? ( | ||
<LemonBanner | ||
type="info" | ||
className="my-4" | ||
action={{ | ||
type: 'primary', | ||
children: 'Change limit', | ||
to: urls.organizationBilling([product.type as ProductKey]), | ||
}} | ||
dismissKey={`initial-billing-limit-notice-${product.type}`} | ||
> | ||
<p className="flex-1 min-w-full sm:min-w-0"> | ||
Default initial billing limit of <b className="text-primary">${initialBillingLimit}</b> active. | ||
</p> | ||
<p className="font-normal"> | ||
This protects you from accidentally incurring large unexpected charges. Some features may stop working | ||
and data may be dropped if your usage exceeds your limit. | ||
</p> | ||
</LemonBanner> | ||
) : null | ||
} | ||
|
||
export const InitialBillingLimitNotice = ({ product_key }: { product_key: ProductKey }): JSX.Element | null => { | ||
const { billing } = useValues(billingLogic) | ||
const product = billing?.products.find((p) => p.type === product_key) | ||
return product ? <InitialBillingLimitNoticeContents product={product} /> : null | ||
} |
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
15 changes: 15 additions & 0 deletions
15
frontend/src/scenes/data-warehouse/DataWarehouseInitialBillingLimitNotice.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,15 @@ | ||
import { useValues } from 'kea' | ||
import { InitialBillingLimitNotice } from 'scenes/billing/InitialBillingLimitNotice' | ||
|
||
import { ProductKey } from '~/types' | ||
|
||
import { dataWarehouseSettingsLogic } from './settings/dataWarehouseSettingsLogic' | ||
|
||
export const DataWarehouseInitialBillingLimitNotice = (): JSX.Element | null => { | ||
const { dataWarehouseSources, selfManagedTables } = useValues(dataWarehouseSettingsLogic) | ||
|
||
const hasSources = | ||
(dataWarehouseSources?.results && dataWarehouseSources?.results.length > 0) || selfManagedTables?.length > 0 | ||
|
||
return hasSources ? <InitialBillingLimitNotice product_key={ProductKey.DATA_WAREHOUSE} /> : null | ||
} |
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