feat: centralize url

This commit is contained in:
Arman committed 2024-05-15 15:50:23 +02:00
1 parent 66dad86768
commit 760c15ebc9
19 files changed
+55 -82

No files matched your search

@@ -5,7 +5,7 @@
import { BillingPlan } from '$lib/constants';
import { Button } from '$lib/elements/forms';
import { HeaderAlert } from '$lib/layout';
import { readOnly, tierToPlan } from '$lib/stores/billing';
import { readOnly, tierToPlan, upgradeURL } from '$lib/stores/billing';
import { organization } from '$lib/stores/organization';
</script>
@@ -25,7 +25,7 @@
<span class="text">View usage</span>
</Button>
<Button
href={`${base}/console/organization-${$organization.$id}/change-plan`}
href={$upgradeURL}
on:click={() => {
trackEvent('click_organization_upgrade', {
from: 'button',
+2 -5
View File
@@ -1,7 +1,6 @@
<script lang="ts">
import { base } from '$app/paths';
import { Button } from '$lib/elements/forms';
import { organization } from '$lib/stores/organization';
import { upgradeURL } from '$lib/stores/billing';
export let service: string;
</script>
@@ -9,8 +8,6 @@
<article class="card u-grid u-cross-center u-width-full-line">
<div class="u-flex u-flex-vertical u-gap-24 u-main-center u-cross-center">
<p class="text u-text-center">Upgrade your plan to add more {service}</p>
<Button secondary href={`${base}/console/organization-${$organization.$id}/change-plan`}>
Change plan
</Button>
<Button secondary href={$upgradeURL}>Change plan</Button>
</div>
</article>
+2 -2
View File
@@ -9,7 +9,7 @@
import { BillingPlan } from '$lib/constants';
import { trackEvent } from '$lib/actions/analytics';
import { localeTimezoneName, utcHourToLocaleHour } from '$lib/helpers/date';
import { base } from '$app/paths';
import { upgradeURL } from '$lib/stores/billing';
export let show = false;
@@ -33,7 +33,7 @@
{#if $organization?.billingPlan === BillingPlan.STARTER}
<Button
fullWidth
href={`${base}/console/organization-${$organization.$id}/change-plan`}
href={$upgradeURL}
on:click={() => {
trackEvent('click_organization_upgrade', {
from: 'button',
+3 -5
View File
@@ -1,9 +1,7 @@
<script lang="ts">
import { goto } from '$app/navigation';
import { base } from '$app/paths';
import { trackEvent } from '$lib/actions/analytics';
import { getServiceLimit, type PlanServices } from '$lib/stores/billing';
import { organization } from '$lib/stores/organization';
import { getServiceLimit, upgradeURL, type PlanServices } from '$lib/stores/billing';
import { isCloud } from '$lib/system';
import { Button } from '../forms';
@@ -20,7 +18,7 @@
// TODO: refactor this to be a string
const upgradeMethod = () => {
goto(`${base}/console/organization-${$organization.$id}/change-plan`);
goto($upgradeURL);
};
$: limitReached = limit !== 0 && limit < Infinity && total >= limit;
@@ -41,7 +39,7 @@
<span class="text">Upgrade your plan to add {name} to your organization</span>
<Button
secondary
href={`${base}/console/organization-${$organization.$id}/change-plan`}
href={$upgradeURL}
on:click={() =>
trackEvent('click_organization_upgrade', {
from: 'button',
+5 -8
View File
@@ -10,6 +10,7 @@
readOnly,
showUsageRatesModal,
tierToPlan,
upgradeURL,
type PlanServices
} from '$lib/stores/billing';
import { organization } from '$lib/stores/organization';
@@ -17,7 +18,6 @@
import { createEventDispatcher, onMount } from 'svelte';
import { ContainerButton } from '.';
import { trackEvent } from '$lib/actions/analytics';
import { base } from '$app/paths';
import { goto } from '$app/navigation';
export let isFlex = true;
@@ -57,7 +57,7 @@
//TODO: refactor this to be a string
const upgradeMethod = () => {
showDropdown = false;
goto(`${base}/console/organization-${$organization.$id}/change-plan`);
goto($upgradeURL);
};
const dispatch = createEventDispatcher();
@@ -102,7 +102,7 @@
<span class="text">
You've reached the {services} limit for the {tier} plan. <Button
link
href={`${base}/console/organization-${$organization.$id}/change-plan`}
href={$upgradeURL}
on:click={() =>
trackEvent('click_organization_upgrade', {
from: 'button',
@@ -137,7 +137,7 @@
{title.toLocaleLowerCase()} per project on the {tier} plan.
{#if $organization?.billingPlan === BillingPlan.STARTER}<Button
link
href={`${base}/console/organization-${$organization.$id}/change-plan`}
href={$upgradeURL}
on:click={() =>
trackEvent('click_organization_upgrade', {
from: 'button',
@@ -159,10 +159,7 @@
You are limited to {limit}
{title.toLocaleLowerCase()} per organization on the {tier} plan.
{#if $organization?.billingPlan === BillingPlan.STARTER}
<Button
link
href={`${base}/console/organization-${$organization.$id}/change-plan`}
>Upgrade</Button>
<Button link href={$upgradeURL}>Upgrade</Button>
for additional {title.toLocaleLowerCase()}.
{/if}
</p>
+2 -1
View File
@@ -22,6 +22,7 @@
import { isCloud } from '$lib/system';
import { Feedback } from '$lib/components/feedback';
import { BillingPlan } from '$lib/constants';
import { upgradeURL } from '$lib/stores/billing';
let showDropdown = false;
let showSupport = false;
@@ -104,7 +105,7 @@
{#if isCloud && $organization?.billingPlan === BillingPlan.STARTER && !$page.url.pathname.startsWith('/console/account')}
<Button
disabled={$organization?.markedForDeletion}
href={`${base}/console/organization-${$organization.$id}/change-plan`}
href={$upgradeURL}
on:click={() => {
trackEvent('click_organization_upgrade', {
from: 'button',
+3 -7
View File
@@ -14,12 +14,11 @@
import { beforeNavigate } from '$app/navigation';
import { Pill } from '$lib/elements';
import { isCloud } from '$lib/system';
import { getServiceLimit, tierToPlan } from '$lib/stores/billing';
import { getServiceLimit, tierToPlan, upgradeURL } from '$lib/stores/billing';
import { organization } from '$lib/stores/organization';
import { app } from '$lib/stores/app';
import { Button } from '$lib/elements/forms';
import { BillingPlan } from '$lib/constants';
import { base } from '$app/paths';
let selectedRequest = 'parameters';
let selectedResponse = 'logs';
@@ -312,11 +311,8 @@
Logs are retained in rolling {hoursToDays(limit)} intervals
with the {tier} plan.
{#if $organization.billingPlan === BillingPlan.STARTER}
<Button
link
href={`${base}/console/organization-${$organization.$id}/change-plan`}
>Upgrade</Button> to increase your log retention
for a longer period.
<Button link href={$upgradeURL}>Upgrade</Button> to increase
your log retention for a longer period.
{/if}
</Alert>
{/if}
+2 -3
View File
@@ -6,6 +6,7 @@
import { BillingPlan } from '$lib/constants';
import { isMac } from '$lib/helpers/platform';
import { slide } from '$lib/helpers/transition';
import { upgradeURL } from '$lib/stores/billing';
import { organization } from '$lib/stores/organization';
import { wizard } from '$lib/stores/wizard';
import { isCloud } from '$lib/system';
@@ -199,9 +200,7 @@
<ul class="drop-list is-only-mobile">
{#if isCloud && $organization?.billingPlan !== BillingPlan.SCALE}
<li class="drop-list-item">
<a
class="drop-button"
href={`${base}/console/organization-${$organization.$id}/change-plan`}>
<a class="drop-button" href={$upgradeURL}>
<span class="text">Upgrade</span>
</a>
</li>
+6 -3
View File
@@ -24,8 +24,6 @@ import { BillingPlan } from '$lib/constants';
import PaymentMandate from '$lib/components/billing/alerts/paymentMandate.svelte';
import MissingPaymentMethod from '$lib/components/billing/alerts/missingPaymentMethod.svelte';
import LimitReached from '$lib/components/billing/alerts/limitReached.svelte';
import { wizard } from './wizard';
import ChangeOrganizationTierCloud from '$routes/console/changeOrganizationTierCloud.svelte';
import { trackEvent } from '$lib/actions/analytics';
export type Tier = 'tier-0' | 'tier-1' | 'tier-2';
@@ -239,7 +237,7 @@ export async function checkForUsageLimit(org: Organization) {
{
name: 'Upgrade plan',
method: () => {
wizard.start(ChangeOrganizationTierCloud);
goto(`${base}/console/organization-${org.$id}/change-plan`);
trackEvent('click_organization_upgrade', {
from: 'button',
source: 'limit_reached_notification'
@@ -364,3 +362,8 @@ export async function checkForMissingPaymentMethod() {
});
}
}
export const upgradeURL = derived(
page,
($page) => `${base}/console/organization-${$page.data?.organization?.$id}/change-plan`
);
@@ -10,7 +10,7 @@
import PaymentHistory from './paymentHistory.svelte';
import TaxId from './taxId.svelte';
import { Alert, Heading } from '$lib/components';
import { failedInvoice, paymentMethods } from '$lib/stores/billing';
import { failedInvoice, paymentMethods, upgradeURL } from '$lib/stores/billing';
import type { PaymentMethodData } from '$lib/sdk/billing';
import { onMount } from 'svelte';
import { page } from '$app/stores';
@@ -22,7 +22,6 @@
import { selectedInvoice, showRetryModal } from './store';
import { Button } from '$lib/elements/forms';
import { goto } from '$app/navigation';
import { base } from '$app/paths';
export let data;
@@ -37,7 +36,7 @@
onMount(async () => {
if ($page.url.searchParams.has('type')) {
if ($page.url.searchParams.get('type') === 'upgrade') {
goto(`${base}/console/organization-${$organization.$id}/change-plan`);
goto($upgradeURL);
}
if (
@@ -21,7 +21,7 @@
import { formatCurrency } from '$lib/helpers/numbers';
import { BillingPlan } from '$lib/constants';
import { trackEvent } from '$lib/actions/analytics';
import { base } from '$app/paths';
import { upgradeURL } from '$lib/stores/billing';
let offset = 0;
let creditList: CreditList = {
@@ -132,7 +132,7 @@
{#if $organization?.billingPlan === BillingPlan.STARTER}
<Button
secondary
href={`${base}/console/organization-${$organization.$id}/change-plan`}
href={$upgradeURL}
on:click={() => {
trackEvent('click_organization_upgrade', {
from: 'button',
@@ -1,11 +1,10 @@
<script lang="ts">
import { invalidate } from '$app/navigation';
import { base } from '$app/paths';
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
import { Alert, CardGrid, Heading } from '$lib/components';
import { BillingPlan, Dependencies } from '$lib/constants';
import { Button, Form, FormList, InputNumber, InputSwitch } from '$lib/elements/forms';
import { showUsageRatesModal } from '$lib/stores/billing';
import { showUsageRatesModal, upgradeURL } from '$lib/stores/billing';
import { addNotification } from '$lib/stores/notifications';
import { organization } from '$lib/stores/organization';
import { sdk } from '$lib/stores/sdk';
@@ -96,7 +95,7 @@
{#if $organization?.billingPlan === BillingPlan.STARTER}
<Button
secondary
href={`${base}/console/organization-${$organization.$id}/change-plan`}
href={$upgradeURL}
on:click={() => {
trackEvent('click_organization_upgrade', {
from: 'button',
@@ -4,7 +4,7 @@
import { Pill } from '$lib/elements';
import { Button } from '$lib/elements/forms';
import { toLocaleDate } from '$lib/helpers/date';
import { plansInfo, tierToPlan } from '$lib/stores/billing';
import { plansInfo, tierToPlan, upgradeURL } from '$lib/stores/billing';
import { organization } from '$lib/stores/organization';
import { onMount } from 'svelte';
import { sdk } from '$lib/stores/sdk';
@@ -243,7 +243,7 @@
</Button>
<Button
disabled={$organization?.markedForDeletion}
href={`${base}/console/organization-${$organization.$id}/change-plan`}
href={$upgradeURL}
on:click={() =>
trackEvent('click_organization_upgrade', {
from: 'button',
@@ -257,7 +257,7 @@
<Button
text
disabled={$organization?.markedForDeletion}
href={`${base}/console/organization-${$organization.$id}/change-plan`}
href={$upgradeURL}
on:click={() =>
trackEvent('click_organization_plan_update', {
from: 'button',
@@ -1,7 +1,7 @@
<script lang="ts">
import { Modal } from '$lib/components';
import { sizeToBytes } from '$lib/helpers/sizeConvertion';
import { plansInfo, tierToPlan } from '$lib/stores/billing';
import { plansInfo, tierToPlan, upgradeURL } from '$lib/stores/billing';
import { organization } from '$lib/stores/organization';
import { onMount } from 'svelte';
import PlanExcess from '../wizard/cloudOrganizationChangeTier/planExcess.svelte';
@@ -12,7 +12,6 @@
import { goto } from '$app/navigation';
import { last } from '$lib/helpers/array';
import { trackEvent } from '$lib/actions/analytics';
import { base } from '$app/paths';
export let show = false;
const plan = $plansInfo?.get($organization.billingPlan);
@@ -77,7 +76,7 @@
View usage
</Button>
<Button
href={`${base}/console/organization-${$organization.$id}/change-plan`}
href={$upgradeURL}
on:click={() => {
show = false;
trackEvent('click_organization_upgrade', {
@@ -1,7 +1,12 @@
<script lang="ts">
import { Container } from '$lib/layout';
import { Card, CardGrid, Heading, ProgressBarBig } from '$lib/components';
import { getServiceLimit, showUsageRatesModal, tierToPlan } from '$lib/stores/billing';
import {
getServiceLimit,
showUsageRatesModal,
tierToPlan,
upgradeURL
} from '$lib/stores/billing';
import { organization } from '$lib/stores/organization';
import { Button } from '$lib/elements/forms';
import { bytesToSize, humanFileSize } from '$lib/helpers/sizeConvertion';
@@ -12,7 +17,6 @@
import type { OrganizationUsage } from '$lib/sdk/billing';
import { BillingPlan } from '$lib/constants';
import { trackEvent } from '$lib/actions/analytics';
import { base } from '$app/paths';
export let data;
@@ -43,7 +47,7 @@
{#if $organization?.billingPlan === BillingPlan.STARTER}
<Button
href={`${base}/console/organization-${$organization.$id}/change-plan`}
href={$upgradeURL}
on:click={() => {
trackEvent('click_organization_upgrade', {
from: 'button',
@@ -75,10 +79,7 @@
<p class="text">
If you exceed the limits of the {plan} plan, services for your organization's projects
may be disrupted.
<a
href={`${base}/console/organization-${$organization.$id}/change-plan`}
class="link">Upgrade for greater capacity</a
>.
<a href={$upgradeURL} class="link">Upgrade for greater capacity</a>.
</p>
{/if}
@@ -23,6 +23,7 @@
import { organization } from '$lib/stores/organization';
import { SMTPSecure } from '@appwrite.io/console';
import InputSelect from '$lib/elements/forms/inputSelect.svelte';
import { upgradeURL } from '$lib/stores/billing';
let enabled = false;
let senderName: string;
@@ -135,11 +136,7 @@
Custom SMTP is a Pro plan feature. Upgrade to enable custom SMTP sever.
<svelte:fragment slot="action">
<div class="alert-buttons u-flex">
<Button
text
href={`${base}/console/organization-${$organization.$id}/change-plan`}>
Upgrade plan
</Button>
<Button text href={$upgradeURL}>Upgrade plan</Button>
</div>
</svelte:fragment>
</Alert>
@@ -10,7 +10,7 @@
TableRow,
Table
} from '$lib/elements/table';
import { showUsageRatesModal, tierToPlan } from '$lib/stores/billing';
import { showUsageRatesModal, tierToPlan, upgradeURL } from '$lib/stores/billing';
import { organization } from '$lib/stores/organization';
import { Button } from '$lib/elements/forms';
import { humanFileSize } from '$lib/helpers/sizeConvertion';
@@ -51,7 +51,7 @@
<Heading tag="h2" size="5">Usage</Heading>
{#if $organization?.billingPlan === BillingPlan.STARTER}
<Button href={`${base}/console/organization-${$organization.$id}/change-plan`}>
<Button href={$upgradeURL}>
<span class="text">Upgrade</span>
</Button>
{/if}
@@ -74,10 +74,7 @@
{:else if $organization.billingPlan === BillingPlan.STARTER}
<p class="text">
If you exceed the limits of the {plan} plan, services for your projects may be disrupted.
<a
href={`${base}/console/organization-${$organization.$id}/change-plan`}
class="link">Upgrade for greater capacity</a
>.
<a href={$upgradeURL} class="link">Upgrade for greater capacity</a>.
</p>
{/if}
@@ -1,12 +1,11 @@
<script lang="ts">
import { base } from '$app/paths';
import { Alert, CustomId } from '$lib/components';
import { BillingPlan } from '$lib/constants';
import { Pill } from '$lib/elements';
import { Button, FormList, InputFile } from '$lib/elements/forms';
import { humanFileSize, sizeToBytes } from '$lib/helpers/sizeConvertion';
import WizardStep from '$lib/layout/wizardStep.svelte';
import { getServiceLimit, tierToPlan } from '$lib/stores/billing';
import { getServiceLimit, tierToPlan, upgradeURL } from '$lib/stores/billing';
import { organization } from '$lib/stores/organization';
import { isCloud } from '$lib/system';
import { bucket } from '../store';
@@ -35,11 +34,7 @@
<svelte:fragment slot="action">
{#if $organization?.billingPlan === BillingPlan.STARTER}
<div class="alert-buttons u-flex">
<Button
text
href={`${base}/console/organization-${$organization.$id}/change-plan`}>
Upgrade plan
</Button>
<Button text href={$upgradeURL}>Upgrade plan</Button>
</div>
{/if}
</svelte:fragment>
@@ -1,12 +1,11 @@
<script lang="ts">
import { base } from '$app/paths';
import { Submit } from '$lib/actions/analytics';
import { Alert, CardGrid, Heading } from '$lib/components';
import { BillingPlan } from '$lib/constants';
import { Button, Form, FormItem, InputNumber, InputSelect } from '$lib/elements/forms';
import { humanFileSize, sizeToBytes } from '$lib/helpers/sizeConvertion';
import { createByteUnitPair } from '$lib/helpers/unit';
import { getServiceLimit, readOnly, tierToPlan } from '$lib/stores/billing';
import { getServiceLimit, readOnly, tierToPlan, upgradeURL } from '$lib/stores/billing';
import { organization } from '$lib/stores/organization';
import { GRACE_PERIOD_OVERRIDE, isCloud } from '$lib/system';
import { bucket } from '../store';
@@ -49,11 +48,7 @@
<svelte:fragment slot="action">
{#if $organization?.billingPlan === BillingPlan.STARTER}
<div class="alert-buttons u-flex">
<Button
text
href={`${base}/console/organization-${$organization.$id}/change-plan`}>
Upgrade plan
</Button>
<Button text href={$upgradeURL}>Upgrade plan</Button>
</div>
{/if}
</svelte:fragment>