-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Billing UI changes #1552
base: main
Are you sure you want to change the base?
Billing UI changes #1552
Changes from 13 commits
869813e
6a2c718
c85d9c7
9523c1d
9896068
267aceb
b97710a
1461d5a
05ff3f6
27d7f07
62fb063
792b4e4
2b78dc5
dff6ecd
be917bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
<script lang="ts"> | ||
import { invalidate } from '$app/navigation'; | ||
import { Submit, trackError, trackEvent } from '$lib/actions/analytics'; | ||
import { CardGrid, Heading } from '$lib/components'; | ||
import { Dependencies } from '$lib/constants'; | ||
import { Alert, CardGrid, Heading } from '$lib/components'; | ||
import { BillingPlan, Dependencies } from '$lib/constants'; | ||
import { upgradeURL } from '$lib/stores/billing'; | ||
import { Button, Form, FormList, InputSelectSearch } from '$lib/elements/forms'; | ||
import { | ||
Table, | ||
|
@@ -39,7 +40,7 @@ | |
if (alerts.some((alert) => alert === selectedAlert)) { | ||
return; | ||
} | ||
if (alerts.length <= 2) { | ||
if (alerts.length <= 3) { | ||
alerts = [...alerts, selectedAlert ? selectedAlert : parseInt(search)]; | ||
search = ''; | ||
selectedAlert = null; | ||
|
@@ -59,7 +60,7 @@ | |
addNotification({ | ||
type: 'success', | ||
isHtml: true, | ||
message: `<span>A budget alert has been added to <b>${$organization.name}</b></span>` | ||
message: `<span> ${alerts.length === 0 ? 'Budget alerts removed from' : alerts.length > 1 ? `Budget alerts added to` : 'A budget alert has been added to'} <b>${$organization.name}</b> </span>` | ||
}); | ||
trackEvent(Submit.BudgetAlertsUpdate, { | ||
alerts | ||
|
@@ -78,65 +79,98 @@ | |
|
||
<Form onSubmit={updateBudget}> | ||
<CardGrid> | ||
<Heading tag="h2" size="6">Budget alerts</Heading> | ||
<Heading tag="h2" size="6">Billing alerts</Heading> | ||
|
||
<p class="text"> | ||
Get notified by email when your organization reaches or exceeds a percent of your | ||
specified budget cap. You can set a maximum of 3 alerts. | ||
{#if $organization?.billingPlan === BillingPlan.FREE} | ||
Get notified by email when your organization meets a percentage of your budget cap. <b | ||
>Free 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"> | ||
<FormList> | ||
<div class="u-flex u-gap-16"> | ||
<InputSelectSearch | ||
label="Percentage (%) of budget cap" | ||
placeholder="Select a percentage" | ||
id="alerts" | ||
{options} | ||
bind:search | ||
bind:value={selectedAlert} | ||
on:select={() => (search = selectedAlert.toString())} /> | ||
<div style="align-self: flex-end"> | ||
<Button | ||
secondary | ||
disabled={alerts.length > 2 || (!search && !selectedAlert)} | ||
on:click={addAlert}> | ||
Add alert | ||
</Button> | ||
{#if $organization?.billingPlan === BillingPlan.FREE} | ||
<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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we mention Scale here as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Scale isn't directly available as an option on upgrade when the current plan is on Free, right? |
||
</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 | ||
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)} | ||
on:click={addAlert}> | ||
Add alert | ||
</Button> | ||
</div> | ||
</div> | ||
</div> | ||
</FormList> | ||
</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 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"> | ||
<Button disabled={isButtonDisabled} submit>Update</Button> | ||
{#if $organization?.billingPlan === BillingPlan.FREE} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should you also be able to upgrade from Education plan? |
||
<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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't check for features based on the plan name, but check the currentPlan to see if a feature is there or not. Because does Education have the billing alert feature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think
currentPlan
hasbillingAlerts
flag setup on backend and sdk atm. Regarding Education plan, its disabled via Cloud's plans config.