Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ jobs:
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
echo "value=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
else
echo "value=dev" >> "$GITHUB_OUTPUT"
echo "value=dev-${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
fi

- uses: docker/setup-buildx-action@v3
Expand Down
2 changes: 1 addition & 1 deletion src/app/(dashboard)/pipelines/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function getReductionPercent(totals: { eventsIn: bigint; eventsOut: bigint }): n
const evIn = Number(totals.eventsIn);
const evOut = Number(totals.eventsOut);
if (evIn === 0) return null;
return (1 - evOut / evIn) * 100;
return Math.max(0, (1 - evOut / evIn) * 100);
}

function reductionColor(pct: number): string {
Expand Down
17 changes: 15 additions & 2 deletions src/components/environment-selector.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"use client";

import { useEffect, useMemo } from "react";
import { useEffect, useMemo, useCallback } from "react";
import Link from "next/link";
import { usePathname, useRouter } from "next/navigation";
import { useQuery } from "@tanstack/react-query";
import { useTRPC } from "@/trpc/client";
import { useEnvironmentStore } from "@/stores/environment-store";
Expand All @@ -23,6 +24,18 @@ export function EnvironmentSelector() {
const { selectedEnvironmentId, setSelectedEnvironmentId, setIsSystemEnvironment } =
useEnvironmentStore();
const selectedTeamId = useTeamStore((s) => s.selectedTeamId);
const pathname = usePathname();
const router = useRouter();

// Navigate back to list pages when switching environments from a detail page
const handleEnvironmentChange = useCallback((id: string) => {
setSelectedEnvironmentId(id);
const detailRoutes = ["/pipelines/", "/fleet/"];
if (detailRoutes.some((route) => pathname.startsWith(route) && pathname !== route)) {
const parentRoute = detailRoutes.find((route) => pathname.startsWith(route));
if (parentRoute) router.push(parentRoute.replace(/\/$/, ""));
}
}, [setSelectedEnvironmentId, pathname, router]);

const envsQuery = useQuery(
trpc.environment.list.queryOptions(
Expand Down Expand Up @@ -79,7 +92,7 @@ export function EnvironmentSelector() {
return (
<Select
value={selectedEnvironmentId ?? ""}
onValueChange={setSelectedEnvironmentId}
onValueChange={handleEnvironmentChange}
>
<SelectTrigger className="h-8 w-[180px] text-xs">
<Layers className="mr-1.5 h-3.5 w-3.5 text-muted-foreground" />
Expand Down
6 changes: 3 additions & 3 deletions src/components/flow/vrl-snippet-drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export function VrlSnippetDrawer({ onInsert }: VrlSnippetDrawerProps) {
};

return (
<div className="flex max-h-64 w-full flex-col overflow-hidden rounded border bg-muted/20">
<div className={`flex w-full flex-col rounded border bg-muted/20 ${showForm ? "" : "max-h-64 overflow-hidden"}`}>
<div className="border-b p-2 flex items-center gap-2">
<div className="relative flex-1">
<Search className="absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" />
Expand Down Expand Up @@ -190,7 +190,7 @@ export function VrlSnippetDrawer({ onInsert }: VrlSnippetDrawerProps) {
</div>
</div>
)}
<ScrollArea className="flex-1 min-h-0">
{!showForm && <ScrollArea className="flex-1 min-h-0">
<div className="p-1">
{grouped.size === 0 && (
<p className="p-3 text-center text-xs text-muted-foreground">
Expand Down Expand Up @@ -256,7 +256,7 @@ export function VrlSnippetDrawer({ onInsert }: VrlSnippetDrawerProps) {
</div>
))}
</div>
</ScrollArea>
</ScrollArea>}
</div>
);
}
2 changes: 1 addition & 1 deletion src/server/routers/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const dashboardRouter = router({
const totalEventsIn = Number(reductionMetrics._sum.eventsIn ?? 0);
const totalEventsOut = Number(reductionMetrics._sum.eventsOut ?? 0);
const reductionPercent = totalEventsIn > 0
? (1 - totalEventsOut / totalEventsIn) * 100
? Math.max(0, (1 - totalEventsOut / totalEventsIn) * 100)
: null;

return {
Expand Down
Loading