Skip to content

Commit

Permalink
feat(billing): Launch PAYG modal from url (#86066)
Browse files Browse the repository at this point in the history
### Description

Links to the subscription page may need to open the
on-demand/pay-as-you-go modal. Urls with the `#open-ondemand-modal` hash
will navigate to the page and open the modal automatically.

For example, an over quota email notification can now link directly to
the form:

<img width="748" alt="Screenshot 2025-02-26 at 1 12 36 PM"
src="https://github.com/user-attachments/assets/024d8ede-a24b-4298-8372-b83a1ccd2cf4"
/>
  • Loading branch information
jarrettscott authored Feb 28, 2025
1 parent b35693a commit 91d9b33
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions static/gsApp/views/subscriptionPage/overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {hasAccessToSubscriptionOverview, isAm3DsPlan} from 'getsentry/utils/bill
import {sortCategories} from 'getsentry/utils/dataCategory';
import withPromotions from 'getsentry/utils/withPromotions';
import ContactBillingMembers from 'getsentry/views/contactBillingMembers';
import {openOnDemandBudgetEditModal} from 'getsentry/views/onDemandBudgets/editOnDemandButton';

import openPerformanceQuotaCreditsPromoModal from './promotions/performanceQuotaCreditsPromo';
import openPerformanceReservedTransactionsDiscountModal from './promotions/performanceReservedTransactionsPromo';
Expand Down Expand Up @@ -132,6 +133,22 @@ function Overview({api, location, subscription, organization, promotionData}: Pr
) {
openCodecovModal({organization});
}

// Open on-demand budget modal if hash fragment present and user has access
if (
window.location.hash === '#open-ondemand-modal' &&
subscription.supportsOnDemand &&
hasAccessToSubscriptionOverview(subscription, organization)
) {
openOnDemandBudgetEditModal({organization, subscription});

// Clear hash to prevent modal reopening on refresh
window.history.replaceState(
null,
'',
window.location.pathname + window.location.search
);
}
}, [organization, location.query, subscription, promotionData, api]);

useEffect(
Expand Down

0 comments on commit 91d9b33

Please sign in to comment.