Skip to content

Commit

Permalink
fix: issues with managed plan and sub/trial ended handing revert (#6178)
Browse files Browse the repository at this point in the history
* Enable billing page for no sub scenario

* Fix issues with managed plan
  • Loading branch information
AdityaHegde committed Nov 27, 2024
1 parent 9e3e90d commit f77a23f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
7 changes: 5 additions & 2 deletions web-admin/src/features/billing/Payment.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(
Expand All @@ -31,7 +34,7 @@
</script>

<!-- Presence of paymentCustomerId signifies that the org's payment is managed through stripe -->
{#if !$categorisedIssues.isLoading && !neverSubscribed && $org.data?.organization?.paymentCustomerId && !onTrial && !onEnterprisePlan}
{#if !$categorisedIssues.isLoading && $org.data?.organization?.paymentCustomerId && !hidePaymentModule}
<SettingsContainer title="Payment Method">
<div slot="body" class="flex flex-row items-center gap-x-1">
{#if paymentIssues?.length}
Expand Down
12 changes: 7 additions & 5 deletions web-admin/src/features/billing/plans/POCPlan.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@
<span>To make changes to your contract,</span>
<ContactUs variant="enterprise" />
</svelte:fragment>
{#if hasPayment}
<Button type="primary" slot="action" on:click={() => (open = true)}>
Start Team plan
</Button>
{/if}
<svelte:fragment slot="action">
{#if hasPayment}
<Button type="primary" on:click={() => (open = true)}>
Start Team plan
</Button>
{/if}
</svelte:fragment>
</SettingsContainer>

<StartTeamPlanDialog bind:open {organization} type="base" />
9 changes: 5 additions & 4 deletions web-admin/src/features/billing/plans/Plan.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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;
</script>

{#if neverSubbed}
Expand All @@ -40,7 +41,7 @@
<CancelledTeamPlan {organization} {showUpgradeDialog} {plan} />
{:else if subIsTeamPlan}
<TeamPlan {organization} {subscription} {plan} />
{:else if subIsPOCPlan}
{:else if subIsManagedPlan}
<POCPlan {organization} {hasPayment} {plan} />
{:else if subIsEnterprisePlan}
<EnterprisePlan {organization} {plan} />
Expand Down
4 changes: 2 additions & 2 deletions web-admin/src/features/billing/plans/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
$: basePage = `/${organization}/-/settings`;
$: onEnterprisePlan =
subscription?.plan && isEnterprisePlan(subscription?.plan);
$: hideBillingSettings = neverSubscribed || !subscription;
$: hideBillingSettings = neverSubscribed;
$: navItems = [
{ label: "General", route: "" },
Expand Down

2 comments on commit f77a23f

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 Published on https://ui.rilldata.com as production
🚀 Deployed on https://6746dd5bebd874cd293ec267--rill-ui.netlify.app

Please sign in to comment.