Skip to content

Commit 7687e6d

Browse files
authored
fix: show save button in VRL snippet form (#17)
* fix: show save button in VRL snippet form Hide the snippet list when the creation form is open so the Cancel/Create buttons aren't clipped by the container overflow. * feat: embed dev-SHA version in agent Docker image Use dev-<sha> version string in Docker agent builds to match the binary release format, enabling proper version detection in the fleet UI. The image still uses a single rolling 'dev' tag. * fix: clamp reduction percentage to zero minimum When sinks retry failed events, eventsOut can exceed eventsIn, producing negative reduction values like -201%. Clamp to 0%. * fix: navigate to list page when switching environment on detail view When changing environment while viewing a pipeline editor or fleet detail page, redirect to the parent list page to avoid showing stale data from a different environment. * fix: remove height constraint when snippet form is open Apply max-h-64 and overflow-hidden only when browsing snippets. When the form is open, remove constraints so buttons are visible.
1 parent acc199e commit 7687e6d

5 files changed

Lines changed: 21 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ jobs:
123123
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
124124
echo "value=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
125125
else
126-
echo "value=dev" >> "$GITHUB_OUTPUT"
126+
echo "value=dev-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
127127
fi
128128
129129
- uses: docker/setup-buildx-action@v3

src/app/(dashboard)/pipelines/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function getReductionPercent(totals: { eventsIn: bigint; eventsOut: bigint }): n
7171
const evIn = Number(totals.eventsIn);
7272
const evOut = Number(totals.eventsOut);
7373
if (evIn === 0) return null;
74-
return (1 - evOut / evIn) * 100;
74+
return Math.max(0, (1 - evOut / evIn) * 100);
7575
}
7676

7777
function reductionColor(pct: number): string {

src/components/environment-selector.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"use client";
22

3-
import { useEffect, useMemo } from "react";
3+
import { useEffect, useMemo, useCallback } from "react";
44
import Link from "next/link";
5+
import { usePathname, useRouter } from "next/navigation";
56
import { useQuery } from "@tanstack/react-query";
67
import { useTRPC } from "@/trpc/client";
78
import { useEnvironmentStore } from "@/stores/environment-store";
@@ -23,6 +24,18 @@ export function EnvironmentSelector() {
2324
const { selectedEnvironmentId, setSelectedEnvironmentId, setIsSystemEnvironment } =
2425
useEnvironmentStore();
2526
const selectedTeamId = useTeamStore((s) => s.selectedTeamId);
27+
const pathname = usePathname();
28+
const router = useRouter();
29+
30+
// Navigate back to list pages when switching environments from a detail page
31+
const handleEnvironmentChange = useCallback((id: string) => {
32+
setSelectedEnvironmentId(id);
33+
const detailRoutes = ["/pipelines/", "/fleet/"];
34+
if (detailRoutes.some((route) => pathname.startsWith(route) && pathname !== route)) {
35+
const parentRoute = detailRoutes.find((route) => pathname.startsWith(route));
36+
if (parentRoute) router.push(parentRoute.replace(/\/$/, ""));
37+
}
38+
}, [setSelectedEnvironmentId, pathname, router]);
2639

2740
const envsQuery = useQuery(
2841
trpc.environment.list.queryOptions(
@@ -79,7 +92,7 @@ export function EnvironmentSelector() {
7992
return (
8093
<Select
8194
value={selectedEnvironmentId ?? ""}
82-
onValueChange={setSelectedEnvironmentId}
95+
onValueChange={handleEnvironmentChange}
8396
>
8497
<SelectTrigger className="h-8 w-[180px] text-xs">
8598
<Layers className="mr-1.5 h-3.5 w-3.5 text-muted-foreground" />

src/components/flow/vrl-snippet-drawer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export function VrlSnippetDrawer({ onInsert }: VrlSnippetDrawerProps) {
125125
};
126126

127127
return (
128-
<div className="flex max-h-64 w-full flex-col overflow-hidden rounded border bg-muted/20">
128+
<div className={`flex w-full flex-col rounded border bg-muted/20 ${showForm ? "" : "max-h-64 overflow-hidden"}`}>
129129
<div className="border-b p-2 flex items-center gap-2">
130130
<div className="relative flex-1">
131131
<Search className="absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" />
@@ -190,7 +190,7 @@ export function VrlSnippetDrawer({ onInsert }: VrlSnippetDrawerProps) {
190190
</div>
191191
</div>
192192
)}
193-
<ScrollArea className="flex-1 min-h-0">
193+
{!showForm && <ScrollArea className="flex-1 min-h-0">
194194
<div className="p-1">
195195
{grouped.size === 0 && (
196196
<p className="p-3 text-center text-xs text-muted-foreground">
@@ -256,7 +256,7 @@ export function VrlSnippetDrawer({ onInsert }: VrlSnippetDrawerProps) {
256256
</div>
257257
))}
258258
</div>
259-
</ScrollArea>
259+
</ScrollArea>}
260260
</div>
261261
);
262262
}

src/server/routers/dashboard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const dashboardRouter = router({
4242
const totalEventsIn = Number(reductionMetrics._sum.eventsIn ?? 0);
4343
const totalEventsOut = Number(reductionMetrics._sum.eventsOut ?? 0);
4444
const reductionPercent = totalEventsIn > 0
45-
? (1 - totalEventsOut / totalEventsIn) * 100
45+
? Math.max(0, (1 - totalEventsOut / totalEventsIn) * 100)
4646
: null;
4747

4848
return {

0 commit comments

Comments
 (0)