Skip to content

Commit 4b2ee04

Browse files
authored
Merge pull request #2233 from appwrite/feat-SER-65-Adding-clear-steps-for-downgrading
2 parents 95a8e69 + 899bdbf commit 4b2ee04

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

src/lib/components/billing/planSelection.svelte

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import { LabelCard } from '..';
88
99
export let billingPlan: Tier;
10-
export let anyOrgFree = false;
1110
export let isNewOrg = false;
11+
export let anyOrgFree = false;
1212
export let selfService = true;
1313
1414
$: freePlan = $plansInfo.get(BillingPlan.FREE);
@@ -22,12 +22,9 @@
2222
<LabelCard
2323
name="plan"
2424
bind:group={billingPlan}
25-
disabled={anyOrgFree || !selfService}
25+
disabled={!selfService}
2626
value={BillingPlan.FREE}
27-
title={tierFree.name}
28-
tooltipShow={anyOrgFree}
29-
tooltipText="You are limited to 1 Free organization per account."
30-
tooltipWidth="100%">
27+
title={tierFree.name}>
3128
<svelte:fragment slot="action">
3229
{#if $organization?.billingPlan === BillingPlan.FREE && !isNewOrg}
3330
<Badge variant="secondary" size="xs" content="Current plan" />

src/routes/(console)/organization-[organization]/change-plan/+page.svelte

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@
150150
await goto(previousPage);
151151
addNotification({
152152
type: 'success',
153-
isHtml: true,
154-
message: `<b>${$organization.name}</b> plan has been successfully updated.`
153+
message: `${$organization.name} plan has been successfully updated.`
155154
});
156155
157156
trackEvent(Submit.OrganizationDowngrade, {
@@ -264,7 +263,9 @@
264263
265264
$: isUpgrade = $plansInfo.get(selectedPlan).order > $currentPlan?.order;
266265
$: isDowngrade = $plansInfo.get(selectedPlan).order < $currentPlan?.order;
267-
$: isButtonDisabled = $organization?.billingPlan === selectedPlan;
266+
$: isButtonDisabled =
267+
$organization?.billingPlan === selectedPlan ||
268+
(isDowngrade && selectedPlan === BillingPlan.FREE && data.hasFreeOrgs);
268269
</script>
269270

270271
<svelte:head>
@@ -297,8 +298,21 @@
297298
selfService={data.selfService}
298299
anyOrgFree={data.hasFreeOrgs} />
299300

301+
{#if isDowngrade && selectedPlan === BillingPlan.FREE && data.hasFreeOrgs}
302+
<Alert.Inline
303+
status="warning"
304+
title="You can only have one free organization per account">
305+
To downgrade this organization, first migrate or delete one of your
306+
existing paid organizations.
307+
<Button
308+
compact
309+
href="https://appwrite.io/docs/advanced/migrations/cloud"
310+
>Migration guide</Button>
311+
</Alert.Inline>
312+
{/if}
313+
300314
{#if isDowngrade}
301-
{#if selectedPlan === BillingPlan.FREE}
315+
{#if selectedPlan === BillingPlan.FREE && !data.hasFreeOrgs}
302316
<PlanExcess tier={BillingPlan.FREE} />
303317
{:else if selectedPlan === BillingPlan.PRO && data.organization.billingPlan === BillingPlan.SCALE && collaborators?.length > 0}
304318
{@const extraMembers = collaborators?.length ?? 0}
@@ -364,7 +378,7 @@
364378
id="members" />
365379
</Fieldset>
366380
{/if}
367-
{#if isDowngrade && selectedPlan === BillingPlan.FREE}
381+
{#if isDowngrade && selectedPlan === BillingPlan.FREE && !data.hasFreeOrgs}
368382
<Fieldset legend="Feedback">
369383
<Layout.Stack gap="xl">
370384
<InputSelect
@@ -395,7 +409,7 @@
395409
bind:billingBudget
396410
organizationId={data.organization.$id} />
397411
{:else if data.organization.billingPlan !== BillingPlan.CUSTOM}
398-
<PlanComparisonBox downgrade={isDowngrade} />
412+
<PlanComparisonBox downgrade={data.hasFreeOrgs ? false : isDowngrade} />
399413
{/if}
400414
</svelte:fragment>
401415
<svelte:fragment slot="footer">

0 commit comments

Comments
 (0)