refactor/update project breadcrumb links and restructure project page components

This commit is contained in:
biersoeckli
2025-01-08 16:23:47 +00:00
parent 09f20739c3
commit 96e5a93de6
13 changed files with 50 additions and 12 deletions

View File

@@ -9,15 +9,16 @@ import PageTitle from "@/components/custom/page-title";
import ProjectBreadcrumbs from "./project-breadcrumbs";
import CreateProjectActions from "./create-project-actions";
export default async function AppsPage({
searchParams,
params
}: {
searchParams?: { [key: string]: string | undefined };
params: { projectId: string }
}) {
await getAuthUserSession();
const projectId = searchParams?.projectId;
const projectId = params?.projectId;
if (!projectId) {
return <p>Could not find project with id {projectId}</p>
}

View File

@@ -10,7 +10,7 @@ export default function AppBreadcrumbs({ app }: { app: AppExtendedModel }) {
const { setBreadcrumbs } = useBreadcrumbs();
useEffect(() => setBreadcrumbs([
{ name: "Projects", url: "/" },
{ name: app.project.name, url: "/project?projectId=" + app.projectId },
{ name: app.project.name, url: "/project/" + app.projectId },
{ name: app.name },
]), []);
return <></>;

View File

@@ -39,7 +39,7 @@ export default function ProjectsTable({ data }: { data: Project[] }) {
["updatedAt", "Updated At", false, (item) => formatDateTime(item.updatedAt)],
]}
data={data}
onItemClickLink={(item) => `/project?projectId=${item.id}`}
onItemClickLink={(item) => `/project/${item.id}`}
actionCol={(item) =>
<>
<div className="flex">
@@ -53,7 +53,7 @@ export default function ProjectsTable({ data }: { data: Project[] }) {
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuLabel>Actions</DropdownMenuLabel>
<Link href={`/project?projectId=${item.id}`}>
<Link href={`/project/${item.id}`}>
<DropdownMenuItem>
<Eye /> <span>Show Apps of Project</span>
</DropdownMenuItem>

View File

@@ -42,7 +42,7 @@ export default function S3TargetsTable({ targets }: {
["updatedAt", "Updated At", false, (item) => formatDateTime(item.updatedAt)],
]}
data={targets}
onItemClickLink={(item) => `/project?projectId=${item.id}`}
onItemClickLink={(item) => `/project/${item.id}`}
actionCol={(item) =>
<>
<div className="flex">

View File

@@ -27,6 +27,9 @@ import {
} from "@/components/ui/avatar"
import { App, Project } from "@prisma/client"
import { UserSession } from "@/shared/model/sim-session.model"
import { usePathname } from "next/navigation"
import { useRouter } from "next/router"
import { useEffect, useState } from "react"
const settingsMenu = [
@@ -60,6 +63,30 @@ export function SidebarCient({
session: UserSession;
}) {
const path = usePathname();
const [currentlySelectedProjectId, setCurrentlySelectedProjectId] = useState<string | null>(null);
const [currentlySelectedAppId, setCurrentlySelectedAppId] = useState<string | null>(null);
useEffect(() => {
if (path.startsWith('/project/app/')) {
const appId = path.split('/')[3];
const project = projects.find(p => p.apps.some(a => a.id === appId));
setCurrentlySelectedProjectId(project?.id || null);
setCurrentlySelectedAppId(appId);
} else if (path.startsWith("/project")) {
const projectId = path.split('/')[2];
setCurrentlySelectedProjectId(projectId);
setCurrentlySelectedAppId(null);
} else {
setCurrentlySelectedProjectId(null);
setCurrentlySelectedAppId(null);
}
}, [path]);
const {
state,
open,
@@ -117,7 +144,8 @@ export function SidebarCient({
<SidebarMenuButton asChild tooltip={{
children: 'All Projects',
hidden: open,
}}>
}}
isActive={path === '/'}>
<Link href="/">
<FolderClosed />
<span>Projects</span>
@@ -135,8 +163,10 @@ export function SidebarCient({
<SidebarMenuButton asChild tooltip={{
children: `Project: ${item.name}`,
hidden: open,
}}>
<Link href={`/project?projectId=${item.id}`}>
}}
isActive={currentlySelectedProjectId === item.id}
>
<Link href={`/project/${item.id}`}>
<Dot /> <span>{item.name}</span>
</Link>
</SidebarMenuButton>
@@ -154,7 +184,8 @@ export function SidebarCient({
className="min-w-56 rounded-lg"
>
{item.apps.map((app) => (
<DropdownMenuItem asChild key={app.name}>
<DropdownMenuItem asChild key={app.name}
className={currentlySelectedAppId === app.id ? 'bg-sidebar-accent text-sidebar-accent-foreground' : ''}>
<a href={`/project/app/${app.id}`}>{app.name}</a>
</DropdownMenuItem>
))}
@@ -176,7 +207,8 @@ export function SidebarCient({
<SidebarMenuButton asChild tooltip={{
children: 'Monitoring',
hidden: open,
}}>
}}
isActive={path.startsWith('/monitoring')}>
<Link href="/monitoring">
<ChartNoAxesCombined />
<span>Monitoring</span>

View File

@@ -7,7 +7,7 @@ import deploymentService from "./deployment.service";
import k3s from "../adapter/kubernetes-api.adapter";
import ingressService from "./ingress.service";
import svcService from "./svc.service";
import { randomBytes, randomUUID } from "crypto";
import { randomBytes } from "crypto";
import podService from "./pod.service";
import bcrypt from "bcrypt";
@@ -177,6 +177,11 @@ class FileBrowserService {
name: kubeAppName,
image: 'filebrowser/filebrowser:v2.31.2',
imagePullPolicy: 'Always',
/*args: [
// ...existing code...
"--commands",
"cp,apk,rm,ls,mv"
],*/
volumeMounts: [
{
name: 'fb-data',