Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Merge branch 'main' into feature/usage-breakdown

Victor Hugo dos Santos7e5c41378d75
diff --cc backend/src/ee/services/license-v2/license-v2-service.ts
index 9cd32383fe,3807ae1280..2ff2b2788a
--- a/backend/src/ee/services/license-v2/license-v2-service.ts
+++ b/backend/src/ee/services/license-v2/license-v2-service.ts
@@@ -34,7 -28,7 +34,8 @@@ import
BillingV2Plan,
BillingV2Preview,
BillingV2SubState,
+ BillingV2UsageBreakdown,
+ BillingV2Trial,
TAddBillingV2PaymentMethodDTO,
TBillingV2SubscriptionLifecycleDTO,
TBuyBillingV2ProductDTO,
@@@ -43,11 -37,10 +44,12 @@@
TCreateBillingV2PortalSessionDTO,
TGetBillingV2CatalogDTO,
TGetBillingV2OverviewDTO,
+ TGetBillingV2UsageBreakdownDTO,
+ TListBillableOrganizationsDTO,
TPreviewBillingV2ChangeDTO,
TRemoveBillingV2ProductDTO,
- TStartBillingV2TrialDTO
+ TStartBillingV2TrialDTO,
+ TUpgradeBillingV2ProductDTO
} from "./license-v2-types";
type TLicenseV2ServiceFactoryDep = {
diff --cc backend/src/services/license-client/usage/usage-counter-dal.ts
index fb0b4e612f,50e5660b0f..5b1c35a49c
--- a/backend/src/services/license-client/usage/usage-counter-dal.ts
+++ b/backend/src/services/license-client/usage/usage-counter-dal.ts
@@@ -317,77 -252,11 +317,82 @@@ export const usageCounterDALFactory = (
}
};
+ const countProjectIdentitiesByKindFor = async (projectType: ProjectType, orgId: string) => {
+ try {
+ return await countProjectIdentitiesByKind(projectType, orgId);
+ } catch (error) {
+ throw new DatabaseError({ error, name: "Count project identities by kind for usage breakdown" });
+ }
+ };
+
+ const getProjectIdentityBreakdown = async (projectType: ProjectType, orgId: string) => {
+ try {
+ return await getProjectIdentityOwnershipBreakdown(projectType, orgId);
+ } catch (error) {
+ throw new DatabaseError({ error, name: "Get project identity breakdown for usage" });
+ }
+ };
+
+ const getInternalCaOrgBreakdown = async (orgId: string): Promise<TOrgUnitCountRow[]> => {
+ try {
+ const rows = (await $internalCas(orgId)
+ .groupBy(`${TableName.Project}.orgId`)
+ .select({ orgId: `${TableName.Project}.orgId` })
+ .count(`${TableName.CertificateAuthority}.id as count`)) as {
+ orgId: string;
+ count: string | number;
+ }[];
+
+ return rows.map((row) => ({ orgId: row.orgId, count: Number(row.count) }));
+ } catch (error) {
+ throw new DatabaseError({ error, name: "Get internal CA breakdown for usage" });
+ }
+ };
+
+ // The meter counts DISTINCT quotaKey across the whole org tree, so one certificate name issued in two
+ // orgs is a single billable unit. Splitting that by org therefore needs each quotaKey attributed to
+ // exactly one of them, else the parts sum past the billed total. The earliest issuance wins (org id
+ // breaks a tie) so the attribution is stable between reads rather than shifting with row order.
+ const getActiveCertificateOrgBreakdown = async (orgId: string): Promise<TCertificateOrgUnitRow[]> => {
+ try {
+ const attributed = $activeQuotaCertificates(orgId)
+ .whereNotNull(`${TableName.Certificate}.quotaKey`)
+ .distinctOn(`${TableName.Certificate}.quotaKey`)
+ .orderBy([
+ { column: `${TableName.Certificate}.quotaKey` },
+ { column: `${TableName.Certificate}.notBefore`, order: "asc" },
+ { column: `${TableName.Project}.orgId`, order: "asc" }
+ ])
+ .select({
+ quotaKey: `${TableName.Certificate}.quotaKey`,
+ orgId: `${TableName.Project}.orgId`,
+ hasWildcard: `${TableName.Certificate}.hasWildcard`
+ });
+
+ const rows = (await db
+ .replicaNode()
+ .from(attributed.as("attributed"))
+ .groupBy("attributed.orgId")
+ .select({ orgId: "attributed.orgId" })
+ .count("* as total")
+ .select(db.raw(`COUNT(*) FILTER (WHERE attributed."hasWildcard") as "wildcard"`))) as {
+ orgId: string;
+ total: string | number;
+ wildcard: string | number;
+ }[];
+
+ return rows.map((row) => ({
+ orgId: row.orgId,
+ count: Number(row.total),
+ wildcard: Number(row.wildcard)
+ }));
+ } catch (error) {
+ throw new DatabaseError({ error, name: "Get active certificate breakdown for usage" });
+ const countAgentVaultIdentities = async (orgId?: string): Promise<number> => {
+ try {
+ return await countProjectIdentities(ProjectType.AgentVault, orgId);
+ } catch (error) {
+ throw new DatabaseError({ error, name: "Count Agent Vault identities for usage" });
}
};
@@@ -399,9 -268,6 +404,10 @@@
countPamResources,
countSecretManagementIdentities,
countPamIdentities,
+ countProjectIdentitiesByKindFor,
+ getProjectIdentityBreakdown,
+ getInternalCaOrgBreakdown,
- getActiveCertificateOrgBreakdown
++ getActiveCertificateOrgBreakdown,
+ countAgentVaultIdentities
};
};
diff --cc backend/src/services/license-client/usage/usage-counters.ts
index baa60cb145,fa3c67cf7e..94e6bc0be3
--- a/backend/src/services/license-client/usage/usage-counters.ts
+++ b/backend/src/services/license-client/usage/usage-counters.ts
@@@ -28,12 -31,9 +29,13 @@@ const METERED_FEATURES =
WildcardCerts,
SecretIdentities,
PamIdentities,
+ AgentVaultIdentities,
UserIdentities
-].map((feature) => feature.key);
+] as const;
+
+export type TMeteredDimensionKey = (typeof METERED_FEATURES)[number]["key"];
+
+export const METERED_DIMENSION_KEYS: TMeteredDimensionKey[] = METERED_FEATURES.map((feature) => feature.key);
type TBuildMeteredFeaturesDep = {
licenseDAL: Pick<TLicenseDALFactory, "countOrgUsersAndIdentities" | "countOfOrgMembers">;
diff --cc frontend/src/components/v3/generic/Combobox/Combobox.stories.tsx
index 978c648991,0581f44038..a211740f4b
--- a/frontend/src/components/v3/generic/Combobox/Combobox.stories.tsx
+++ b/frontend/src/components/v3/generic/Combobox/Combobox.stories.tsx
@@@ -1,8 -1,7 +1,9 @@@
-import { createContext, type ReactNode, useContext, useState } from "react";
+import { createContext, type ReactNode, useContext, useEffect, useState } from "react";
import type { Meta, StoryObj } from "@storybook/react-vite";
+ import { expect, userEvent, within } from "storybook/test";
+import { useDebounce } from "@app/hooks";
+
import { Button } from "../Button";
import {
Dialog,
diff --cc frontend/src/components/v3/generic/Combobox/Combobox.tsx
index e3bd1a0d8a,4f3a347230..e2c01b91f2
--- a/frontend/src/components/v3/generic/Combobox/Combobox.tsx
+++ b/frontend/src/components/v3/generic/Combobox/Combobox.tsx
@@@ -16,10 -18,10 +18,12 @@@ type ComboboxSharedProps<TOption> =
getOptionValue: (option: TOption) => string;
getOptionLabel: (option: TOption) => string;
getOptionKeywords?: (option: TOption) => readonly string[];
+ getOptionGroup?: (option: TOption) => string;
isOptionDisabled?: (option: TOption) => boolean;
+ onSearchChange?: (search: string) => void;
+ listFooter?: React.ReactNode;
renderOption?: (option: TOption, state: ComboboxRenderOptionState) => React.ReactNode;
+ renderOptionIndicator?: (option: TOption, state: ComboboxRenderOptionState) => React.ReactNode;
renderValue?: (option: TOption) => React.ReactNode;
clearAriaLabel?: string;
placeholder?: string;
@@@ -128,56 -170,89 +172,93 @@@ const ComboboxList = <TOption,>(
isOptionDisabled,
loadingMessage,
renderOption,
+ renderOptionIndicator,
ariaLabel,
+ isEmpty,
selectedValues,
maxHeight
- }: ComboboxListProps<TOption>) => (
- <>
- <ComboboxPrimitive.List
- aria-label={ariaLabel}
- aria-busy={isLoading || undefined}
- onWheel={(event) => event.stopPropagation()}
- className="thin-scrollbar scroll-py-1 overflow-y-auto overscroll-contain p-1 outline-none"
- style={{ maxHeight }}
- >
- {(option: TOption) => {
- const optionValue = getOptionValue(option);
- const isSelected = selectedValues.has(optionValue);
-
- return (
- <ComboboxPrimitive.Item
- key={optionValue}
- value={option}
- disabled={isOptionDisabled?.(option)}
- className={cn(
- COMBOBOX_ROW_CLASS,
- "relative pr-8 pl-2",
- "data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[highlighted]:bg-foreground/5 data-[highlighted]:text-foreground"
- )}
- >
- <span className="min-w-0 flex-1">
- {renderOption?.(option, { isSelected }) ?? (
- <span className="block truncate">{getOptionLabel(option)}</span>
- )}
- </span>
- <ComboboxPrimitive.ItemIndicator className="absolute right-2 flex size-4 items-center justify-center">
- <CheckIcon className="size-4" />
- </ComboboxPrimitive.ItemIndicator>
- {isSelected && <span className="sr-only">Current selection</span>}
- </ComboboxPrimitive.Item>
- );
- }}
- </ComboboxPrimitive.List>
- <ComboboxPrimitive.Empty className="py-6 text-center text-sm text-muted empty:hidden">
- {isLoading ? loadingMessage : emptyMessage}
- </ComboboxPrimitive.Empty>
- </>
- );
+ }: ComboboxListProps<TOption>) => {
+ const renderItem = (item: ComboboxItem<TOption>) => {
+ const { option } = item;
+ const optionValue = getOptionValue(option);
+ const isSelected = selectedValues.has(optionValue);
+
+ return (
+ <ComboboxPrimitive.Item
+ key={optionValue}
+ value={item}
+ disabled={isOptionDisabled?.(option)}
+ className={cn(
+ COMBOBOX_ROW_CLASS,
+ "relative pl-2",
+ renderOptionIndicator ? "pr-2" : "pr-8",
+ "data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[highlighted]:bg-foreground/5 data-[highlighted]:text-foreground"
+ )}
+ >
+ <span className="min-w-0 flex-1">
+ {renderOption?.(option, { isSelected }) ?? (
+ <span className="block truncate">{getOptionLabel(option)}</span>
+ )}
+ </span>
+ {renderOptionIndicator ? (
+ <span className="ml-2 shrink-0">{renderOptionIndicator(option, { isSelected })}</span>
+ ) : (
+ <ComboboxPrimitive.ItemIndicator className="absolute right-2 flex size-4 items-center justify-center">
+ <CheckIcon className="size-4" />
+ </ComboboxPrimitive.ItemIndicator>
+ )}
+ {isSelected && <span className="sr-only">Current selection</span>}
+ </ComboboxPrimitive.Item>
+ );
+ };
+
+ return (
+ <>
+ <ComboboxPrimitive.List
+ aria-label={ariaLabel}
+ aria-busy={isLoading || undefined}
+ onWheel={(event) => event.stopPropagation()}
+ className={() =>
+ cn(
+ "thin-scrollbar scroll-py-1 overflow-y-auto overscroll-contain p-1 outline-none",
+ (isLoading || isEmpty) && "hidden"
+ )
+ }
+ style={{ maxHeight }}
+ >
+ {getOptionGroup
+ ? (group: ComboboxGroup<TOption>) => (
+ <ComboboxPrimitive.Group key={group.value} items={group.items}>
+ <ComboboxPrimitive.GroupLabel className="px-2 py-1.5 text-xs font-medium text-muted">
+ {group.value}
+ </ComboboxPrimitive.GroupLabel>
+ <ComboboxPrimitive.Collection>{renderItem}</ComboboxPrimitive.Collection>
+ </ComboboxPrimitive.Group>
+ )
+ : renderItem}
+ </ComboboxPrimitive.List>
+ {isLoading ? (
+ <div
+ role="status"
+ className="flex min-h-16 items-center justify-center px-3 py-4 text-sm text-muted"
+ >
+ <span>{loadingMessage}</span>
+ </div>
+ ) : (
+ isEmpty && (
+ <div role="status" className="py-6 text-center text-sm text-muted">
+ {emptyMessage}
+ </div>
+ )
+ )}
+ </>
+ );
+ };
+const ComboboxListFooter = ({ children }: { children: React.ReactNode }) => (
+ <div className="border-t border-border px-3 py-2 text-xs text-muted">{children}</div>
+);
+
type ComboboxSelectAllProps = {
areAllSelected: boolean;
optionCount: number;
@@@ -276,10 -351,10 +357,12 @@@ const SingleCombobox = <TOption,>(
getOptionValue,
getOptionLabel,
getOptionKeywords,
+ getOptionGroup,
isOptionDisabled,
+ onSearchChange,
+ listFooter,
renderOption,
+ renderOptionIndicator,
renderValue,
onClear,
clearAriaLabel = "Clear selection",
@@@ -300,55 -378,92 +386,100 @@@
...inputProps
}: ComboboxSingleProps<TOption>) => {
const inputRef = React.useRef<HTMLInputElement | null>(null);
+ const highlightedOptionValueRef = React.useRef<string | null>(null);
const [open, setOpen] = React.useState(false);
+ const selectedLabel = value == null ? "" : getOptionLabel(value);
+ const [search, setSearch] = React.useState("");
const selectedOptions = React.useMemo(() => (value == null ? [] : [value]), [value]);
- const items = useComboboxItems(options, selectedOptions, getOptionValue, !onSearchChange);
- const localFilter = useComboboxFilter({ getOptionKeywords, getOptionLabel });
-
- const filter = onSearchChange ? null : localFilter;
++ // `onSearchChange` hands the query to the caller, so the local matcher must not filter
++ // the page it sends back, and a selection absent from that page is not a match to show.
++ const isLocalFilterEnabled = shouldFilter && !onSearchChange;
+ const items = useComboboxItems(
+ options,
+ selectedOptions,
+ getOptionValue,
- includeMissingSelectedOptions
++ includeMissingSelectedOptions && !onSearchChange
+ );
+ const { itemsByValue, rootItems } = usePrimitiveComboboxItems(
+ items,
+ getOptionValue,
+ getOptionGroup
+ );
+ const selectedItem =
+ value == null ? null : (itemsByValue.get(getOptionValue(value)) ?? { option: value });
+ const filter = useComboboxFilter({ getOptionKeywords, getOptionLabel });
+ const primitiveFilter = React.useCallback(
+ (item: ComboboxItem<TOption>, query: string) => filter(item.option, query),
+ [filter]
+ );
+ const visibleOptions = React.useMemo(
- () => items.filter((option) => !shouldFilter || filter(option, search)),
- [filter, items, search, shouldFilter]
++ () => items.filter((option) => !isLocalFilterEnabled || filter(option, search)),
++ [filter, isLocalFilterEnabled, items, search]
+ );
+ const selectableOptions = React.useMemo(
+ () => visibleOptions.filter((option) => !isOptionDisabled?.(option)),
+ [isOptionDisabled, visibleOptions]
+ );
const selectedValues = React.useMemo(
() => new Set(value == null ? [] : [getOptionValue(value)]),
[getOptionValue, value]
);
-
- const stableValueRef = React.useRef<TOption | null>(null);
- if (value == null) {
- stableValueRef.current = null;
- } else if (
- stableValueRef.current == null ||
- getOptionValue(stableValueRef.current) !== getOptionValue(value)
- ) {
- stableValueRef.current = value;
- }
- const selectedValue = onSearchChange ? stableValueRef.current : (value ?? null);
++ const updateSearch = (nextSearch: string) => {
++ setSearch(nextSearch);
++ onSearchChange?.(nextSearch);
++ onInputValueChange?.(nextSearch);
++ };
return (
- <ComboboxPrimitive.Root<TOption, false>
- items={items}
- value={selectedValue}
+ <ComboboxPrimitive.Root<ComboboxItem<TOption>, false>
+ items={rootItems}
+ value={selectedItem}
onValueChange={(nextValue, eventDetails) => {
if (nextValue == null) {
- if (eventDetails.reason === "clear-press") onClear?.();
+ if (eventDetails.reason === "clear-press") {
- setSearch("");
++ updateSearch("");
+ onClear?.();
+ }
return;
}
- onValueChange(nextValue);
+ onValueChange(nextValue.option);
}}
open={open}
- onOpenChange={setOpen}
- onInputValueChange={(nextSearch, eventDetails) => {
+ onOpenChange={(nextOpen, eventDetails) => {
+ setOpen(nextOpen);
+ if (nextOpen) {
+ // Clicking into a selected combobox starts from its current label. When
+ // typing itself opens the popup, preserve the query emitted just before
+ // this event instead of replacing the user's first keystroke. Consumers
+ // that search server-side never receive the seeded label (it would be
+ // sent as a query and match nothing), so their input must stay in step
+ // with the empty query the parent still holds.
- if (eventDetails.reason !== "input-change") setSearch(shouldFilter ? selectedLabel : "");
++ if (eventDetails.reason !== "input-change") {
++ setSearch(isLocalFilterEnabled ? selectedLabel : "");
++ }
+ } else {
+ highlightedOptionValueRef.current = null;
- setSearch("");
- onInputValueChange?.("");
++ updateSearch("");
+ }
+ }}
+ onItemHighlighted={(item) => {
+ highlightedOptionValueRef.current = item ? getOptionValue(item.option) : null;
+ }}
+ inputValue={open ? search : selectedLabel}
+ onInputValueChange={(nextValue, eventDetails) => {
if (eventDetails.reason === "input-change" || eventDetails.reason === "input-clear") {
- onSearchChange?.(nextSearch);
- setSearch(nextValue);
- onInputValueChange?.(nextValue);
++ updateSearch(nextValue);
}
}}
- itemToStringLabel={getOptionLabel}
- itemToStringValue={getOptionValue}
+ itemToStringLabel={(item) => getOptionLabel(item.option)}
+ itemToStringValue={(item) => getOptionValue(item.option)}
isItemEqualToValue={(option, selectedOption) =>
- getOptionValue(option) === getOptionValue(selectedOption)
+ getOptionValue(option.option) === getOptionValue(selectedOption.option)
}
- filter={filter}
- filter={shouldFilter ? primitiveFilter : null}
++ filter={isLocalFilterEnabled ? primitiveFilter : null}
disabled={isDisabled}
modal={modal}
- autoHighlight
+ autoHighlight={!onSearchChange}
>
<div className="relative w-full">
<ComboboxPrimitive.Input
@@@ -361,6 -476,24 +492,23 @@@
placeholder={open ? searchPlaceholder : placeholder}
onKeyDown={(event) => {
onKeyDown?.(event);
+
+ const hasHighlightedOption = selectableOptions.some(
+ (option) => getOptionValue(option) === highlightedOptionValueRef.current
+ );
+ if (
+ !event.defaultPrevented &&
+ event.key === "Enter" &&
+ open &&
+ !isLoading &&
+ !hasHighlightedOption &&
+ selectableOptions[0]
+ ) {
+ onValueChange(selectableOptions[0]);
+ setOpen(false);
- setSearch("");
- onInputValueChange?.("");
++ updateSearch("");
+ }
+
preventComboboxFormSubmit(event);
}}
className={cn(
@@@ -442,10 -577,10 +593,12 @@@ const MultipleCombobox = <TOption,>(
getOptionValue,
getOptionLabel,
getOptionKeywords,
+ getOptionGroup,
isOptionDisabled,
+ onSearchChange,
+ listFooter,
renderOption,
+ renderOptionIndicator,
renderValue,
onClear,
clearAriaLabel = "Clear all selections",
@@@ -475,28 -615,39 +633,47 @@@
const [open, setOpen] = React.useState(false);
const [search, setSearch] = React.useState("");
const selectedOptions = React.useMemo(() => [...value], [value]);
- const items = useComboboxItems(options, selectedOptions, getOptionValue, !onSearchChange);
- const localFilter = useComboboxFilter({ getOptionKeywords, getOptionLabel });
- const filter = onSearchChange ? null : localFilter;
++ // `onSearchChange` hands the query to the caller, so the local matcher must not filter
++ // the page it sends back, and a selection absent from that page is not a match to show.
++ const isLocalFilterEnabled = shouldFilter && !onSearchChange;
+ const items = useComboboxItems(
+ options,
+ selectedOptions,
+ getOptionValue,
- includeMissingSelectedOptions
++ includeMissingSelectedOptions && !onSearchChange
+ );
+ const { itemsByValue, rootItems } = usePrimitiveComboboxItems(
+ items,
+ getOptionValue,
+ getOptionGroup
+ );
+ const selectedItems = React.useMemo(
+ () => selectedOptions.map((option) => itemsByValue.get(getOptionValue(option)) ?? { option }),
+ [getOptionValue, itemsByValue, selectedOptions]
+ );
+ const filter = useComboboxFilter({ getOptionKeywords, getOptionLabel });
+ const primitiveFilter = React.useCallback(
+ (item: ComboboxItem<TOption>, query: string) => filter(item.option, query),
+ [filter]
+ );
+ const selectedValues = React.useMemo(
+ () => new Set(value.map(getOptionValue)),
+ [getOptionValue, value]
+ );
+ const updateSearch = (nextSearch: string) => {
+ setSearch(nextSearch);
+ onSearchChange?.(nextSearch);
++ onInputValueChange?.(nextSearch);
+ };
- const selectedValues = React.useMemo(
- () => new Set(value.map(getOptionValue)),
- [getOptionValue, value]
+ const visibleOptions = React.useMemo(
- () => items.filter((option) => !shouldFilter || filter(option, search)),
- [filter, items, search, shouldFilter]
++ () => items.filter((option) => !isLocalFilterEnabled || filter(option, search)),
++ [filter, isLocalFilterEnabled, items, search]
);
- // Select all only covers the options matching the current search, so a filtered
- // list toggles what is on screen instead of the entire option set. Under a caller-owned
- // search the fetched options are already that set.
+ // Select all only covers the visible result set. External-search consumers
+ // provide an already-filtered list, so do not apply the local filter again.
const selectAllOptions = React.useMemo(
- () =>
- isSelectAll
- ? items.filter(
- (option) => !isOptionDisabled?.(option) && (filter == null || filter(option, search))
- )
- : [],
- [filter, isOptionDisabled, isSelectAll, items, search]
+ () => (isSelectAll ? visibleOptions.filter((option) => !isOptionDisabled?.(option)) : []),
+ [isOptionDisabled, isSelectAll, visibleOptions]
);
const areAllOptionsSelected =
selectAllOptions.length > 0 &&
@@@ -538,19 -689,27 +715,25 @@@
open={open}
onOpenChange={(nextOpen) => {
setOpen(nextOpen);
- if (!nextOpen) {
- setSearch("");
- onInputValueChange?.("");
- }
+ if (!nextOpen) updateSearch("");
}}
inputValue={search}
- onInputValueChange={updateSearch}
- itemToStringLabel={getOptionLabel}
- itemToStringValue={getOptionValue}
+ onInputValueChange={(nextValue, eventDetails) => {
+ setSearch(nextValue);
+ if (eventDetails.reason === "input-change" || eventDetails.reason === "input-clear") {
++ onSearchChange?.(nextValue);
+ onInputValueChange?.(nextValue);
+ }
+ }}
+ itemToStringLabel={(item) => getOptionLabel(item.option)}
+ itemToStringValue={(item) => getOptionValue(item.option)}
isItemEqualToValue={(option, selectedOption) =>
- getOptionValue(option) === getOptionValue(selectedOption)
+ getOptionValue(option.option) === getOptionValue(selectedOption.option)
}
- filter={filter}
- filter={shouldFilter ? primitiveFilter : null}
++ filter={isLocalFilterEnabled ? primitiveFilter : null}
disabled={isDisabled}
modal={modal}
- autoHighlight
+ autoHighlight={!onSearchChange}
>
<ComboboxPrimitive.Chips
ref={chipsRef}
diff --cc frontend/src/hooks/api/billingV2/index.tsx
index 3f68b2808d,c13c5d283a..82cbd71b02
--- a/frontend/src/hooks/api/billingV2/index.tsx
+++ b/frontend/src/hooks/api/billingV2/index.tsx
@@@ -9,18 -9,11 +9,19 @@@ export
useRefreshBillingV2Entitlements,
useRemoveBillingV2Product,
useResumeBillingV2Subscription,
- useStartBillingV2Trial
+ useStartBillingV2Trial,
+ useUpgradeBillingV2Product
} from "./mutations";
-export { billingV2Keys, useGetBillingV2Catalog, useGetBillingV2Overview } from "./queries";
+export {
+ billingV2Keys,
+ useGetBillingV2Catalog,
+ useGetBillingV2Organizations,
+ useGetBillingV2Overview,
+ useGetBillingV2UsageBreakdown
+} from "./queries";
export type {
+ BillingV2BreakdownProject,
+ BillingV2BreakdownScope,
BillingV2Cadence,
BillingV2CatalogProduct,
BillingV2CommitmentChange,
@@@ -37,7 -29,8 +38,10 @@@
BillingV2Preview,
BillingV2PreviewLine,
BillingV2SubState,
+ BillingV2Trial,
+ BillingV2TrialOutcome,
BillingV2TrialResult,
- BillingV2UpgradeResult
++ BillingV2UpgradeResult,
+ BillingV2UsageBreakdown
} from "./types";
+export { BillingV2BreakdownDimension } from "./types";
diff --cc frontend/src/pages/organization/BillingV2Page/components/Overview.tsx
index 6db770881a,b0ef69b50c..347740ce0d
--- a/frontend/src/pages/organization/BillingV2Page/components/Overview.tsx
+++ b/frontend/src/pages/organization/BillingV2Page/components/Overview.tsx
@@@ -13,7 -13,7 +13,8 @@@ import { ProductsCard } from "./cards/P
import { ErrorPanel } from "./states/ErrorPanel";
import { OverviewSkeleton } from "./states/OverviewSkeleton";
import { Banner } from "./Banner";
+import { RootOrgFilter } from "./RootOrgFilter";
+ import { TrialBanners } from "./TrialBanners";
export type OverviewProps = {
overview?: BillingV2Overview;
@@@ -142,9 -129,9 +164,10 @@@ export const Overview = (
readOnly={productsReadOnly}
onManage={onUpgrade}
onSetCommitment={onSetCommitment}
+ onViewBreakdown={onViewBreakdown}
onContact={onContact}
/>
+ {hasBillingHistory && billingSection}
</div>
);
}
@@@ -168,33 -153,24 +189,26 @@@
onManage={onUpgrade}
onContact={onContact}
/> */}
+ <TrialBanners
+ overview={overview}
+ catalog={catalog}
+ readOnly={productsReadOnly}
+ onManage={onUpgrade}
+ onUpdatePayment={onUpdatePayment}
+ onContact={onContact}
+ />
<BillingHeaderCard overview={overview} catalog={catalog} />
+ {orgFilter}
<ProductsCard
overview={overview}
catalog={catalog}
readOnly={productsReadOnly}
onManage={onUpgrade}
onSetCommitment={onSetCommitment}
+ onViewBreakdown={onViewBreakdown}
onContact={onContact}
/>
- {!isManaged && (
- // Payment (cloud-only) + details share a row, keyed off container width (sidebar resizes it).
- <div className="@container">
- <div className={cn("grid gap-4", showPayment && "@3xl:grid-cols-[2fr_3fr]")}>
- {showPayment && (
- <PaymentCard
- overview={overview}
- canManage={canManageBilling}
- onUpdate={onUpdatePayment}
- />
- )}
- <DetailsCard overview={overview} canManage={canManageBilling} onEdit={onEditDetails} />
- </div>
- </div>
- )}
- {showPayment && <InvoicesCard invoices={overview.invoices} />}
+ {billingSection}
</div>
);
};
diff --cc frontend/src/pages/organization/BillingV2Page/components/cards/ProductsCard.tsx
index 2aa459b728,8986f6761d..01b39a2ec7
--- a/frontend/src/pages/organization/BillingV2Page/components/cards/ProductsCard.tsx
+++ b/frontend/src/pages/organization/BillingV2Page/components/cards/ProductsCard.tsx
@@@ -1,5 -1,5 +1,5 @@@
import { CSSProperties, ReactNode } from "react";
- import { ChevronRight, DollarSign, Package, RefreshCw } from "lucide-react";
-import { Clock, DollarSign, Package, RefreshCw } from "lucide-react";
++import { ChevronRight, Clock, DollarSign, Package, RefreshCw } from "lucide-react";
import { createNotification } from "@app/components/notifications";
import {