diff --git a/ui/components/providers/organizations/org-launch-scan.tsx b/ui/components/providers/organizations/org-launch-scan.tsx index 8747d28126..90711033c6 100644 --- a/ui/components/providers/organizations/org-launch-scan.tsx +++ b/ui/components/providers/organizations/org-launch-scan.tsx @@ -23,6 +23,7 @@ import { } from "@/components/shadcn/select/select"; import { Spinner } from "@/components/shadcn/spinner/spinner"; import { TreeStatusIcon } from "@/components/shadcn/tree-view/tree-status-icon"; +import { UsageLimitMessage } from "@/components/shared/usage-limit-message"; import { ToastAction, useToast } from "@/components/ui"; import { getActionErrorMessage, hasActionError } from "@/lib/action-errors"; import { @@ -362,18 +363,7 @@ export function OrgLaunchScan({ )} {isBlocked ? ( -
- You have exceeded the usage limit of one provider. You can add - more providers and run unlimited scans by adding a subscription.{" "} - - Manage Billing - -
+- You have exceeded the usage limit of one provider. You can add more - providers and run unlimited scans by adding a subscription.{" "} - - Manage Billing - -
- )} + {(isLimitBlocked || isBlocked) &&- You have exceeded the usage limit of one provider. You can add more - providers and run unlimited scans by adding a subscription.{" "} - - Manage Billing - -
- )} - {!isScheduleMode && (+ {USAGE_LIMIT_MESSAGE}{" "} + + Manage Billing + +
+); diff --git a/ui/lib/action-errors.test.ts b/ui/lib/action-errors.test.ts index b770f6b7af..5c434dab5b 100644 --- a/ui/lib/action-errors.test.ts +++ b/ui/lib/action-errors.test.ts @@ -22,7 +22,7 @@ describe("getActionErrorMessage", () => { expect(message).toBe(ACTION_ERROR_MESSAGES[ACTION_ERROR_STATUS.FORBIDDEN]); }); - it("should use the default subscription error for payment-required responses", () => { + it("should use the default usage-limit error for payment-required responses", () => { // Given const result = { error: "Payment required.", diff --git a/ui/lib/action-errors.ts b/ui/lib/action-errors.ts index 46fc3ae4b8..bea6dcd8df 100644 --- a/ui/lib/action-errors.ts +++ b/ui/lib/action-errors.ts @@ -6,9 +6,14 @@ export const ACTION_ERROR_STATUS = { export type ActionErrorStatus = (typeof ACTION_ERROR_STATUS)[keyof typeof ACTION_ERROR_STATUS]; +// Shown whenever the API returns 402 for an over-limit (trial-expired) tenant. +// Rendered with a billing link by he `UsageLimitMessage` component, and as +// plain text in toasts/field errors. +export const USAGE_LIMIT_MESSAGE = + "You have exceeded the usage limit of one provider. You can add more providers and run unlimited scans by adding a subscription."; + export const ACTION_ERROR_MESSAGES = { - [ACTION_ERROR_STATUS.PAYMENT_REQUIRED]: - "Your subscription doesn't allow this action. Upgrade your plan or contact an administrator.", + [ACTION_ERROR_STATUS.PAYMENT_REQUIRED]: USAGE_LIMIT_MESSAGE, [ACTION_ERROR_STATUS.FORBIDDEN]: "You don't have permission to perform this action. Ask an administrator to update your role.", } as const satisfies Record