mirror of
https://github.com/appwrite/console.git
synced 2026-11-18 20:47:21 +00:00
update: scroll to card.
This commit is contained in:
1 parent
5ea5d2ee30
commit
b3851cd568
3 files changed
+119
-100
No files matched your search
@@ -18,7 +18,9 @@
|
||||
import { addNotification } from '$lib/stores/notifications';
|
||||
import { currentPlan, organization } from '$lib/stores/organization';
|
||||
import { sdk } from '$lib/stores/sdk';
|
||||
import { onMount } from 'svelte';
|
||||
import { onMount, tick } from 'svelte';
|
||||
import { page } from '$app/stores';
|
||||
import { scrollToUpdateBudget } from '$routes/(console)/organization-[organization]/billing/store';
|
||||
|
||||
export let alertsEnabled = false;
|
||||
|
||||
@@ -78,106 +80,121 @@
|
||||
|
||||
$: isButtonDisabled =
|
||||
symmetricDifference(alerts, $organization.budgetAlerts).length === 0 || !alertsEnabled;
|
||||
|
||||
let formHolderElement: HTMLDivElement;
|
||||
|
||||
$: if ($scrollToUpdateBudget) {
|
||||
history.replaceState(null, '', $page.url.pathname);
|
||||
|
||||
tick().then(() => {
|
||||
formHolderElement?.scrollIntoView({
|
||||
block: 'nearest'
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<Form onSubmit={updateBudget}>
|
||||
<CardGrid>
|
||||
<Heading tag="h2" size="6">Billing alerts</Heading>
|
||||
<div bind:this={formHolderElement} style:padding-block-start="1.5rem">
|
||||
<Form onSubmit={updateBudget}>
|
||||
<CardGrid>
|
||||
<Heading tag="h2" size="6">Billing alerts</Heading>
|
||||
|
||||
<p class="text">
|
||||
{#if !$currentPlan.budgeting}
|
||||
Get notified by email when your organization meets a percentage of your budget cap. <b
|
||||
>{tierToPlan($organization.billingPlan).name} organizations will receive one notification
|
||||
at 75% resource usage.</b>
|
||||
{:else}
|
||||
Get notified by email when your organization meets or exceeds a percentage of your
|
||||
specified billing alert(s).
|
||||
{/if}
|
||||
</p>
|
||||
<svelte:fragment slot="aside">
|
||||
{#if !$currentPlan.budgeting}
|
||||
<Alert type="info">
|
||||
<svelte:fragment slot="title"
|
||||
>Billing alerts are a Pro plan feature
|
||||
</svelte:fragment>
|
||||
Upgrade to a Pro plan to manage when you receive billing alerts for your organization.
|
||||
</Alert>
|
||||
{:else}
|
||||
<FormList>
|
||||
<Alert type="info">
|
||||
You can set a maximum of 4 billing alerts per organization.
|
||||
</Alert>
|
||||
|
||||
<div class="u-flex u-gap-16">
|
||||
<InputSelectSearch
|
||||
disabled={!alertsEnabled}
|
||||
label="Percentage (%) of budget cap"
|
||||
placeholder="Select a percentage"
|
||||
id="alerts"
|
||||
{options}
|
||||
bind:search
|
||||
interactiveOutput
|
||||
bind:value={selectedAlert}
|
||||
on:select={() => (search = selectedAlert.toString())} />
|
||||
<div style="align-self: flex-end">
|
||||
<Button
|
||||
secondary
|
||||
disabled={alerts.length > 3 ||
|
||||
(!search && !selectedAlert) ||
|
||||
!alertsEnabled}
|
||||
on:click={addAlert}>
|
||||
Add alert
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</FormList>
|
||||
|
||||
{#if alerts.length}
|
||||
<Table noMargin noStyles transparent>
|
||||
<TableHeader>
|
||||
<TableCellHead>Alert at budget cap %</TableCellHead>
|
||||
<TableCellHead width={30} />
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each alerts.sort() as alert}
|
||||
<TableRow>
|
||||
<TableCellText title="Percentage">
|
||||
{alert}%
|
||||
</TableCellText>
|
||||
<TableCell>
|
||||
<Button
|
||||
text
|
||||
round
|
||||
ariaLabel="remove alert"
|
||||
on:click={() =>
|
||||
(alerts = alerts.filter((a) => a !== alert))}>
|
||||
<span class="icon-x" aria-hidden="true" />
|
||||
</Button>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
<p class="text">
|
||||
{#if !$currentPlan.budgeting}
|
||||
Get notified by email when your organization meets a percentage of your budget
|
||||
cap. <b
|
||||
>{tierToPlan($organization.billingPlan).name} organizations will receive one
|
||||
notification at 75% resource usage.</b>
|
||||
{:else}
|
||||
Get notified by email when your organization meets or exceeds a percentage of
|
||||
your specified billing alert(s).
|
||||
{/if}
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
</p>
|
||||
<svelte:fragment slot="aside">
|
||||
{#if !$currentPlan.budgeting}
|
||||
<Alert type="info">
|
||||
<svelte:fragment slot="title"
|
||||
>Billing alerts are a Pro plan feature
|
||||
</svelte:fragment>
|
||||
Upgrade to a Pro plan to manage when you receive billing alerts for your organization.
|
||||
</Alert>
|
||||
{:else}
|
||||
<FormList>
|
||||
<Alert type="info">
|
||||
You can set a maximum of 4 billing alerts per organization.
|
||||
</Alert>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
{#if $organization?.billingPlan === BillingPlan.FREE || $organization?.billingPlan === BillingPlan.GITHUB_EDUCATION}
|
||||
<Button
|
||||
secondary
|
||||
href={$upgradeURL}
|
||||
on:click={() => {
|
||||
trackEvent('click_organization_upgrade', {
|
||||
from: 'button',
|
||||
source: 'billing_alerts_card'
|
||||
});
|
||||
}}
|
||||
>Upgrade to Pro
|
||||
</Button>
|
||||
{:else}
|
||||
<Button disabled={isButtonDisabled} submit>Update</Button>
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
<div class="u-flex u-gap-16">
|
||||
<InputSelectSearch
|
||||
disabled={!alertsEnabled}
|
||||
label="Percentage (%) of budget cap"
|
||||
placeholder="Select a percentage"
|
||||
id="alerts"
|
||||
{options}
|
||||
bind:search
|
||||
interactiveOutput
|
||||
bind:value={selectedAlert}
|
||||
on:select={() => (search = selectedAlert.toString())} />
|
||||
<div style="align-self: flex-end">
|
||||
<Button
|
||||
secondary
|
||||
disabled={alerts.length > 3 ||
|
||||
(!search && !selectedAlert) ||
|
||||
!alertsEnabled}
|
||||
on:click={addAlert}>
|
||||
Add alert
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</FormList>
|
||||
|
||||
{#if alerts.length}
|
||||
<Table noMargin noStyles transparent>
|
||||
<TableHeader>
|
||||
<TableCellHead>Alert at budget cap %</TableCellHead>
|
||||
<TableCellHead width={30} />
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{#each alerts.sort() as alert}
|
||||
<TableRow>
|
||||
<TableCellText title="Percentage">
|
||||
{alert}%
|
||||
</TableCellText>
|
||||
<TableCell>
|
||||
<Button
|
||||
text
|
||||
round
|
||||
ariaLabel="remove alert"
|
||||
on:click={() =>
|
||||
(alerts = alerts.filter((a) => a !== alert))}>
|
||||
<span class="icon-x" aria-hidden="true" />
|
||||
</Button>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
{/each}
|
||||
</TableBody>
|
||||
</Table>
|
||||
{/if}
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
|
||||
<svelte:fragment slot="actions">
|
||||
{#if $organization?.billingPlan === BillingPlan.FREE || $organization?.billingPlan === BillingPlan.GITHUB_EDUCATION}
|
||||
<Button
|
||||
secondary
|
||||
href={$upgradeURL}
|
||||
on:click={() => {
|
||||
trackEvent('click_organization_upgrade', {
|
||||
from: 'button',
|
||||
source: 'billing_alerts_card'
|
||||
});
|
||||
}}
|
||||
>Upgrade to Pro
|
||||
</Button>
|
||||
{:else}
|
||||
<Button disabled={isButtonDisabled} submit>Update</Button>
|
||||
{/if}
|
||||
</svelte:fragment>
|
||||
</CardGrid>
|
||||
</Form>
|
||||
</div>
|
||||
@@ -16,3 +16,5 @@ export const addCreditWizardStore = writable<{ coupon: string; paymentMethodId:
|
||||
|
||||
export const selectedInvoice = writable<Invoice>(null);
|
||||
export const showRetryModal = writable(false);
|
||||
|
||||
export const scrollToUpdateBudget = derived(page, ($page) => $page.url.hash.includes('#update-budget'));
|
||||
@@ -19,7 +19,7 @@
|
||||
<span class="text">View usage</span>
|
||||
</Button>
|
||||
<Button
|
||||
href={`${base}/organization-${$organization.$id}/billing`}
|
||||
href={`${base}/organization-${$organization.$id}/billing#update-budget`}
|
||||
secondary
|
||||
fullWidthMobile>
|
||||
<span class="text">Update limit</span>
|
||||
|
||||
Reference in new issue
Block a user