Skip to content

Commit b750dc0

Browse files
Merge pull request #2600 from appwrite/feat-profiles-org-platform
2 parents 39e37f0 + 285b2df commit b750dc0

50 files changed

Lines changed: 165 additions & 111 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
"dependencies": {
2424
"@ai-sdk/svelte": "^1.1.24",
25-
"@appwrite.io/console": "https://pkg.pr.new/appwrite-labs/cloud/@appwrite.io/console@2752",
25+
"@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@5ce6dc7",
2626
"@appwrite.io/pink-icons": "0.25.0",
2727
"@appwrite.io/pink-icons-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-icons-svelte@4472521",
2828
"@appwrite.io/pink-legacy": "^1.0.3",

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/components/archiveProject.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import { getPlatformInfo } from '$lib/helpers/platform';
3030
import { Status, type Models } from '@appwrite.io/console';
3131
import type { ComponentType } from 'svelte';
32-
import { BillingPlan } from '$lib/constants';
3332
import { goto } from '$app/navigation';
3433
import { base } from '$app/paths';
3534
import { sdk } from '$lib/stores/sdk';
@@ -97,7 +96,7 @@
9796
function isUnarchiveDisabled(): boolean {
9897
if (!organization || !currentPlan) return true;
9998
100-
if (organization.billingPlan === BillingPlan.FREE) {
99+
if (isFreePlan(organization.billingPlan)) {
101100
const currentProjectCount = organization.projects?.length || 0;
102101
const projectLimit = currentPlan.projects || 0;
103102
@@ -189,6 +188,7 @@
189188
}
190189
191190
import { formatName as formatNameHelper } from '$lib/helpers/string';
191+
import { isFreePlan } from '$lib/helpers/billing';
192192
function formatName(name: string, limit: number = 19) {
193193
return formatNameHelper(name, limit, $isSmallViewport);
194194
}

src/lib/components/backupDatabaseAlert.svelte

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<script lang="ts">
22
import { page } from '$app/state';
3-
import { BillingPlan } from '$lib/constants';
43
import { Button } from '$lib/elements/forms';
54
import { organization } from '$lib/stores/organization';
65
import { HeaderAlert } from '$lib/layout';
@@ -10,6 +9,7 @@
109
import { backupsBannerId, showPolicyAlert } from '$lib/stores/database';
1110
import { IconX } from '@appwrite.io/pink-icons-svelte';
1211
import { Icon } from '@appwrite.io/pink-svelte';
12+
import { isFreePlan } from '$lib/helpers/billing';
1313
1414
function handleClose() {
1515
showPolicyAlert.set(false);
@@ -18,14 +18,14 @@
1818
</script>
1919

2020
{#if $showPolicyAlert && isCloud && $organization?.$id && page.url.pathname.match(/\/databases\/database-[^/]+$/)}
21-
{@const isFreePlan = $organization?.billingPlan === BillingPlan.FREE}
21+
{@const isFree = isFreePlan($organization?.billingPlan)}
2222

23-
{@const subtitle = isFreePlan
23+
{@const subtitle = isFree
2424
? 'Upgrade your plan to ensure your data stays safe and backed up'
2525
: 'Protect your data by quickly adding a backup policy'}
2626

27-
{@const ctaText = isFreePlan ? 'Upgrade plan' : 'Create policy'}
28-
{@const ctaURL = isFreePlan ? $upgradeURL : `${page.url.pathname}/backups`}
27+
{@const ctaText = isFree ? 'Upgrade plan' : 'Create policy'}
28+
{@const ctaURL = isFree ? $upgradeURL : `${page.url.pathname}/backups`}
2929

3030
<HeaderAlert type="warning" title="Your database has no backup policy">
3131
<svelte:fragment>{subtitle}</svelte:fragment>
@@ -35,7 +35,7 @@
3535
href={ctaURL}
3636
secondary
3737
fullWidthMobile
38-
event={isFreePlan ? 'backup_banner_upgrade' : 'backup_banner_add'}>
38+
event={isFree ? 'backup_banner_upgrade' : 'backup_banner_add'}>
3939
<span class="text">{ctaText}</span>
4040
</Button>
4141

src/lib/components/backupRestoreBox.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { onMount } from 'svelte';
55
import { isCloud, isSelfHosted } from '$lib/system';
66
import { organization } from '$lib/stores/organization';
7-
import { BillingPlan, Dependencies } from '$lib/constants';
7+
import { Dependencies } from '$lib/constants';
88
import type { BackupArchive, BackupRestoration } from '$lib/sdk/backups';
99
import { goto, invalidate } from '$app/navigation';
1010
import { page } from '$app/state';
@@ -13,6 +13,7 @@
1313
import { getProjectId } from '$lib/helpers/project';
1414
import { toLocaleDate } from '$lib/helpers/date';
1515
import { Typography } from '@appwrite.io/pink-svelte';
16+
import { isFreePlan } from '$lib/helpers/billing';
1617
1718
const backupRestoreItems: {
1819
archives: Map<string, BackupArchive>;
@@ -125,7 +126,7 @@
125126
126127
onMount(() => {
127128
// fast path: don't subscribe if org is on a free plan or is self-hosted.
128-
if (isSelfHosted || (isCloud && $organization?.billingPlan === BillingPlan.FREE)) return;
129+
if (isSelfHosted || (isCloud && isFreePlan($organization?.billingPlan))) return;
129130
130131
return realtime.forProject(page.params.region, 'console', (response) => {
131132
if (!response.channels.includes(`projects.${getProjectId()}`)) return;

src/lib/components/billing/alerts/limitReached.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
import { base } from '$app/paths';
33
import { page } from '$app/state';
44
import { Click, trackEvent } from '$lib/actions/analytics';
5-
import { BillingPlan } from '$lib/constants';
65
import { Button } from '$lib/elements/forms';
6+
import { isFreePlan } from '$lib/helpers/billing';
77
import { HeaderAlert } from '$lib/layout';
88
import { hideBillingHeaderRoutes, readOnly, tierToPlan, upgradeURL } from '$lib/stores/billing';
99
import { organization } from '$lib/stores/organization';
1010
</script>
1111

12-
{#if $organization?.$id && $organization?.billingPlan === BillingPlan.FREE && $readOnly && !hideBillingHeaderRoutes.includes(page.url.pathname)}
12+
{#if $organization?.$id && isFreePlan($organization?.billingPlan) && $readOnly && !hideBillingHeaderRoutes.includes(page.url.pathname)}
1313
<HeaderAlert
1414
type="error"
1515
title={`${$organization.name} usage has reached the ${tierToPlan($organization.billingPlan).name} plan limit`}>

src/lib/components/billing/alerts/newDevUpgradePro.svelte

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
import { base } from '$app/paths';
33
import { page } from '$app/state';
44
import { Click, trackEvent } from '$lib/actions/analytics';
5-
import { BillingPlan, NEW_DEV_PRO_UPGRADE_COUPON } from '$lib/constants';
5+
import { NEW_DEV_PRO_UPGRADE_COUPON } from '$lib/constants';
66
import { Button } from '$lib/elements/forms';
77
import { organization } from '$lib/stores/organization';
88
import { activeHeaderAlert } from '$routes/(console)/store';
99
import GradientBanner from '../gradientBanner.svelte';
1010
import { isSmallViewport } from '$lib/stores/viewport';
1111
import { Layout, Typography } from '@appwrite.io/pink-svelte';
1212
import { resolvedProfile } from '$lib/profiles/index.svelte';
13+
import { isFreePlan } from '$lib/helpers/billing';
1314
1415
let show = true;
1516
@@ -24,7 +25,7 @@
2425
}
2526
</script>
2627

27-
{#if show && $organization?.$id && $organization?.billingPlan === BillingPlan.FREE && !page.url.pathname.includes(base + '/account')}
28+
{#if show && $organization?.$id && isFreePlan($organization?.billingPlan) && !page.url.pathname.includes(base + '/account')}
2829
<GradientBanner on:close={handleClose}>
2930
<Layout.Stack
3031
gap="m"

src/lib/components/billing/usageRates.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { abbreviateNumber, formatCurrency, isWithinSafeRange } from '$lib/helpers/numbers';
88
import { BillingPlan } from '$lib/constants';
99
import { Table, Typography } from '@appwrite.io/pink-svelte';
10+
import { isFreePlan } from '$lib/helpers/billing';
1011
1112
export let show = false;
1213
export let org: Organization;
@@ -17,7 +18,7 @@
1718
? new Date(new Date().getFullYear(), new Date().getMonth() + 1, 1).toString()
1819
: org?.billingNextInvoiceDate;
1920
20-
$: isFree = org.billingPlan === BillingPlan.FREE;
21+
$: isFree = isFreePlan(org.billingPlan);
2122
2223
// equal or above means unlimited!
2324
const getCorrectSeatsCountValue = (count: number): string | number => {

src/lib/components/roles/upgrade.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
import { upgradeURL } from '$lib/stores/billing';
44
import { isCloud } from '$lib/system';
55
import { organization } from '$lib/stores/organization';
6-
import { BillingPlan } from '$lib/constants';
76
import Button from '$lib/elements/forms/button.svelte';
87
import { Badge, Layout, Link, Typography } from '@appwrite.io/pink-svelte';
8+
import { isFreePlan } from '$lib/helpers/billing';
99
</script>
1010

1111
<Base>
1212
<Layout.Stack gap="s">
1313
{#if isCloud}
14-
{#if $organization?.billingPlan !== BillingPlan.FREE}
14+
{#if !isFreePlan($organization?.billingPlan)}
1515
<Typography.Text variant="m-600">Roles</Typography.Text>
1616
<Typography.Text>Owner, Developer, Editor, Analyst and Billing.</Typography.Text>
1717
<Typography.Text>

src/lib/helpers/billing.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { BillingPlan } from '@appwrite.io/console';
2+
3+
export function isFreePlan(plan: BillingPlan | string): boolean {
4+
switch (plan) {
5+
case BillingPlan.Imaginebasic:
6+
case BillingPlan.Tier0:
7+
return true;
8+
default:
9+
return false;
10+
}
11+
}

0 commit comments

Comments
 (0)