Skip to content

Commit 568aba8

Browse files
Merge pull request #1733 from appwrite/revert-1721-revert-1675-feat-budget-nullable
Revert "Revert "Console Feat: make budget cap nullable""
2 parents 27fded5 + f3507c8 commit 568aba8

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

src/routes/(console)/create-organization/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
171171
trackEvent(Submit.OrganizationCreate, {
172172
plan: tierToPlan(billingPlan)?.name,
173-
budget_cap_enabled: !!billingBudget,
173+
budget_cap_enabled: billingBudget !== null,
174174
members_invited: collaborators?.length
175175
});
176176

src/routes/(console)/organization-[organization]/billing/+page.svelte

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<script lang="ts">
22
import { Container } from '$lib/layout';
33
import { organization } from '$lib/stores/organization';
4-
import BudgetAlert from './budgetAlert.svelte';
54
import BudgetCap from './budgetCap.svelte';
65
import PlanSummary from './planSummary.svelte';
76
import BillingAddress from './billingAddress.svelte';
@@ -128,7 +127,6 @@
128127
<BillingAddress billingAddress={data?.billingAddress} />
129128
<TaxId />
130129
<BudgetCap />
131-
<BudgetAlert />
132130
<AvailableCredit />
133131
</Container>
134132

src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import { sdk } from '$lib/stores/sdk';
2121
import { onMount } from 'svelte';
2222
23+
export let alertsEnabled = false;
24+
2325
let search: string;
2426
let selectedAlert: number;
2527
let alerts: number[] = [];
@@ -74,7 +76,8 @@
7476
}
7577
}
7678
77-
$: isButtonDisabled = symmetricDifference(alerts, $organization.budgetAlerts).length === 0;
79+
$: isButtonDisabled =
80+
symmetricDifference(alerts, $organization.budgetAlerts).length === 0 || !alertsEnabled;
7881
</script>
7982

8083
<Form onSubmit={updateBudget}>
@@ -107,6 +110,7 @@
107110

108111
<div class="u-flex u-gap-16">
109112
<InputSelectSearch
113+
disabled={!alertsEnabled}
110114
label="Percentage (%) of budget cap"
111115
placeholder="Select a percentage"
112116
id="alerts"
@@ -118,7 +122,9 @@
118122
<div style="align-self: flex-end">
119123
<Button
120124
secondary
121-
disabled={alerts.length > 3 || (!search && !selectedAlert)}
125+
disabled={alerts.length > 3 ||
126+
(!search && !selectedAlert) ||
127+
!alertsEnabled}
122128
on:click={addAlert}>
123129
Add alert
124130
</Button>

src/routes/(console)/organization-[organization]/billing/budgetCap.svelte

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
import { organization, currentPlan } from '$lib/stores/organization';
1010
import { sdk } from '$lib/stores/sdk';
1111
import { onMount } from 'svelte';
12+
import BudgetAlert from './budgetAlert.svelte';
1213
1314
let capActive = false;
1415
let budget: number;
1516
1617
onMount(() => {
1718
budget = $organization?.billingBudget;
18-
capActive = !!$organization?.billingBudget;
19+
capActive = $organization?.billingBudget !== null;
1920
});
2021
2122
async function updateBudget() {
@@ -44,7 +45,7 @@
4445
}
4546
4647
$: if (!capActive) {
47-
budget = 0;
48+
budget = null;
4849
}
4950
</script>
5051

@@ -113,3 +114,5 @@
113114
</svelte:fragment>
114115
</CardGrid>
115116
</Form>
117+
118+
<BudgetAlert alertsEnabled={capActive && budget > 0} />

0 commit comments

Comments
 (0)