Skip to content

Commit b7cf7f7

Browse files
committed
fix: improve ui
1 parent ede17bf commit b7cf7f7

File tree

1 file changed

+63
-59
lines changed

1 file changed

+63
-59
lines changed

studio/src/pages/[organizationSlug]/cache-warmer.tsx

Lines changed: 63 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -87,70 +87,74 @@ const CacheWarmerPage: NextPageWithLayout = () => {
8787
}
8888

8989
return (
90-
<div className="space-y-6 rounded-lg border p-6">
91-
<div className="flex w-full items-center justify-between">
92-
<div className="flex flex-col gap-y-1">
93-
<h3 className="font-semibold tracking-tight">Enable Cache Warmer</h3>
94-
<p className="text-sm text-muted-foreground">
95-
{!!cacheWarmerFeature?.enabled
96-
? "Enable cache warmer to warm the router with your top opeartions."
97-
: "Upgrade your billing plan to use this cacheWarmer."}{" "}
98-
<Link
99-
href={docsBaseURL + "/concepts/cache-warmer"}
100-
className="text-primary"
101-
target="_blank"
102-
rel="noreferrer"
103-
>
104-
Learn more
105-
</Link>
106-
</p>
107-
</div>
108-
<Switch
109-
checked={cacheWarmerEnabled}
110-
disabled={
111-
!cacheWarmerFeature?.enabled ||
112-
!checkUserAccess({
113-
rolesToBe: ["admin", "developer"],
114-
userRoles: user?.currentOrganization.roles || [],
115-
})
116-
}
117-
onCheckedChange={(checked) => {
118-
setCacheWarmerEnabled(checked);
119-
mutate(
120-
{
121-
enableCacheWarmer: checked,
122-
namespace: namespace || "default",
123-
maxOperationsCount: checked ? 100 : undefined,
124-
},
125-
{
126-
onSuccess: (d) => {
127-
if (d.response?.code === EnumStatusCode.OK) {
90+
<div className="flex flex-col gap-y-6">
91+
<div className="space-y-6 rounded-lg border p-6">
92+
<div className="flex w-full items-center justify-between">
93+
<div className="flex flex-col gap-y-1">
94+
<h3 className="font-semibold tracking-tight">
95+
Enable Cache Warmer
96+
</h3>
97+
<p className="text-sm text-muted-foreground">
98+
{!!cacheWarmerFeature?.enabled
99+
? "Enable cache warmer to warm the router with your top opeartions."
100+
: "Upgrade your billing plan to use this cacheWarmer."}{" "}
101+
<Link
102+
href={docsBaseURL + "/concepts/cache-warmer"}
103+
className="text-primary"
104+
target="_blank"
105+
rel="noreferrer"
106+
>
107+
Learn more
108+
</Link>
109+
</p>
110+
</div>
111+
<Switch
112+
checked={cacheWarmerEnabled}
113+
disabled={
114+
!cacheWarmerFeature?.enabled ||
115+
!checkUserAccess({
116+
rolesToBe: ["admin", "developer"],
117+
userRoles: user?.currentOrganization.roles || [],
118+
})
119+
}
120+
onCheckedChange={(checked) => {
121+
setCacheWarmerEnabled(checked);
122+
mutate(
123+
{
124+
enableCacheWarmer: checked,
125+
namespace: namespace || "default",
126+
maxOperationsCount: checked ? 100 : undefined,
127+
},
128+
{
129+
onSuccess: (d) => {
130+
if (d.response?.code === EnumStatusCode.OK) {
131+
toast({
132+
description: checked
133+
? "Cache Warmer enabled successfully."
134+
: "Cache Warmer disabled successfully",
135+
duration: 3000,
136+
});
137+
} else if (d.response?.details) {
138+
toast({
139+
description: d.response.details,
140+
duration: 3000,
141+
});
142+
}
143+
refetch();
144+
},
145+
onError: (error) => {
128146
toast({
129147
description: checked
130-
? "Cache Warmer enabled successfully."
131-
: "Cache Warmer disabled successfully",
132-
duration: 3000,
133-
});
134-
} else if (d.response?.details) {
135-
toast({
136-
description: d.response.details,
148+
? "Could not enable the cache warmer. Please try again."
149+
: "Could not disable the cache warmer. Please try again.",
137150
duration: 3000,
138151
});
139-
}
140-
refetch();
141-
},
142-
onError: (error) => {
143-
toast({
144-
description: checked
145-
? "Could not enable the cache warmer. Please try again."
146-
: "Could not disable the cache warmer. Please try again.",
147-
duration: 3000,
148-
});
152+
},
149153
},
150-
},
151-
);
152-
}}
153-
/>
154+
);
155+
}}
156+
/>
157+
</div>
154158
</div>
155159
<CacheWarmerConfig
156160
key={currentOperationsCount}

0 commit comments

Comments
 (0)