diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4455da0..b208893 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/src/app/(dashboard)/pipelines/page.tsx b/src/app/(dashboard)/pipelines/page.tsx index d67e18c..8de1170 100644 --- a/src/app/(dashboard)/pipelines/page.tsx +++ b/src/app/(dashboard)/pipelines/page.tsx @@ -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 { diff --git a/src/components/environment-selector.tsx b/src/components/environment-selector.tsx index e6bc904..4ec0b2c 100644 --- a/src/components/environment-selector.tsx +++ b/src/components/environment-selector.tsx @@ -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"; @@ -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( @@ -79,7 +92,7 @@ export function EnvironmentSelector() { return (