@@ -9,17 +9,19 @@ import {
99 useOptionalOrganization ,
1010 useOrganization ,
1111 useBillingLimit ,
12+ useCanManageBilling ,
1213} from "~/hooks/useOrganizations" ;
1314import { useOptionalProject , useProject } from "~/hooks/useProject" ;
1415import { useShowSelfServe } from "~/hooks/useShowSelfServe" ;
1516import { useCurrentPlan } from "~/routes/_app.orgs.$organizationSlug/route" ;
1617import { v3BillingLimitsPath , v3BillingPath , v3QueuesPath } from "~/utils/pathBuilder" ;
18+ import { ENVIRONMENT_PAUSE_SOURCE_BILLING_LIMIT } from "~/utils/environmentPauseSource" ;
1719
1820function getUpgradeResetDate ( ) : Date {
1921 const nextMonth = new Date ( ) ;
20- nextMonth . setUTCMonth ( nextMonth . getMonth ( ) + 1 ) ;
2122 nextMonth . setUTCDate ( 1 ) ;
2223 nextMonth . setUTCHours ( 0 , 0 , 0 , 0 ) ;
24+ nextMonth . setUTCMonth ( nextMonth . getUTCMonth ( ) + 1 ) ;
2325 return nextMonth ;
2426}
2527
@@ -41,7 +43,7 @@ export function OrgBanner() {
4143 project &&
4244 environment &&
4345 environment . paused &&
44- environment . pauseSource !== "BILLING_LIMIT"
46+ environment . pauseSource !== ENVIRONMENT_PAUSE_SOURCE_BILLING_LIMIT
4547 ) ;
4648 const isArchived = ! ! ( organization && project && environment && environment . archivedAt ) ;
4749
@@ -77,30 +79,39 @@ export function OrgBanner() {
7779
7880function LimitRejectedBanner ( ) {
7981 const organization = useOrganization ( ) ;
82+ const showSelfServe = useShowSelfServe ( ) ;
83+ const canManageBilling = useCanManageBilling ( ) ;
84+ const canResolve = showSelfServe && canManageBilling ;
8085
8186 return (
8287 < AnimatedOrgBannerBar
8388 show
8489 variant = "error"
8590 action = {
86- < LinkButton
87- variant = "danger/small"
88- leadingIconClassName = "px-0"
89- to = { v3BillingLimitsPath ( organization ) }
90- >
91- Resolve
92- </ LinkButton >
91+ canResolve ? (
92+ < LinkButton
93+ variant = "danger/small"
94+ leadingIconClassName = "px-0"
95+ to = { v3BillingLimitsPath ( organization ) }
96+ >
97+ Resolve
98+ </ LinkButton >
99+ ) : undefined
93100 }
94101 >
95102 < span className = "font-medium" > Billing limit exceeded</ span > — New triggers are currently
96103 blocked.
104+ { ! canResolve ? " Contact your organization administrator to resolve this issue." : null }
97105 </ AnimatedOrgBannerBar >
98106 ) ;
99107}
100108
101109function LimitGraceBanner ( ) {
102110 const organization = useOrganization ( ) ;
103111 const billingLimit = useBillingLimit ( ) ;
112+ const showSelfServe = useShowSelfServe ( ) ;
113+ const canManageBilling = useCanManageBilling ( ) ;
114+ const canResolve = showSelfServe && canManageBilling ;
104115
105116 const graceEndsAt =
106117 billingLimit ?. isConfigured && billingLimit . limitState . status === "grace"
@@ -112,35 +123,43 @@ function LimitGraceBanner() {
112123 show = { graceEndsAt !== null }
113124 variant = "error"
114125 action = {
115- < LinkButton
116- variant = "danger/small"
117- leadingIconClassName = "px-0"
118- to = { v3BillingLimitsPath ( organization ) }
119- >
120- Resolve
121- </ LinkButton >
126+ canResolve ? (
127+ < LinkButton
128+ variant = "danger/small"
129+ leadingIconClassName = "px-0"
130+ to = { v3BillingLimitsPath ( organization ) }
131+ >
132+ Resolve
133+ </ LinkButton >
134+ ) : undefined
122135 }
123136 >
124137 < span className = "font-medium" > Billing limit reached</ span > — Queues have been paused. New runs
125138 will continue to queue until < DateTime date = { graceEndsAt ?? new Date ( ) } includeTime /> .
139+ { ! canResolve ? " Contact your organization administrator to resolve this issue." : null }
126140 </ AnimatedOrgBannerBar >
127141 ) ;
128142}
129143
130144function NoLimitConfiguredBanner ( ) {
131145 const organization = useOrganization ( ) ;
146+ const canManageBilling = useCanManageBilling ( ) ;
132147
133148 return (
134149 < AnimatedOrgBannerBar
135150 show
136151 variant = "warning"
137152 action = {
138- < LinkButton variant = "tertiary/small" to = { v3BillingLimitsPath ( organization ) } >
139- Configure billing limit
140- </ LinkButton >
153+ canManageBilling ? (
154+ < LinkButton variant = "tertiary/small" to = { v3BillingLimitsPath ( organization ) } >
155+ Configure billing limit
156+ </ LinkButton >
157+ ) : undefined
141158 }
142159 >
143- Protect your organization from unexpected usage spikes.
160+ { canManageBilling
161+ ? "Protect your organization from unexpected usage spikes."
162+ : "Billing limits are not configured for this organization. Contact an organization administrator to configure them." }
144163 </ AnimatedOrgBannerBar >
145164 ) ;
146165}
0 commit comments