Skip to content

Commit ef5d30e

Browse files
committed
Implemented reset
1 parent 5631938 commit ef5d30e

File tree

1 file changed

+22
-9
lines changed
  • apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.concurrency

1 file changed

+22
-9
lines changed

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

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,14 @@ export default function Page() {
262262
);
263263
}
264264

265+
function initialAllocation(environments: ConcurrencyResult["environments"]) {
266+
return new Map<string, number>(
267+
environments
268+
.filter((e) => e.type !== "DEVELOPMENT")
269+
.map((e) => [e.id, Math.max(0, e.maximumConcurrencyLimit - e.planConcurrencyLimit)])
270+
);
271+
}
272+
265273
function Upgradable({
266274
extraConcurrency,
267275
extraAllocatedConcurrency,
@@ -284,13 +292,7 @@ function Upgradable({
284292
const navigation = useNavigation();
285293
const isLoading = navigation.state !== "idle" && navigation.formMethod === "POST";
286294

287-
const [allocation, setAllocation] = useState(
288-
new Map<string, number>(
289-
environments
290-
.filter((e) => e.type !== "DEVELOPMENT")
291-
.map((e) => [e.id, Math.max(0, e.maximumConcurrencyLimit - e.planConcurrencyLimit)])
292-
)
293-
);
295+
const [allocation, setAllocation] = useState(initialAllocation(environments));
294296

295297
const allocated = Array.from(allocation.values()).reduce((e, acc) => e + acc, 0);
296298
const unallocated = extraConcurrency - allocated;
@@ -380,8 +382,19 @@ function Upgradable({
380382
) : (
381383
<div className="flex w-full items-center justify-between gap-3">
382384
<div className="flex items-center gap-1">
383-
<InformationCircleIcon className="size-4 text-text-bright" />
384-
<span>Save your changes or RESET</span>
385+
<InformationCircleIcon className="size-4 text-text-dimmed" />
386+
<span>
387+
Save your changes or{" "}
388+
<button
389+
className="inline text-indigo-500 hover:text-indigo-300"
390+
onClick={() => {
391+
setAllocation(initialAllocation(environments));
392+
}}
393+
>
394+
reset
395+
</button>
396+
.
397+
</span>
385398
</div>
386399
<Button
387400
variant="primary/small"

0 commit comments

Comments
 (0)