Skip to content

Commit 9661a04

Browse files
committed
Change the Upgrade button logic for batch rate limit to be plan based
1 parent 58ba3e5 commit 9661a04

File tree

1 file changed

+38
-7
lines changed
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.limits

1 file changed

+38
-7
lines changed

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.limits/route.tsx

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ export default function Page() {
151151
{/* Rate Limits Section */}
152152
<RateLimitsSection
153153
rateLimits={data.rateLimits}
154+
isOnTopPlan={data.isOnTopPlan}
155+
billingPath={organizationBillingPath(organization)}
154156
organization={organization}
155157
project={project}
156158
environment={environment}
@@ -244,11 +246,15 @@ function ConcurrencySection({ concurrencyPath }: { concurrencyPath: string }) {
244246

245247
function RateLimitsSection({
246248
rateLimits,
249+
isOnTopPlan,
250+
billingPath,
247251
organization,
248252
project,
249253
environment,
250254
}: {
251255
rateLimits: LimitsResult["rateLimits"];
256+
isOnTopPlan: boolean;
257+
billingPath: string;
252258
organization: ReturnType<typeof useOrganization>;
253259
project: ReturnType<typeof useProject>;
254260
environment: ReturnType<typeof useEnvironment>;
@@ -322,15 +328,27 @@ function RateLimitsSection({
322328
</TableRow>
323329
</TableHeader>
324330
<TableBody>
325-
<RateLimitRow info={rateLimits.api} />
326-
<RateLimitRow info={rateLimits.batch} />
331+
<RateLimitRow info={rateLimits.api} isOnTopPlan={isOnTopPlan} billingPath={billingPath} />
332+
<RateLimitRow
333+
info={rateLimits.batch}
334+
isOnTopPlan={isOnTopPlan}
335+
billingPath={billingPath}
336+
/>
327337
</TableBody>
328338
</Table>
329339
</div>
330340
);
331341
}
332342

333-
function RateLimitRow({ info }: { info: RateLimitInfo }) {
343+
function RateLimitRow({
344+
info,
345+
isOnTopPlan,
346+
billingPath,
347+
}: {
348+
info: RateLimitInfo;
349+
isOnTopPlan: boolean;
350+
billingPath: string;
351+
}) {
334352
const maxTokens = info.config.type === "tokenBucket" ? info.config.maxTokens : info.config.tokens;
335353
const percentage =
336354
info.currentTokens !== null && maxTokens > 0 ? info.currentTokens / maxTokens : null;
@@ -372,10 +390,23 @@ function RateLimitRow({ info }: { info: RateLimitInfo }) {
372390
</TableCell>
373391
<TableCell alignment="right">
374392
<div className="flex justify-end">
375-
<Feedback
376-
button={<Button variant="secondary/small">Contact us</Button>}
377-
defaultValue="help"
378-
/>
393+
{info.name === "Batch rate limit" ? (
394+
isOnTopPlan ? (
395+
<Feedback
396+
button={<Button variant="secondary/small">Contact us</Button>}
397+
defaultValue="help"
398+
/>
399+
) : (
400+
<LinkButton to={billingPath} variant="secondary/small">
401+
View plans
402+
</LinkButton>
403+
)
404+
) : (
405+
<Feedback
406+
button={<Button variant="secondary/small">Contact us</Button>}
407+
defaultValue="help"
408+
/>
409+
)}
379410
</div>
380411
</TableCell>
381412
</TableRow>

0 commit comments

Comments
 (0)