From f77a23fb7f9066b0a47925dd7108ccaf9b1081e6 Mon Sep 17 00:00:00 2001 From: Aditya Hegde Date: Wed, 27 Nov 2024 13:40:53 +0530 Subject: [PATCH] fix: issues with managed plan and sub/trial ended handing revert (#6178) * Enable billing page for no sub scenario * Fix issues with managed plan --- web-admin/src/features/billing/Payment.svelte | 7 +++++-- web-admin/src/features/billing/plans/POCPlan.svelte | 12 +++++++----- web-admin/src/features/billing/plans/Plan.svelte | 9 +++++---- web-admin/src/features/billing/plans/utils.ts | 4 ++-- .../routes/[organization]/-/settings/+layout.svelte | 2 +- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/web-admin/src/features/billing/Payment.svelte b/web-admin/src/features/billing/Payment.svelte index 884d39e4b29..f4eebca1ff8 100644 --- a/web-admin/src/features/billing/Payment.svelte +++ b/web-admin/src/features/billing/Payment.svelte @@ -9,7 +9,7 @@ import SettingsContainer from "@rilldata/web-admin/features/organizations/settings/SettingsContainer.svelte"; import { Button } from "@rilldata/web-common/components/button"; import CancelCircle from "@rilldata/web-common/components/icons/CancelCircle.svelte"; - import { isEnterprisePlan } from "./plans/utils"; + import { isEnterprisePlan, isManagedPlan } from "./plans/utils"; export let organization: string; export let subscription: V1Subscription; @@ -21,6 +21,9 @@ $: onTrial = !!$categorisedIssues.data?.trial; $: onEnterprisePlan = subscription?.plan && isEnterprisePlan(subscription.plan); + $: onManagedPlan = subscription?.plan && isManagedPlan(subscription.plan); + $: hidePaymentModule = + neverSubscribed || onTrial || onEnterprisePlan || onManagedPlan; async function handleManagePayment() { window.open( @@ -31,7 +34,7 @@ -{#if !$categorisedIssues.isLoading && !neverSubscribed && $org.data?.organization?.paymentCustomerId && !onTrial && !onEnterprisePlan} +{#if !$categorisedIssues.isLoading && $org.data?.organization?.paymentCustomerId && !hidePaymentModule}
{#if paymentIssues?.length} diff --git a/web-admin/src/features/billing/plans/POCPlan.svelte b/web-admin/src/features/billing/plans/POCPlan.svelte index d359ad0baab..01c40bf272b 100644 --- a/web-admin/src/features/billing/plans/POCPlan.svelte +++ b/web-admin/src/features/billing/plans/POCPlan.svelte @@ -22,11 +22,13 @@ To make changes to your contract, - {#if hasPayment} - - {/if} + + {#if hasPayment} + + {/if} + diff --git a/web-admin/src/features/billing/plans/Plan.svelte b/web-admin/src/features/billing/plans/Plan.svelte index 048f517b7fe..fe3b3638308 100644 --- a/web-admin/src/features/billing/plans/Plan.svelte +++ b/web-admin/src/features/billing/plans/Plan.svelte @@ -6,7 +6,7 @@ import TeamPlan from "@rilldata/web-admin/features/billing/plans/TeamPlan.svelte"; import TrialPlan from "@rilldata/web-admin/features/billing/plans/TrialPlan.svelte"; import { - isPOCPlan, + isManagedPlan, isTeamPlan, } from "@rilldata/web-admin/features/billing/plans/utils"; import { useCategorisedOrganizationBillingIssues } from "@rilldata/web-admin/features/billing/selectors"; @@ -28,8 +28,9 @@ // ended subscription will have a cancelled issue associated with it $: subHasEnded = !!$categorisedIssues.data?.cancelled; $: subIsTeamPlan = plan && isTeamPlan(plan); - $: subIsPOCPlan = plan && isPOCPlan(plan); - $: subIsEnterprisePlan = plan && !isTrial && !subIsTeamPlan && !subIsPOCPlan; + $: subIsManagedPlan = plan && isManagedPlan(plan); + $: subIsEnterprisePlan = + plan && !isTrial && !subIsTeamPlan && !subIsManagedPlan; {#if neverSubbed} @@ -40,7 +41,7 @@ {:else if subIsTeamPlan} -{:else if subIsPOCPlan} +{:else if subIsManagedPlan} {:else if subIsEnterprisePlan} diff --git a/web-admin/src/features/billing/plans/utils.ts b/web-admin/src/features/billing/plans/utils.ts index 3c7c1462495..79e11c2d193 100644 --- a/web-admin/src/features/billing/plans/utils.ts +++ b/web-admin/src/features/billing/plans/utils.ts @@ -29,12 +29,12 @@ export function isTeamPlan(plan: V1BillingPlan) { return plan.planType === V1BillingPlanType.BILLING_PLAN_TYPE_TEAM; } -export function isPOCPlan(plan: V1BillingPlan) { +export function isManagedPlan(plan: V1BillingPlan) { return plan.planType === V1BillingPlanType.BILLING_PLAN_TYPE_MANAGED; } export function isEnterprisePlan(plan: V1BillingPlan) { - return !isTrialPlan(plan) && !isTeamPlan(plan) && !isPOCPlan(plan); + return !isTrialPlan(plan) && !isTeamPlan(plan) && !isManagedPlan(plan); } export function getSubscriptionResumedText(endDate: string) { diff --git a/web-admin/src/routes/[organization]/-/settings/+layout.svelte b/web-admin/src/routes/[organization]/-/settings/+layout.svelte index aa35637408a..e18656e9ace 100644 --- a/web-admin/src/routes/[organization]/-/settings/+layout.svelte +++ b/web-admin/src/routes/[organization]/-/settings/+layout.svelte @@ -14,7 +14,7 @@ $: basePage = `/${organization}/-/settings`; $: onEnterprisePlan = subscription?.plan && isEnterprisePlan(subscription?.plan); - $: hideBillingSettings = neverSubscribed || !subscription; + $: hideBillingSettings = neverSubscribed; $: navItems = [ { label: "General", route: "" },