feat(factories): show hosted credit warning banner on the workspace board - #7242
Merged
Merged
Conversation
Extend the banner and its lib/hostedCreditEmpty helpers to support a new 'low' warning level in addition to the existing 'empty' one: - 'empty' (remaining hosted credit <= $0): severe red styling. - 'low' (0 < remaining <= $20 / 2000 cents): amber warning styling. hostedCreditWarningLevel() replaces the old boolean-only threshold check and now also triggers for the low-credit range. shouldShowHostedCreditEmptyBanner() stays as a boolean wrapper around it for compatibility. The banner's action button now supports two shapes: a link to Organization Spending (existing Work Orders / Missions behavior, unchanged) or a plain 'Go to billing' button that takes an onClick (no navigation wired yet — there is no billing page). Signed-off-by: SuperPlane Agent <superplaneagent@superplane.com> Co-authored-by: Miyat Miletic <mijat.miletic98@gmail.com>
…oard Render the hosted credit warning banner (empty/low) at the top of the workspace board (LinesPage), above the line header, using a new 'billing' action variant of useHostedCreditEmptyBanner: the button does not link to Organization Spending like Tasks/Missions do, since there is no billing page yet — it is a no-op 'Go to billing' button. Add a LOW_CREDIT_USAGE_REPORT fixture and cover the empty/low/none states with an integration spec and Storybook stories. Signed-off-by: SuperPlane Agent <superplaneagent@superplane.com> Co-authored-by: Miyat Miletic <mijat.miletic98@gmail.com>
There was a problem hiding this comment.
superplanehq-integration[bot] has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
Contributor
Author
|
👋 Commands for maintainers:
|
Contributor
Author
|
Maintainers: comment |
Implement the BoardGoToBillingButton story onGoToBilling callback with console logging so the interaction is observable in Storybook, matching the project convention of logging interactive story callbacks. Signed-off-by: SuperPlane Agent <superplaneagent@superplane.com>
Signed-off-by: Mijat Miletic <mijat.miletic98@gmail.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Miyat Miletic <mytmlt@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SUPER-148
This change adds a hosted credit warning banner to the workspace board (the Lines / board view). The banner tells the user when the organization is out of hosted credit or is close to running out. It reuses and extends the existing
HostedCreditEmptyBannercomponent instead of adding a new one.UI
HostedCreditEmptyBannernow takes alevelprop with two values.emptymeans remaining hosted credit is $0 or less.lowmeans remaining hosted credit is above $0 and at or below $20 (2000 cents). Theemptylevel uses red, severe styling. Thelowlevel uses amber, warning styling.The banner action button now supports two shapes. When the caller passes
spendingHref, the button is a link to Organization Spending, same as before. When the caller passesonGoToBillinginstead, the button reads "Go to billing" and calls that handler. There is no billing page yet, so this button is a no-op for now.web_src/src/pages/factories/lib/hostedCreditEmpty.tshas a newhostedCreditWarningLevelfunction. It readsremainingCreditCents,grantTotalCents,superplaneGrantCents,purchasedCreditCents, andbillingEnabled, and returns"empty","low", ornull. It returnsnullwhen remaining credit is comfortably above the low-credit threshold, and also when the organization never had hosted credit (no grant, no purchase, billing off), so the banner does not warn about credit that was never expected to run out.shouldShowHostedCreditEmptyBannerstays in place as a boolean wrapper around this function, so it keeps working for any other caller.web_src/src/pages/factories/lib/useHostedCreditEmptyBanner.tsxgets a new options argument with anactionfield.action: "spending"is the default and keeps the current behavior on the Tasks and Missions pages: the button links to Organization Spending.action: "billing"renders the new no-op "Go to billing" button. This keeps the Tasks and Missions pages working exactly as before, while the board opts into the new button.web_src/src/pages/factories/pages/LinesPage.tsxcalls the hook withaction: "billing"and renders the banner aboveLineDetailHeader, at the top of the board. When remaining hosted credit is above $20, no banner shows. When it is $0 or less, a red banner shows. When it is between $0 and $20, an amber banner shows.Tests and Storybook
Unit tests in
hostedCreditEmpty.spec.tsandHostedCreditEmptyBanner.spec.tsxcover both warning levels, the boundary at $20, the red/amber styles, and the no-op billing button. A new integration test,LinesPage.hostedCreditBanner.spec.tsx, checks that the board shows no banner, a red banner, or an amber banner, based on the organization's remaining hosted credit. Storybook stories forHostedCreditEmptyBannerand for the Lines board cover the low-credit state and the board's billing button variant.API, workers, database
No changes. This task only adds UI logic that reads the existing organization workspace usage data.
Created via SuperPlane.
The PR appears safe to merge.