Skip to content

Commit 5b141ec

Browse files
authored
Merge pull request #2631 from appwrite/fix-use-plan-capabilities-for-policy-checks
2 parents ca24b61 + e0d881d commit 5b141ec

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

src/routes/(console)/project-[region]-[project]/databases/create.svelte

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
import { ID } from '@appwrite.io/console';
88
import { createEventDispatcher } from 'svelte';
99
import { isCloud } from '$lib/system';
10-
import { BillingPlan } from '$lib/constants';
11-
import { organization } from '$lib/stores/organization';
10+
import { currentPlan } from '$lib/stores/organization';
1211
import { upgradeURL } from '$lib/stores/billing';
1312
import CreatePolicy from './database-[database]/backups/createPolicy.svelte';
1413
import { cronExpression, type UserBackupPolicy } from '$lib/helpers/backups';
@@ -132,7 +131,7 @@
132131
<CustomId bind:show={showCustomId} name="Database" bind:id autofocus={false} />
133132

134133
{#if isCloud}
135-
{#if $organization?.billingPlan === BillingPlan.FREE}
134+
{#if !$currentPlan?.backupsEnabled}
136135
<Alert.Inline title="This database won't be backed up" status="warning">
137136
Upgrade your plan to ensure your data stays safe and backed up.
138137
<svelte:fragment slot="actions">

src/routes/(console)/project-[region]-[project]/databases/database-[database]/backups/containerHeader.svelte

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
import { Badge, Icon, Layout, Tag, Typography } from '@appwrite.io/pink-svelte';
66
import { goto } from '$app/navigation';
77
import { upgradeURL } from '$lib/stores/billing';
8-
import { BillingPlan } from '$lib/constants';
9-
import { organization } from '$lib/stores/organization';
108
119
export let isFlex = true;
1210
export let title: string;
@@ -50,7 +48,7 @@
5048
paddingBlock="var(--space-5, 12px)"
5149
paddingInline="var(--space-6, 16px)"
5250
resetListPadding>
53-
{#if $organization?.billingPlan === BillingPlan.PRO}
51+
{#if maxPolicies === 1}
5452
<Tag
5553
size="s"
5654
style="white-space: nowrap; max-width: none;"

src/routes/(console)/project-[region]-[project]/databases/database-[database]/backups/createPolicy.svelte

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
type UserBackupPolicy
2121
} from '$lib/helpers/backups';
2222
import { InputNumber } from '$lib/elements/forms/index.js';
23-
import { organization } from '$lib/stores/organization';
24-
import { BillingPlan } from '$lib/constants';
23+
import { currentPlan } from '$lib/stores/organization';
2524
import { Card, Icon, Layout, Link, Tag, Typography } from '@appwrite.io/pink-svelte';
2625
import { IconPencil, IconTrash } from '@appwrite.io/pink-icons-svelte';
2726
import { isSmallViewport } from '$lib/stores/viewport';
@@ -149,7 +148,7 @@
149148
);
150149
151150
// pre-check the hourly if on pro plan
152-
if ($organization.billingPlan === BillingPlan.PRO && isFromBackupsTab) {
151+
if ($currentPlan?.backupPolicies === 1 && isFromBackupsTab) {
153152
presetPolicies.update((all) =>
154153
all.map((policy) => {
155154
policy.id = ID.unique();
@@ -176,7 +175,7 @@
176175
</script>
177176

178177
<div class="u-flex-vertical u-gap-16">
179-
{#if $organization.billingPlan === BillingPlan.SCALE}
178+
{#if $currentPlan?.backupPolicies > 1}
180179
{#if title || subtitle}
181180
<div class="body-text-2">
182181
{#if title}
@@ -195,7 +194,7 @@
195194
{/if}
196195

197196
<!-- because we show a set of pre-defined ones -->
198-
{#if $organization.billingPlan === BillingPlan.PRO}
197+
{#if $currentPlan?.backupPolicies === 1}
199198
{@const dailyPolicy = $presetPolicies[1]}
200199

201200
{#if isFromBackupsTab}

0 commit comments

Comments
 (0)