99 useOptionalOrganization ,
1010 useOrganization ,
1111 useBillingLimit ,
12+ useCanManageBilling ,
1213} from "~/hooks/useOrganizations" ;
1314import { useOptionalProject , useProject } from "~/hooks/useProject" ;
1415import { useShowSelfServe } from "~/hooks/useShowSelfServe" ;
@@ -17,9 +18,9 @@ import { v3BillingLimitsPath, v3BillingPath, v3QueuesPath } from "~/utils/pathBu
1718
1819function getUpgradeResetDate ( ) : Date {
1920 const nextMonth = new Date ( ) ;
20- nextMonth . setUTCMonth ( nextMonth . getMonth ( ) + 1 ) ;
2121 nextMonth . setUTCDate ( 1 ) ;
2222 nextMonth . setUTCHours ( 0 , 0 , 0 , 0 ) ;
23+ nextMonth . setUTCMonth ( nextMonth . getUTCMonth ( ) + 1 ) ;
2324 return nextMonth ;
2425}
2526
@@ -77,30 +78,39 @@ export function OrgBanner() {
7778
7879function LimitRejectedBanner ( ) {
7980 const organization = useOrganization ( ) ;
81+ const showSelfServe = useShowSelfServe ( ) ;
82+ const canManageBilling = useCanManageBilling ( ) ;
83+ const canResolve = showSelfServe && canManageBilling ;
8084
8185 return (
8286 < AnimatedOrgBannerBar
8387 show
8488 variant = "error"
8589 action = {
86- < LinkButton
87- variant = "danger/small"
88- leadingIconClassName = "px-0"
89- to = { v3BillingLimitsPath ( organization ) }
90- >
91- Resolve
92- </ LinkButton >
90+ canResolve ? (
91+ < LinkButton
92+ variant = "danger/small"
93+ leadingIconClassName = "px-0"
94+ to = { v3BillingLimitsPath ( organization ) }
95+ >
96+ Resolve
97+ </ LinkButton >
98+ ) : undefined
9399 }
94100 >
95101 < span className = "font-medium" > Billing limit exceeded</ span > — New triggers are currently
96102 blocked.
103+ { ! canResolve ? " Contact your organization administrator to resolve this issue." : null }
97104 </ AnimatedOrgBannerBar >
98105 ) ;
99106}
100107
101108function LimitGraceBanner ( ) {
102109 const organization = useOrganization ( ) ;
103110 const billingLimit = useBillingLimit ( ) ;
111+ const showSelfServe = useShowSelfServe ( ) ;
112+ const canManageBilling = useCanManageBilling ( ) ;
113+ const canResolve = showSelfServe && canManageBilling ;
104114
105115 const graceEndsAt =
106116 billingLimit ?. isConfigured && billingLimit . limitState . status === "grace"
@@ -112,35 +122,43 @@ function LimitGraceBanner() {
112122 show = { graceEndsAt !== null }
113123 variant = "error"
114124 action = {
115- < LinkButton
116- variant = "danger/small"
117- leadingIconClassName = "px-0"
118- to = { v3BillingLimitsPath ( organization ) }
119- >
120- Resolve
121- </ LinkButton >
125+ canResolve ? (
126+ < LinkButton
127+ variant = "danger/small"
128+ leadingIconClassName = "px-0"
129+ to = { v3BillingLimitsPath ( organization ) }
130+ >
131+ Resolve
132+ </ LinkButton >
133+ ) : undefined
122134 }
123135 >
124136 < span className = "font-medium" > Billing limit reached</ span > — Queues have been paused. New runs
125137 will continue to queue until < DateTime date = { graceEndsAt ?? new Date ( ) } includeTime /> .
138+ { ! canResolve ? " Contact your organization administrator to resolve this issue." : null }
126139 </ AnimatedOrgBannerBar >
127140 ) ;
128141}
129142
130143function NoLimitConfiguredBanner ( ) {
131144 const organization = useOrganization ( ) ;
145+ const canManageBilling = useCanManageBilling ( ) ;
132146
133147 return (
134148 < AnimatedOrgBannerBar
135149 show
136150 variant = "warning"
137151 action = {
138- < LinkButton variant = "tertiary/small" to = { v3BillingLimitsPath ( organization ) } >
139- Configure billing limit
140- </ LinkButton >
152+ canManageBilling ? (
153+ < LinkButton variant = "tertiary/small" to = { v3BillingLimitsPath ( organization ) } >
154+ Configure billing limit
155+ </ LinkButton >
156+ ) : undefined
141157 }
142158 >
143- Protect your organization from unexpected usage spikes.
159+ { canManageBilling
160+ ? "Protect your organization from unexpected usage spikes."
161+ : "Billing limits are not configured for this organization. Contact an organization administrator to configure them." }
144162 </ AnimatedOrgBannerBar >
145163 ) ;
146164}
0 commit comments