mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
fix: plan limit tag shown for users, upgrade flow wrong step, upgrade flow invited member
This commit is contained in:
@@ -183,18 +183,23 @@ export function checkForTrialEnding(org: Organization) {
|
||||
}
|
||||
}
|
||||
|
||||
export function checkForUsageLimit(org: Organization) {
|
||||
export async function checkForUsageLimit(org: Organization) {
|
||||
if (!org?.billingLimits) {
|
||||
readOnly.set(false);
|
||||
return;
|
||||
}
|
||||
const { bandwidth, documents, executions, storage, users } = org.billingLimits;
|
||||
const members = await sdk.forConsole.teams.listMemberships(org.$id);
|
||||
const plan = get(plansInfo).plans.find((plan) => plan.$id === org.billingPlan);
|
||||
const membersOverflow =
|
||||
members?.total > plan.members ? members.total - (plan.members || Infinity) : 0;
|
||||
if (
|
||||
bandwidth >= 100 ||
|
||||
documents >= 100 ||
|
||||
executions >= 100 ||
|
||||
storage >= 100 ||
|
||||
users >= 100
|
||||
users >= 100 ||
|
||||
membersOverflow > 0
|
||||
) {
|
||||
readOnly.set(true);
|
||||
} else readOnly.set(false);
|
||||
|
||||
@@ -284,7 +284,7 @@
|
||||
calculateTrialDay(org);
|
||||
checkForTrialEnding(org);
|
||||
await paymentExpired(org);
|
||||
checkForUsageLimit(org);
|
||||
await checkForUsageLimit(org);
|
||||
checkForMarkedForDeletion(org);
|
||||
await checkPaymentAuthorizationRequired(org);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,6 @@
|
||||
wizard.hide();
|
||||
|
||||
trackEvent(Submit.OrganizationDowngrade, {
|
||||
customId: !!$changeOrganizationTier.id,
|
||||
plan: tierToPlan($changeOrganizationTier.billingPlan)?.name
|
||||
});
|
||||
} catch (e) {
|
||||
@@ -144,7 +143,6 @@
|
||||
});
|
||||
}
|
||||
trackEvent($isUpgrade ? Submit.OrganizationUpgrade : Submit.OrganizationDowngrade, {
|
||||
customId: !!$changeOrganizationTier.id,
|
||||
plan: tierToPlan($changeOrganizationTier.billingPlan)?.name
|
||||
});
|
||||
wizard.hide();
|
||||
@@ -164,7 +162,6 @@
|
||||
|
||||
onDestroy(() => {
|
||||
$changeOrganizationTier = {
|
||||
id: null,
|
||||
billingPlan: 'tier-1',
|
||||
paymentMethodId: null,
|
||||
collaborators: [],
|
||||
|
||||
@@ -57,11 +57,12 @@
|
||||
members: members.total > plan.members ? members.total - (plan.members || Infinity) : 0
|
||||
};
|
||||
if (
|
||||
$changeOrganizationTier.limitOverflow.bandwidth > 0 ||
|
||||
$changeOrganizationTier.limitOverflow.storage > 0 ||
|
||||
$changeOrganizationTier.limitOverflow.users > 0 ||
|
||||
$changeOrganizationTier.limitOverflow.executions > 0 ||
|
||||
$changeOrganizationTier.limitOverflow.members > 0
|
||||
($changeOrganizationTier.limitOverflow.bandwidth > 0 ||
|
||||
$changeOrganizationTier.limitOverflow.storage > 0 ||
|
||||
$changeOrganizationTier.limitOverflow.users > 0 ||
|
||||
$changeOrganizationTier.limitOverflow.executions > 0 ||
|
||||
$changeOrganizationTier.limitOverflow.members > 0) &&
|
||||
$changeOrganizationTier.billingPlan === 'tier-0'
|
||||
) {
|
||||
$changeOrganizationTier.isOverLimit = true;
|
||||
$changeTierSteps = updateStepStatus($changeTierSteps, 5, false);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { Box, CreditCardBrandImage } from '$lib/components';
|
||||
import { CouponInput } from '$lib/components/billing';
|
||||
import { Pill } from '$lib/elements';
|
||||
import { FormList, InputTextarea } from '$lib/elements/forms';
|
||||
import { toLocaleDate } from '$lib/helpers/date';
|
||||
import { WizardStep } from '$lib/layout';
|
||||
@@ -72,9 +71,6 @@
|
||||
<p class="body-text-1 u-bold">Organization name</p>
|
||||
<div class="u-flex u-gap-8 u-cross-center u-margin-block-start-8">
|
||||
<p class="text">{$organization.name}</p>
|
||||
{#if $changeOrganizationTier?.id}
|
||||
<Pill>{$changeOrganizationTier.id}</Pill>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{#if $changeOrganizationTier.billingPlan !== 'tier-0'}
|
||||
|
||||
@@ -16,13 +16,14 @@
|
||||
import { changeOrganizationTier } from './store';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { user } from '$lib/stores/user';
|
||||
import { organization } from '$lib/stores/organization';
|
||||
|
||||
const plan = $plansInfo.plans.find((p) => p.$id === $changeOrganizationTier.billingPlan);
|
||||
|
||||
let email: string;
|
||||
|
||||
onMount(async () => {
|
||||
const members = await sdk.forConsole.teams.listMemberships($changeOrganizationTier.id);
|
||||
const members = await sdk.forConsole.teams.listMemberships($organization.$id);
|
||||
if (members.total) {
|
||||
$changeOrganizationTier.collaborators = members.memberships
|
||||
.map((m) => {
|
||||
|
||||
@@ -59,12 +59,14 @@
|
||||
{#if currentTier === 'tier-0'}
|
||||
<Button
|
||||
text
|
||||
external
|
||||
href="https://appwrite.io/docs/advanced/platform/starter#reaching-resource-limits">
|
||||
Learn more
|
||||
</Button>
|
||||
{:else if currentTier === 'tier-1'}
|
||||
<Button
|
||||
text
|
||||
external
|
||||
href="https://appwrite.io/docs/advanced/platform/pro#reaching-resource-limits">
|
||||
Learn more
|
||||
</Button>
|
||||
|
||||
@@ -7,7 +7,6 @@ export const isUpgrade = writable<boolean>(false);
|
||||
export const changeOrganizationFinalAction = writable<string>('Start trial');
|
||||
|
||||
export const changeOrganizationTier = writable<{
|
||||
id?: string;
|
||||
billingPlan: Tier;
|
||||
paymentMethodId: string;
|
||||
billingAddressId: string;
|
||||
@@ -25,7 +24,6 @@ export const changeOrganizationTier = writable<{
|
||||
feedbackMessage?: string;
|
||||
couponCode?: string;
|
||||
}>({
|
||||
id: null,
|
||||
billingPlan: 'tier-1',
|
||||
paymentMethodId: null,
|
||||
collaborators: [],
|
||||
|
||||
Reference in New Issue
Block a user