From b3851cd5682805b634ac2c9ca3b41abf76f7b02a Mon Sep 17 00:00:00 2001 From: Darshan Date: Mon, 17 Mar 2025 14:45:19 +0530 Subject: [PATCH] update: scroll to card. --- .../billing/budgetAlert.svelte | 215 ++++++++++-------- .../billing/store.ts | 2 + .../budgetLimitAlert.svelte | 2 +- 3 files changed, 119 insertions(+), 100 deletions(-) diff --git a/src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte b/src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte index 07a5db67a..3bc8c9f66 100644 --- a/src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte +++ b/src/routes/(console)/organization-[organization]/billing/budgetAlert.svelte @@ -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' + }); + }); + } -
- - Billing alerts +
+ + + Billing alerts -

- {#if !$currentPlan.budgeting} - Get notified by email when your organization meets a percentage of your budget cap. {tierToPlan($organization.billingPlan).name} organizations will receive one notification - at 75% resource usage. - {:else} - Get notified by email when your organization meets or exceeds a percentage of your - specified billing alert(s). - {/if} -

- - {#if !$currentPlan.budgeting} - - Billing alerts are a Pro plan feature - - Upgrade to a Pro plan to manage when you receive billing alerts for your organization. - - {:else} - - - You can set a maximum of 4 billing alerts per organization. - - -
- (search = selectedAlert.toString())} /> -
- -
-
-
- - {#if alerts.length} - - - Alert at budget cap % - - - - {#each alerts.sort() as alert} - - - {alert}% - - - - - - {/each} - -
+

+ {#if !$currentPlan.budgeting} + Get notified by email when your organization meets a percentage of your budget + cap. {tierToPlan($organization.billingPlan).name} organizations will receive one + notification at 75% resource usage. + {:else} + Get notified by email when your organization meets or exceeds a percentage of + your specified billing alert(s). {/if} - {/if} - +

+ + {#if !$currentPlan.budgeting} + + Billing alerts are a Pro plan feature + + Upgrade to a Pro plan to manage when you receive billing alerts for your organization. + + {:else} + + + You can set a maximum of 4 billing alerts per organization. + - - {#if $organization?.billingPlan === BillingPlan.FREE || $organization?.billingPlan === BillingPlan.GITHUB_EDUCATION} - - {:else} - - {/if} - -
- +
+ (search = selectedAlert.toString())} /> +
+ +
+
+ + + {#if alerts.length} + + + Alert at budget cap % + + + + {#each alerts.sort() as alert} + + + {alert}% + + + + + + {/each} + +
+ {/if} + {/if} + + + + {#if $organization?.billingPlan === BillingPlan.FREE || $organization?.billingPlan === BillingPlan.GITHUB_EDUCATION} + + {:else} + + {/if} + + + +
diff --git a/src/routes/(console)/organization-[organization]/billing/store.ts b/src/routes/(console)/organization-[organization]/billing/store.ts index ca081c291..9359f72e8 100644 --- a/src/routes/(console)/organization-[organization]/billing/store.ts +++ b/src/routes/(console)/organization-[organization]/billing/store.ts @@ -16,3 +16,5 @@ export const addCreditWizardStore = writable<{ coupon: string; paymentMethodId: export const selectedInvoice = writable(null); export const showRetryModal = writable(false); + +export const scrollToUpdateBudget = derived(page, ($page) => $page.url.hash.includes('#update-budget')); \ No newline at end of file diff --git a/src/routes/(console)/organization-[organization]/budgetLimitAlert.svelte b/src/routes/(console)/organization-[organization]/budgetLimitAlert.svelte index fbe101f9b..bffa7e44a 100644 --- a/src/routes/(console)/organization-[organization]/budgetLimitAlert.svelte +++ b/src/routes/(console)/organization-[organization]/budgetLimitAlert.svelte @@ -19,7 +19,7 @@ View usage