Merge branch 'billing' of https://github.com/appwrite/console into fix-project-usage

This commit is contained in:
Torsten Dittmann committed 2023-12-11 18:13:23 +01:00
commit 869bd7d8be
27 files changed
+385 -246

No files matched your search

+12 -8
View File
@@ -62,14 +62,18 @@
<h4 class="eyebrow-heading-3">Troubleshooting</h4>
<div class="u-margin-block-start-8 u-width-full-line">
<iframe
title="Appwrite Status"
src="https://status.appwrite.online/badge?theme=dark"
width="250"
height="30"
frameborder="0"
scrolling="no">
</iframe>
{#key $app.themeInUse}
<iframe
title="Appwrite Status"
src={`https://status.appwrite.online/badge?theme=${
$app.themeInUse === 'dark' ? 'dark' : 'light'
}`}
width="250"
height="30"
frameborder="0"
scrolling="no">
</iframe>
{/key}
</div>
</div>
+3 -2
View File
@@ -10,8 +10,9 @@
export let github = false;
export let text = false;
export let danger = false;
export let disabled = false;
export let round = false;
export let link = false;
export let disabled = false;
export let external = false;
export let href: string = null;
export let fullWidth = false;
@@ -40,7 +41,7 @@
}
$: resolvedClasses = [
'button',
link ? 'link' : 'button',
disabled && 'is-disabled',
round && 'is-only-icon',
secondary && 'is-secondary',
+77 -45
View File
@@ -4,7 +4,9 @@
getServiceLimit,
type PlanServices,
showUsageRatesModal,
checkForUsageFees
checkForUsageFees,
readOnly,
checkForProjectLimitation
} from '$lib/stores/billing';
import { Alert, DropList, Heading } from '$lib/components';
import { Pill } from '$lib/elements';
@@ -14,6 +16,7 @@
import { wizard } from '$lib/stores/wizard';
import ChangeOrganizationTierCloud from '$routes/console/changeOrganizationTierCloud.svelte';
import { ContainerButton } from '.';
import { Button } from '$lib/elements/forms';
export let isFlex = true;
export let title: string;
@@ -31,6 +34,15 @@
let showDropdown = false;
const { bandwidth, documents, storage, users, executions } = $organization?.billingLimits;
const limitedServices = [
{ name: 'bandwidth', value: bandwidth },
{ name: 'documents', value: documents },
{ name: 'storage', value: storage },
{ name: 'users', value: users },
{ name: 'executions', value: executions }
];
const limit = getServiceLimit(serviceId) || Infinity;
const upgradeMethod = () => {
showDropdown = false;
@@ -39,41 +51,49 @@
const dispatch = createEventDispatcher();
$: tier = tierToPlan($organization?.billingPlan)?.name;
$: hasProjectLimitation =
checkForProjectLimitation(serviceId) && $organization?.billingPlan === 'tier-0';
$: hasUsageFees = hasProjectLimitation
? checkForUsageFees($organization?.billingPlan, serviceId)
: false;
$: isLimited = limit !== 0 && limit < Infinity;
$: hasUsageFees = checkForUsageFees($organization?.billingPlan, serviceId);
$: isButtonDisabled = buttonDisabled || (isLimited && total >= limit && !hasUsageFees);
$: overflowingServices = limitedServices.filter((service) => service.value >= 0);
$: isButtonDisabled =
buttonDisabled || $readOnly || (isLimited && total >= limit && !hasUsageFees);
onMount(() => {
dispatch('data', { isButtonDisabled, limit, tier });
});
</script>
{#if isCloud && showAlert && total && limit !== 0 && total >= limit}
<!-- Show only if on Cloud, alerts are enabled, and it isn't a project limited service -->
{#if isCloud && showAlert}
<slot name="alert" {limit} {tier} {title} {upgradeMethod} {hasUsageFees}>
{#if hasUsageFees}
<Alert type={alertType} isStandalone>
<span class="text">
You've reached the {title.toLocaleLowerCase()} limit for the {tier} plan.
<button
class="link"
type="button"
on:click|preventDefault={() => ($showUsageRatesModal = true)}
>Excess usage fees will apply</button
>.
</span>
</Alert>
{:else}
<Alert type={alertType} isStandalone>
<span class="text">
You've reached the {title.toLowerCase()} limit for the {tier} plan.
{#if $organization?.billingPlan === 'tier-0'}
<button class="link" type="button" on:click|preventDefault={upgradeMethod}
>Upgrade</button>
for additional {title.toLocaleLowerCase()}.
{/if}
</span>
</Alert>
{#if $readOnly}
{@const services = overflowingServices
.map((s) => {
return s.name.toLocaleLowerCase();
})
.join(', ')}
{#if $organization?.billingPlan !== 'tier-0' && hasUsageFees}
<Alert type="info" isStandalone>
<span class="text">
You've reached the {services} limit for the {tier} plan.
<Button link on:click={() => ($showUsageRatesModal = true)}
>Excess usage fees will apply</Button
>.
</span>
</Alert>
{:else}
<Alert type={alertType} isStandalone>
<span class="text">
You've reached the {services} limit for the {tier} plan. <Button
link
on:click={upgradeMethod}>Upgrade</Button> your organization for additional
resources.
</span>
</Alert>
{/if}
{/if}
</slot>
{/if}
@@ -83,31 +103,43 @@
<Heading tag={titleTag} size={titleSize}>{title}</Heading>
{#if isCloud && isLimited}
<DropList bind:show={showDropdown} width="16">
<Pill button on:click={() => (showDropdown = !showDropdown)}>
<span class="icon-info" />{title} limited
</Pill>
{#if hasProjectLimitation}
<Pill button on:click={() => (showDropdown = !showDropdown)}>
<span class="icon-info" />{total}/{limit}
{title} used
</Pill>
{:else}
<Pill button on:click={() => (showDropdown = !showDropdown)}>
<span class="icon-info" />{title} limited
</Pill>
{/if}
<svelte:fragment slot="list">
<slot name="tooltip" {limit} {tier} {title} {upgradeMethod} {hasUsageFees}>
{#if hasUsageFees}
{#if hasProjectLimitation}
<p class="text">
Your are limited to {limit}
{title.toLocaleLowerCase()} per project on the {tier} plan.
{#if $organization?.billingPlan === 'tier-0'}<Button
link
on:click={upgradeMethod}>Upgrade</Button>
for addtional {title.toLocaleLowerCase()}.
{/if}
</p>
{:else if hasUsageFees}
<p class="text">
You are limited to {limit}
{title.toLocaleLowerCase()} per project on the {tier} plan.
<button
class="link"
type="button"
on:click|preventDefault={() => ($showUsageRatesModal = true)}
>Excess usage fees will apply</button
{title.toLocaleLowerCase()} per organization on the {tier} plan.
<Button link on:click={() => ($showUsageRatesModal = true)}
>Excess usage fees will apply</Button
>.
</p>
{:else}
<p class="text">
Your are limited to {limit}
{title.toLocaleLowerCase()} per project on the {tier} plan.
{#if $organization?.billingPlan === 'tier-0'}<button
class="link"
type="button"
on:click|preventDefault={upgradeMethod}>Upgrade</button>
for addtional {title.toLocaleLowerCase()}.
You are limited to {limit}
{title.toLocaleLowerCase()} per organization on the {tier} plan.
{#if $organization?.billingPlan === 'tier-0'}
<Button link on:click={upgradeMethod}>Upgrade</Button>
for additional {title.toLocaleLowerCase()}.
{/if}
</p>
{/if}
+8 -6
View File
@@ -105,12 +105,14 @@
{/if}
{#if !$page.url.pathname.includes('/console/account') && $readOnly}
<Pill danger button on:click={() => ($showExcess = true)}>
<div>
<span class="icon-exclamation-circle" aria-hidden="true" />
<span>limit reached</span>
</div>
</Pill>
<div style="min-inline-size: fit-content">
<Pill danger button on:click={() => ($showExcess = true)}>
<div>
<span class="icon-exclamation-circle" aria-hidden="true" />
<span>limit reached</span>
</div>
</Pill>
</div>
{/if}
<div class="main-header-end">
+136 -5
View File
@@ -1,10 +1,17 @@
import { page } from '$app/stores';
import { derived, get, writable } from 'svelte/store';
import { sdk } from './sdk';
import { organization } from './organization';
import { organization, type Organization } from './organization';
import type { InvoiceList, AddressesList, Invoice, PaymentList, PlansInfo } from '$lib/sdk/billing';
import { isCloud } from '$lib/system';
import { cachedStore } from '$lib/helpers/cache';
import { Query } from '@appwrite.io/console';
import { headerAlert } from './headerAlert';
import PaymentAuthRequired from '$lib/components/billing/alerts/paymentAuthRequired.svelte';
import { diffDays, toLocaleDate } from '$lib/helpers/date';
import { addNotification, notifications } from './notifications';
import { goto } from '$app/navigation';
import { base } from '$app/paths';
export type Tier = 'tier-0' | 'tier-1' | 'tier-2';
@@ -63,7 +70,7 @@ export function getServiceLimit(serviceId: PlanServices, tier: Tier = null): num
const plan = get(plansInfo).plans.find(
(p) => p.$id === (tier ?? get(organization)?.billingPlan)
);
return plan[serviceId];
return plan?.[serviceId];
}
export const failedInvoice = cachedStore<
@@ -80,8 +87,12 @@ export const failedInvoice = cachedStore<
// const failedInvoices = invoices.invoices;
if (failedInvoices.length > 0) {
const firstFailed = failedInvoices[0];
//TODO: if firstFailed is older than 30 days, set readonly to true!
set(firstFailed);
const today = new Date();
const thirtyDaysAgo = new Date(today.setDate(today.getDate() - 30));
const failedDate = new Date(firstFailed.$createdAt);
if (failedDate < thirtyDaysAgo) {
readOnly.set(true);
}
} else set(false);
}
};
@@ -126,11 +137,131 @@ export function checkForUsageFees(plan: Tier, id: PlanServices) {
} else return false;
}
export function checkForProjectLimitation(id: PlanServices) {
switch (id) {
case 'databases':
case 'functions':
case 'buckets':
case 'members':
case 'platforms':
case 'webhooks':
case 'teams':
return true;
default:
return false;
}
}
export function isServiceLimited(serviceId: PlanServices, plan: Tier, total: number) {
if (!total) return false;
const limit = getServiceLimit(serviceId) || Infinity;
const isLimited = limit !== 0 && limit < Infinity;
const hasUsageFees = checkForUsageFees(plan, serviceId);
console.log(serviceId, plan, total, limit, isLimited, hasUsageFees);
return isLimited && total >= limit && !hasUsageFees;
}
export function calculateTrialDay(org: Organization) {
if (org?.billingPlan === 'tier-0') return false;
const endDate = new Date(org?.billingTrialEndDate);
const today = new Date();
const days = diffDays(today, endDate);
daysLeftInTrial.set(days);
return days;
}
export function checkForTrialEnding(org: Organization) {
const days = calculateTrialDay(org);
if (localStorage.getItem('trialEndingNotification') === 'true' || !days) return;
else if (days <= 5) {
addNotification({
type: 'info',
isHtml: true,
message: `<b>We hope you've been enjoying the ${
tierToPlan(org.billingPlan).name
} plan.</b>
You will be billed on a recurring 30-day cycle after your trial period ends on <b>${toLocaleDate(
org.billingTrialEndDate
)}</b>`
});
localStorage.setItem('trialEndingNotification', 'true');
}
}
export function checkForUsageLimit(org: Organization) {
if (!org?.billingLimits) {
readOnly.set(false);
return;
}
const { bandwidth, documents, executions, storage, users } = org.billingLimits;
if (
bandwidth >= 100 ||
documents >= 100 ||
executions >= 100 ||
storage >= 100 ||
users >= 100
) {
readOnly.set(true);
} else readOnly.set(false);
}
export async function checkPaymentAuthorizationRequired(org: Organization) {
if (org.billingPlan === 'tier-0') return;
const invoices = await sdk.forConsole.billing.listInvoices(org.$id, [
Query.equal('status', 'requires_authentication')
]);
actionRequiredInvoices.set(invoices);
if (get(actionRequiredInvoices) && get(actionRequiredInvoices)?.invoices?.length > 0) {
headerAlert.add({
id: 'paymentAuthRequired',
component: PaymentAuthRequired,
show: true,
importance: 8
});
}
}
export async function paymentExpired(org: Organization) {
if (!org?.paymentMethodId) return;
const payment = await sdk.forConsole.billing.getPaymentMethod(org.paymentMethodId);
if (!payment?.expiryYear) return;
const year = new Date().getFullYear();
const month = new Date().getMonth();
const expiredMessage = `The default payment method for <b>${org.name}</b> has expired`;
const expiringMessage = `The default payment method for <b>${org.name}</b> will expire soon`;
const nots = get(notifications);
const expiredNotification = nots.some((n) => n.message === expiredMessage);
const expiringNotification = nots.some((n) => n.message === expiringMessage);
if (payment.expired && !expiredNotification) {
addNotification({
type: 'error',
isHtml: true,
timeout: 0,
message: expiredMessage,
buttons: [
{
name: 'Update payment details',
method: () => {
goto(`${base}/console/account/payments`);
}
}
]
});
} else if (!expiringNotification && payment.expiryYear <= year && payment.expiryMonth < month) {
addNotification({
type: 'warning',
isHtml: true,
message: expiringMessage,
buttons: [
{
name: 'Update payment details',
method: () => {
goto(`${base}/console/account/payments`);
}
}
]
});
}
}
@@ -37,8 +37,8 @@
</p>
<p class="text">
Consider upgrading and take advantage of the extra resources that come with the Pro
plan. You can also use our Migrations service to self-host some of your projects
instead. Learn more in our <a
plan. You can also use Migrations to self-host some of your projects instead. Learn more
in our <a
class="link"
href="https://appwrite.io/docs/advanced/migrations"
target="_blank"
@@ -162,8 +162,10 @@
<i class="icon-trending-up" />
</div>
<div>
<p class="u-bold">Keep your project plan limits in mind</p>
<p>Make sure to have enough storage in your project plan when importing files</p>
<p class="u-bold">Keep your organization plan's limits in mind</p>
<p>
Make sure to have enough storage in your organization plan when importing files.
</p>
</div>
</div>
{#if $provider.provider === 'firebase'}
+14 -123
View File
@@ -14,20 +14,19 @@
import { loading, requestedMigration } from '../store';
import Create from './createOrganization.svelte';
import {
daysLeftInTrial,
tierToPlan,
readOnly,
showUsageRatesModal,
actionRequiredInvoices
checkForUsageLimit,
checkPaymentAuthorizationRequired,
calculateTrialDay,
checkForTrialEnding,
paymentExpired
} from '$lib/stores/billing';
import { diffDays, toLocaleDate } from '$lib/helpers/date';
import { base } from '$app/paths';
import { goto } from '$app/navigation';
import { CommandCenter, registerCommands, registerSearchers } from '$lib/commandCenter';
import { AIPanel, OrganizationsPanel, ProjectsPanel } from '$lib/commandCenter/panels';
import { orgSearcher, projectsSearcher } from '$lib/commandCenter/searchers';
import { addSubPanel } from '$lib/commandCenter/subPanels';
import { addNotification, notifications } from '$lib/stores/notifications';
import { addNotification } from '$lib/stores/notifications';
import { openMigrationWizard } from './(migration-wizard)';
import { project } from './project-[project]/store';
import { feedback } from '$lib/stores/feedback';
@@ -44,7 +43,6 @@
import { Query } from '@appwrite.io/console';
import { headerAlert } from '$lib/stores/headerAlert';
import MarkedForDeletion from '$lib/components/billing/alerts/markedForDeletion.svelte';
import PaymentAuthRequired from '$lib/components/billing/alerts/paymentAuthRequired.svelte';
import PostReleaseModal from './(billing-modal)/postReleaseModal.svelte';
import TooManyFreOrgs from '$lib/components/billing/alerts/tooManyFreOrgs.svelte';
@@ -294,22 +292,14 @@
}
}
let currentOrg = JSON.stringify($organization?.$id);
organization.subscribe((org) => {
organization.subscribe(async (org) => {
if (!org) return;
if (currentOrg === org.$id) return;
currentOrg = org.$id;
if (isCloud) {
if (org?.billingPlan === 'tier-0') {
$daysLeftInTrial = 0;
} else {
calculateTrialDay(new Date(org?.billingTrialEndDate));
}
checkForTrialEnding();
paymentExpired();
checkForUsageLimit();
if ($organization?.markedForDeletion) {
calculateTrialDay(org);
checkForTrialEnding(org);
await paymentExpired(org);
checkForUsageLimit(org);
if (org?.markedForDeletion) {
headerAlert.add({
id: 'markedForDeletion',
component: MarkedForDeletion,
@@ -317,94 +307,10 @@
importance: 5
});
}
checkPaymentAuthorizationRequired();
await checkPaymentAuthorizationRequired(org);
}
});
function calculateTrialDay(endDate: Date) {
const today = new Date();
const days = diffDays(today, endDate);
$daysLeftInTrial = days;
}
function checkForTrialEnding() {
if (localStorage.getItem('trialEndingNotification') === 'true' || !$daysLeftInTrial) return;
else if ($daysLeftInTrial <= 5) {
addNotification({
type: 'info',
isHtml: true,
message: `<b>We hope you've been enjoying the ${
tierToPlan($organization.billingPlan).name
} plan.</b>
You will be billed on a recurring 30-day cycle after your trial period ends on <b>${toLocaleDate(
$organization.billingTrialEndDate
)}</b>`
});
localStorage.setItem('trialEndingNotification', 'true');
}
}
function checkForUsageLimit() {
if (!$organization?.billingLimits) return;
const { bandwidth, documents, executions, storage, users } = $organization.billingLimits;
if (
bandwidth >= 100 ||
documents >= 100 ||
executions >= 100 ||
storage >= 100 ||
users >= 100
) {
$readOnly = true;
}
}
async function paymentExpired() {
if (!$organization?.paymentMethodId) return;
const payment = await sdk.forConsole.billing.getPaymentMethod(
$organization.paymentMethodId
);
if (!payment?.expiryYear) return;
const year = new Date().getFullYear();
const month = new Date().getMonth();
const expiredMessage = `The default payment method for <b>${$organization.name}</b> has expired`;
const expiringMessage = `The default payment method for <b>${$organization.name}</b> will expire soon`;
const expiredNotification = $notifications.some((n) => n.message === expiredMessage);
const expiringNotification = $notifications.some((n) => n.message === expiringMessage);
if (payment.expired && !expiredNotification) {
addNotification({
type: 'error',
isHtml: true,
timeout: 0,
message: expiredMessage,
buttons: [
{
name: 'Update payment details',
method: () => {
goto(`${base}/console/account/payments`);
}
}
]
});
} else if (
!expiringNotification &&
payment.expiryYear <= year &&
payment.expiryMonth < month
) {
addNotification({
type: 'warning',
isHtml: true,
message: expiringMessage,
buttons: [
{
name: 'Update payment details',
method: () => {
goto(`${base}/console/account/payments`);
}
}
]
});
}
}
function checkForPreReleaseProModal() {
const modalTime = localStorage.getItem('preReleaseProModal');
const notificationTime = localStorage.getItem('preReleaseProNotification');
@@ -433,7 +339,7 @@
type: 'warning',
timeout: 10000,
message:
'Appwrite Pro is coming soon, which means you will be limited to one free organization per account. To avoid service disruptions in your projects, consider upgrading to Pro.',
"Appwrite Pro is coming soon, which means you will be limited to one free organization per account. To avoid service disruptions in your organization's projects, consider upgrading to Pro.",
buttons: [
{
name: 'Learn more',
@@ -447,21 +353,6 @@
}
}
async function checkPaymentAuthorizationRequired() {
if ($organization.billingPlan === 'tier-0') return;
$actionRequiredInvoices = await sdk.forConsole.billing.listInvoices($organization.$id, [
Query.equal('status', 'requires_authentication')
]);
if ($actionRequiredInvoices && $actionRequiredInvoices?.invoices?.length > 0) {
headerAlert.add({
id: 'paymentAuthRequired',
component: PaymentAuthRequired,
show: true,
importance: 8
});
}
}
$: if (!$log.show) {
$log.data = null;
$log.func = null;
@@ -94,8 +94,8 @@
<svelte:fragment slot="title">
The scheduled payment for {$organization.name} failed
</svelte:fragment>
To avoid service disruptions in your projects, please verify your payment details and update
them if necessary.
To avoid service disruptions in organization's your projects, please verify your payment
details and update them if necessary.
</Alert>
{/if}
{#if defaultPaymentMethod?.failed && !backupPaymentMethod}
@@ -103,7 +103,8 @@
<svelte:fragment slot="title">
The default payment method for {$organization.name} has expired
</svelte:fragment>
To avoid service disruptions in your projects, please update your payment details.
To avoid service disruptions in your organization's projects, please update your payment
details.
</Alert>
{/if}
{#if $organization?.billingPlanDowngrade}
@@ -12,6 +12,7 @@
import { wizard } from '$lib/stores/wizard';
import ChangeOrganizationTierCloud from '../changeOrganizationTierCloud.svelte';
import { goto } from '$app/navigation';
import { last } from '$lib/helpers/array';
export let show = false;
const plan = $plansInfo.plans.find((plan) => plan.$id === $organization.billingPlan);
@@ -30,31 +31,48 @@
});
function calculateExcess() {
const totBandwidth = usage?.bandwidth?.length > 0 ? usage.bandwidth[0].value : 0;
const totUsers = usage?.users?.length > 0 ? usage.users[0].value : 0;
const totBandwidth = usage?.bandwidth?.length > 0 ? last(usage.bandwidth).value : 0;
const totUsers = usage?.users?.length > 0 ? last(usage.users).value : 0;
excess = {
bandwidth: totBandwidth > plan.bandwidth ? totBandwidth - plan.bandwidth : 0,
storage:
usage?.storage[0] > sizeToBytes(plan.storage, 'GB')
? usage.storage[0] - plan.storage
usage?.storage > sizeToBytes(plan.storage, 'GB')
? usage.storage - sizeToBytes(plan.storage, 'GB')
: 0,
users: totUsers > plan.users ? totUsers - plan.users : 0,
users: totUsers > (plan.users || Infinity) ? totUsers - plan.users : 0,
executions:
usage?.executions[0] > plan.executions ? usage.executions[0] - plan.executions : 0,
members: members.total > plan.members ? members.total - (plan.members || Infinity) : 0
usage?.executions > sizeToBytes(plan.executions, 'GB')
? usage.executions - sizeToBytes(plan.executions, 'GB')
: 0,
members:
members?.total > (plan.members || Infinity)
? members.total - (plan.members || Infinity)
: 0
};
}
$: if (show) calculateExcess();
</script>
<Modal bind:show title="Limit reached">
<svelte:fragment slot="title">
Your usage exceeds the {tierToPlan($organization.billingPlan).name} plan limits
</svelte:fragment>
<p class="text">
Usage for <b>{$organization.name}</b> organization has reached the limits of the {tierToPlan(
$organization.billingPlan
).name} plan. Consider upgrading to increase your resource usage.
</p>
{#if $organization.billingPlan === 'tier-0'}
<p class="text">
Usage for <b>{$organization.name}</b> organization has reached the limits of the {tierToPlan(
$organization.billingPlan
).name} plan. Consider upgrading to increase your resource usage.
</p>
{:else}
<p class="text">
Usage for <b>{$organization.name}</b> organization has reached the limits of the {tierToPlan(
$organization.billingPlan
).name} plan. Excess usage fees will apply.
</p>
{/if}
<PlanExcess {excess} currentTier={$organization.billingPlan} />
<svelte:fragment slot="footer">
<div class="u-flex u-main-space-between u-width-full-line">
@@ -58,7 +58,8 @@
</p>
{:else}
<p class="text">
If you exceed the limits of the {plan} plan, services for your projects may be disrupted.
If you exceed the limits of the {plan} plan, services for your organization's projects
may be disrupted.
<button
on:click={() => wizard.start(ChangeOrganizationTierCloud)}
class="link"
@@ -2,8 +2,11 @@
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import { registerCommands, updateCommandGroupRanks } from '$lib/commandCenter';
import { isServiceLimited, readOnly } from '$lib/stores/billing';
import { organization } from '$lib/stores/organization';
import { project } from '../store';
import { showCreateUser } from './+page.svelte';
import { userList } from './store';
import { showCreateTeam } from './teams/+page.svelte';
$: $registerCommands([
@@ -19,7 +22,9 @@
group: 'users',
icon: 'plus',
rank: $page.url.pathname.endsWith('auth') ? 10 : 0
rank: $page.url.pathname.endsWith('auth') ? 10 : 0,
disabled:
$readOnly || isServiceLimited('users', $organization.billingPlan, $userList.total)
},
{
label: 'Create team',
@@ -33,7 +38,8 @@
group: 'teams',
icon: 'plus',
rank: $page.url.pathname.endsWith('teams') ? 10 : 0
rank: $page.url.pathname.endsWith('teams') ? 10 : 0,
disabled: $readOnly
},
{
label: 'Go to teams',
@@ -26,13 +26,14 @@
TableRowLink
} from '$lib/elements/table';
import { toLocaleDate, toLocaleDateTime } from '$lib/helpers/date';
import { Container } from '$lib/layout';
import { Container, ContainerHeader } from '$lib/layout';
import type { Models } from '@appwrite.io/console';
import { writable } from 'svelte/store';
import type { PageData } from './$types';
import Create from './createUser.svelte';
import { readOnly } from '$lib/stores/billing';
import { isCloud } from '$lib/system';
import { tooltip } from '$lib/actions/tooltip';
export let data: PageData;
@@ -43,14 +44,27 @@
</script>
<Container>
<SearchQuery search={data.search} placeholder="Search by name, email, phone, or ID">
<Button
on:click={() => ($showCreateUser = true)}
event="create_user"
disabled={isCloud && $readOnly}>
<span class="icon-plus" aria-hidden="true" /> <span class="text">Create user</span>
</Button>
</SearchQuery>
<ContainerHeader
title="Users"
isFlex={false}
total={data.users.total}
buttonDisabled={isCloud && $readOnly}
let:isButtonDisabled>
<SearchQuery search={data.search} placeholder="Search by name, email, phone, or ID">
<div
use:tooltip={{
content: `Upgrade to add more users`,
disabled: !isButtonDisabled
}}>
<Button
on:click={() => ($showCreateUser = true)}
event="create_user"
disabled={isCloud && $readOnly}>
<span class="icon-plus" aria-hidden="true" />
<span class="text">Create user</span>
</Button>
</div></SearchQuery>
</ContainerHeader>
{#if data.users.total}
<Table>
<TableHeader>
@@ -0,0 +1,8 @@
import { page } from '$app/stores';
import type { Models } from '@appwrite.io/console';
import { derived } from 'svelte/store';
export const userList = derived(
page,
($page) => $page.data.users as unknown as Models.UserList<Record<string, unknown>>
);
@@ -18,7 +18,7 @@
await sdk.forProject.vcs.deleteInstallation(selectedInstallation.$id);
await invalidate(Dependencies.PROJECT_INSTALLATIONS);
addNotification({
message: `${selectedInstallation.organization} has been disconnected from your project`,
message: `${selectedInstallation.organization} has been disconnected from this project`,
type: 'success'
});
trackEvent(Submit.InstallationDelete, {
@@ -13,8 +13,8 @@
bind:show
onSubmit={handleDisableAll}>
<p class="text" data-private>
Are you sure you want to disable all services? This will disable API requests to your
project.
Are you sure you want to disable all services? This will disable API requests to this
project for all Client SDKs.
</p>
<svelte:fragment slot="footer">
<Button text on:click={() => (show = false)}>Cancel</Button>
@@ -200,7 +200,11 @@
{/if}
</svelte:fragment>
<svelte:fragment slot="actions">
<Button submit disabled={isButtonDisabled}>Update</Button>
<Button
submit
disabled={isButtonDisabled || $organization.billingPlan === 'tier-0'}>
Update
</Button>
</svelte:fragment>
</CardGrid>
</Form>
@@ -187,7 +187,7 @@
Installing Git to a self-hosted instance
</svelte:fragment>
When installing Git in a locally hosted Appwrite project, you must first configure
your environment variables.
environment variables.
<svelte:fragment slot="buttons">
<Button
href="https://appwrite.io/docs/advanced/self-hosting/functions"
@@ -42,7 +42,9 @@
<Form onSubmit={updateName}>
<CardGrid>
<Heading tag="h6" size="7">API credentials</Heading>
<p class="text">Access Appwrite services using your API Endpoint and Project ID.</p>
<p class="text">
Access Appwrite services using this project's API Endpoint and Project ID.
</p>
<svelte:fragment slot="aside">
<FormList>
<CopyInput label="Project ID" showLabel={true} value={$project.$id} />
@@ -150,7 +150,7 @@
</p>
{:else}
<p class="text">
You are limited to {limit} GB of free storage on the {tier} plan. After this amount
You are limited to {limit} GB storage on the {tier} plan. After this amount
<button
class="link"
type="button"
+5 -3
View File
@@ -51,12 +51,14 @@
if (response.status !== 200) {
trackError(new Error(response.status.toString()), Submit.SupportTicket);
addNotification({
message: 'There was an error submitting your feedback',
message:
'There was an error submitting your support ticket. Please try again later.',
type: 'error'
});
} else {
addNotification({
message: 'Your feedback was submitted successfully',
message:
'Your support ticket was submitted successfully. The Appwrite team will get back to you shortly.',
type: 'success'
});
}
@@ -83,7 +85,7 @@
If you found a bug or have questions, please reach out to the Appwrite team. We try to
respond to all messages within our office hours.
</p>
<p class="text u-margin-block-start-32">Available: <b>Mon-Fri 09:00 - 17:00 UCT</b></p>
<p class="text u-margin-block-start-32">Available: <b>Mon-Fri 09:00 - 17:00 UTC</b></p>
<div class="u-flex u-gap-4 u-cross-center">
<span>Currently:</span>
{#if isSupportOnline()}
@@ -56,7 +56,7 @@
{#if $createOrganization.billingPlan !== 'tier-0'}
<div class="u-margin-block-start-32">
<p class="body-text-1 u-bold">Organization members</p>
<p class="body-text-1 u-bold">Additional members</p>
<p class="text u-margin-block-start-8">{collaboratorsNumber} members</p>
</div>
<div class="u-margin-block-start-32">
@@ -68,7 +68,7 @@
type="switchbox"
id="budget"
label="Enable budget cap"
tooltip="If enabled, you will be notified by email when your project spend reaches 75% of the cap you set. Update your budget cap alerts in Organization Settings."
tooltip="If enabled, you will be notified by email when your organization spend reaches 75% of the cap you set. Update your budget cap alerts in organization Settings."
fullWidth
bind:value={budgetEnabled}>
<p class="text">
@@ -134,8 +134,6 @@
<div class:u-opacity-50={disabled}>
{#if $organization.billingPlan === 'tier-0'}
<Pill disabled>CURRENT PLAN</Pill>
{:else}
<Pill>14 DAY FREE TRIAL</Pill>
{/if}
</div>
</svelte:fragment>
@@ -79,7 +79,7 @@
{#if $changeOrganizationTier.billingPlan !== 'tier-0'}
<div class="u-margin-block-start-32">
<p class="body-text-1 u-bold">Organization members</p>
<p class="body-text-1 u-bold">Additional members</p>
<p class="text u-margin-block-start-8">{collaboratorsNumber} members</p>
</div>
<div class="u-margin-block-start-32">
@@ -82,7 +82,7 @@
type="switchbox"
id="budget"
label="Enable budget cap"
tooltip="If enabled, you will be notified by email when your project spend reaches 75% of the cap you set. Update your budget cap alerts in Organization Settings."
tooltip="If enabled, you will be notified by email when your organization spend reaches 75% of the cap you set. Update your budget cap alerts in organization Settings."
fullWidth
bind:value={budgetEnabled}>
<p class="text">
@@ -15,6 +15,7 @@
import { Button } from '$lib/elements/forms';
import { humanFileSize } from '$lib/helpers/sizeConvertion';
import { abbreviateNumber } from '$lib/helpers/numbers';
import { formatNum } from '$lib/helpers/string';
export let excess: {
bandwidth?: number;
@@ -31,7 +32,11 @@
<Alert type="error">
<svelte:fragment slot="title">
Changing your plan now will result in removal of organization members and more
{#if currentTier === 'tier-0'}
Your usage exceeds the {plan.name} plan limits
{:else}
Changing your plan now will result in removal of organization members and more
{/if}
</svelte:fragment>
{#if excess?.members > 0}
@@ -44,16 +49,26 @@
{/if}
{/if}
{#if excess?.bandwidth > 0 || excess?.executions > 0 || excess?.storage > 0 || excess?.users}
The Starter plan has a limit of one organization member. By proceeding, all but the creator
of the organization admin will be removed. Until you reduce your usage, you will be unable
to add to the resources listed below in all projects within your organization. The current
billing cycle will end on {toLocaleDate($organization.billingCurrentInvoiceDate)}. Any
executions, bandwidth, or messaging usage will be reset at that time.
Until you reduce your usage, you will be unable to add to the resources listed below in all
projects within your organization. The current billing cycle will end on {toLocaleDate(
$organization.billingCurrentInvoiceDate
)}. Any executions, bandwidth, or messaging usage will be reset at that time.
{/if}
<svelte:fragment slot="buttons">
<!-- TODO: add link when available -->
<Button text href="#/">Learn more</Button>
{#if currentTier === 'tier-0'}
<Button
text
href="https://appwrite.io/docs/advanced/platform/starter#reaching-resource-limits">
Learn more
</Button>
{:else if currentTier === 'tier-1'}
<Button
text
href="https://appwrite.io/docs/advanced/platform/pro#reaching-resource-limits">
Learn more
</Button>
{/if}
</svelte:fragment>
</Alert>
@@ -97,7 +112,12 @@
<TableCell title="excess">
<p class="u-color-text-danger">
<span class="icon-arrow-up" />
{excess?.executions} executions
<span
title={excess?.executions
? excess.executions.toString()
: 'executions'}>
{formatNum(excess?.executions)} executions
</span>
</p>
</TableCell>
</TableRow>
@@ -111,7 +131,9 @@
<TableCell title="excess">
<p class="u-color-text-danger">
<span class="icon-arrow-up" />
{excess?.users} users
<span title={excess?.users ? excess.users.toString() : 'users'}>
{formatNum(excess?.users)} users
</span>
</p>
</TableCell>
</TableRow>