Skip to content

Commit de6c1a7

Browse files
authored
Merge pull request #2972 from Harikrishnan1367709/Requests-Warning-Conditional-Render--#2971
feat(requests): conditionally render traefik reload warning
2 parents 7948721 + 615d89e commit de6c1a7

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed

apps/dokploy/components/dashboard/requests/show-requests.tsx

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,25 @@ export const ShowRequests = () => {
6565
to: Date | undefined;
6666
}>(getDefaultDateRange());
6767

68+
// Check if logs exist to determine if traefik has been reloaded
69+
// Only fetch when active to minimize network calls
70+
const { data: statsLogsCheck } = api.settings.readStatsLogs.useQuery(
71+
{
72+
page: {
73+
pageIndex: 0,
74+
pageSize: 1,
75+
},
76+
},
77+
{
78+
enabled: !!isActive,
79+
refetchInterval: 5000, // Check every 5 seconds when active
80+
},
81+
);
82+
83+
// Determine if warning should be shown
84+
// Show warning only if active but no logs exist yet
85+
const shouldShowWarning = isActive && (statsLogsCheck?.totalCount ?? 0) === 0;
86+
6887
useEffect(() => {
6988
if (logCleanupStatus) {
7089
setCronExpression(logCleanupStatus.cronExpression || "0 0 * * *");
@@ -85,16 +104,18 @@ export const ShowRequests = () => {
85104
See all the incoming requests that pass trough Traefik
86105
</CardDescription>
87106

88-
<AlertBlock type="warning">
89-
When you activate, you need to reload traefik to apply the
90-
changes, you can reload traefik in{" "}
91-
<Link
92-
href="/dashboard/settings/server"
93-
className="text-primary"
94-
>
95-
Settings
96-
</Link>
97-
</AlertBlock>
107+
{shouldShowWarning && (
108+
<AlertBlock type="warning">
109+
When you activate, you need to reload traefik to apply the
110+
changes, you can reload traefik in{" "}
111+
<Link
112+
href="/dashboard/settings/server"
113+
className="text-primary"
114+
>
115+
Settings
116+
</Link>
117+
</AlertBlock>
118+
)}
98119
</CardHeader>
99120
<CardContent className="space-y-2 py-8 border-t">
100121
<div className="flex w-full gap-4 justify-end items-center">

0 commit comments

Comments
 (0)