diff --git a/bin/core/src/helpers/mod.rs b/bin/core/src/helpers/mod.rs index 241b656a0..98a621698 100644 --- a/bin/core/src/helpers/mod.rs +++ b/bin/core/src/helpers/mod.rs @@ -13,7 +13,7 @@ use monitor_client::entities::{ }; use mungos::{ by_id::{find_one_by_id, update_one_by_id}, - mongodb::bson::{doc, oid::ObjectId, to_bson, to_document}, + mongodb::bson::{doc, oid::ObjectId, to_document}, }; use periphery_client::{api, PeripheryClient}; use rand::{thread_rng, Rng}; @@ -201,20 +201,26 @@ pub async fn remove_from_recently_viewed( resource: impl Into, ) -> anyhow::Result<()> { let resource: ResourceTarget = resource.into(); - db_client().await - .users - .update_many( - doc! {}, - doc! { - "$pull": { - "recently_viewed": - to_bson(&resource).context("failed to convert resource to bson")? - } - }, - None - ) - .await - .context("failed to remove resource from users recently viewed")?; + let (ty, id) = resource.extract_variant_id(); + db_client() + .await + .users + .update_many( + doc! {}, + doc! { + "$pull": { + "recently_viewed": { + "type": ty.to_string(), + "id": id, + } + } + }, + None, + ) + .await + .context( + "failed to remove resource from users recently viewed", + )?; Ok(()) } diff --git a/frontend/src/components/layouts.tsx b/frontend/src/components/layouts.tsx index 74ca2b084..6bc721f02 100644 --- a/frontend/src/components/layouts.tsx +++ b/frontend/src/components/layouts.tsx @@ -47,7 +47,7 @@ export const Page = ({ actions, children, }: PageProps) => ( -
+
{(title || subtitle || actions) && (
diff --git a/frontend/src/components/resources/deployment/config/index.tsx b/frontend/src/components/resources/deployment/config/index.tsx index 98b701836..0e851968b 100644 --- a/frontend/src/components/resources/deployment/config/index.tsx +++ b/frontend/src/components/resources/deployment/config/index.tsx @@ -83,8 +83,6 @@ export const DeploymentConfig = ({ id }: { id: string }) => { onChange={(process_args) => set({ process_args })} /> ), - }, - network: { network: (value, set) => ( { ), ports: (value, set) => show_ports && , - }, - volumes: { volumes: (v, set) => , - }, - extra_args: { extra_args: (value, set) => ( ), - }, - termination: { termination_signal: (value, set) => ( ), diff --git a/frontend/src/components/updates/details.tsx b/frontend/src/components/updates/details.tsx index f754df77b..346d3721e 100644 --- a/frontend/src/components/updates/details.tsx +++ b/frontend/src/components/updates/details.tsx @@ -35,7 +35,27 @@ export const UpdateDetails = ({ children: ReactNode; }) => { const [open, setOpen] = useState(false); + return ( + + ); +}; +export const UpdateDetailsInner = ({ + id, + children, + open, + setOpen, +}: { + id: string; + children?: ReactNode; + open: boolean; + setOpen: React.Dispatch>; +}) => { const update = useRead("GetUpdate", { id }).data; if (!update) return null; @@ -64,8 +84,13 @@ export const UpdateDetails = ({
- -
setOpen(false)}> + +
setOpen(false)} + >
@@ -139,4 +164,4 @@ export const UpdateDetails = ({ ); -}; +}; \ No newline at end of file diff --git a/frontend/src/components/updates/table.tsx b/frontend/src/components/updates/table.tsx index 68286c78b..02c7d0d2c 100644 --- a/frontend/src/components/updates/table.tsx +++ b/frontend/src/components/updates/table.tsx @@ -2,6 +2,8 @@ import { fmt_date_with_minutes } from "@lib/formatting"; import { Types } from "@monitor/client"; import { ColumnDef } from "@tanstack/react-table"; import { DataTable } from "@ui/data-table"; +import { useState } from "react"; +import { UpdateDetailsInner } from "./details"; export const UpdatesTable = ({ updates, @@ -42,5 +44,15 @@ export const UpdatesTable = ({ ...data, ]; } - return ; + const [id, setId] = useState(""); + return ( + <> + setId(row.id)} + /> + setId("")} /> + + ); }; diff --git a/frontend/src/lib/hooks.ts b/frontend/src/lib/hooks.ts index 476bff568..254d1a404 100644 --- a/frontend/src/lib/hooks.ts +++ b/frontend/src/lib/hooks.ts @@ -163,5 +163,5 @@ export const usePushRecentlyViewed = ({ type, id }: Types.ResourceTarget) => { !!type && !!id && push({ resource: { type, id } }); }, [type, id, push]); - return push; + return () => push({ resource: { type, id } }); }; diff --git a/frontend/src/pages/home/dashboard.tsx b/frontend/src/pages/home/dashboard.tsx index 286371686..6325357e4 100644 --- a/frontend/src/pages/home/dashboard.tsx +++ b/frontend/src/pages/home/dashboard.tsx @@ -1,17 +1,25 @@ import { Page, Section } from "@components/layouts"; -import { Box, FolderTree } from "lucide-react"; -import { Link } from "react-router-dom"; -import { Card, CardDescription, CardHeader, CardTitle } from "@ui/card"; +import { Box, FolderTree, History } from "lucide-react"; +import { Link, useNavigate } from "react-router-dom"; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from "@ui/card"; import { TagsSummary } from "@components/dashboard/tags"; import { ApiKeysSummary } from "@components/dashboard/api-keys"; import { ResourceComponents } from "@components/resources"; import { OpenAlerts } from "@components/alert"; +import { useUser } from "@lib/hooks"; +import { ResourceLink } from "@components/util"; export const Dashboard = () => { return ( - {/* */} + ); @@ -64,21 +72,31 @@ const Resources = () => ( ); -// const RecentlyViewed = () => ( -//
} -// actions="" -// > -//
-// {useRead("GetUser", {}) -// .data?.recently_viewed?.slice(0, 6) -// .map( -// (target) => -// target.type !== "System" && ( -// -// ) -// )} -//
-//
-// ); +const RecentlyViewed = () => { + const nav = useNavigate(); + const recently_viewed = useUser().data?.recently_viewed; + return ( +
} + actions="" + > +
+ {recently_viewed?.slice(0, 6).map( + ({ type, id }) => + type !== "System" && ( + nav(`/${type.toLowerCase()}s/${id}`)} + className="px-3 py-2 h-full hover:bg-accent/50 group-focus:bg-accent/50 transition-colors cursor-pointer" + > + + + {type} + + + ) + )} +
+
+ ); +};