From 997366655c38d145c2e99c30f39534d2462511bd Mon Sep 17 00:00:00 2001 From: karamvir Date: Wed, 2 Aug 2023 21:05:47 -0700 Subject: [PATCH] add recently viewed --- frontend/src/hooks.ts | 7 ++++--- frontend/src/resources/build/index.tsx | 14 +++++++------- frontend/src/resources/deployment/index.tsx | 5 ++++- frontend/src/resources/server/index.tsx | 4 ++++ 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/frontend/src/hooks.ts b/frontend/src/hooks.ts index 6ec30a6f7..818c12ac7 100644 --- a/frontend/src/hooks.ts +++ b/frontend/src/hooks.ts @@ -89,9 +89,10 @@ export const useLogin = () => { }); }; -const recently_viewed = atomWithStorage< - { type: "Deployment" | "Build" | "Server"; id: string }[] ->("recently-viewed", []); +const recently_viewed = atomWithStorage( + "recently-viewed", + [] +); export const useGetRecentlyViewed = () => useAtomValue(recently_viewed); diff --git a/frontend/src/resources/build/index.tsx b/frontend/src/resources/build/index.tsx index c937c7fa7..68f44a4d0 100644 --- a/frontend/src/resources/build/index.tsx +++ b/frontend/src/resources/build/index.tsx @@ -8,24 +8,24 @@ import { Settings } from "lucide-react"; import { BuildConfig } from "./config"; export const BuildPage = () => { - const { buildId } = useParams(); + const id = useParams().buildId; const push = useSetRecentlyViewed(); - if (!buildId) return null; - push("Build", buildId); + if (!id) return null; + push("Build", id); return ( } + title={} info={
- +
} actions={
- - + + diff --git a/frontend/src/resources/deployment/index.tsx b/frontend/src/resources/deployment/index.tsx index aa75cd301..93d78e172 100644 --- a/frontend/src/resources/deployment/index.tsx +++ b/frontend/src/resources/deployment/index.tsx @@ -1,5 +1,5 @@ import { ResourceUpdates } from "@components/updates/resource"; -import { useRead } from "@hooks"; +import { useRead, useSetRecentlyViewed } from "@hooks"; import { ResourceCard } from "@layouts/card"; import { Resource } from "@layouts/resource"; import { @@ -21,7 +21,10 @@ import { Link, useParams } from "react-router-dom"; export const DeploymentPage = () => { const id = useParams().deploymentId; + const push = useSetRecentlyViewed(); + if (!id) return null; + push("Deployment", id); return ( { const id = useParams().serverId; + const push = useSetRecentlyViewed(); + if (!id) return null; + push("Server", id); return (