Ready for release soon.

This commit is contained in:
charlesgauthereau
2025-07-17 09:28:57 +02:00
parent 7abdcd57f9
commit 4d52419247
18 changed files with 1779 additions and 3335 deletions
-934
View File
File diff suppressed because one or more lines are too long
-1
View File
@@ -1,3 +1,2 @@
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-4.6.0.cjs
+9
View File
@@ -6,6 +6,7 @@ import * as drizzleDb from "@/db";
import {db} from "@/db";
import {EDbmsSchema} from "@/db/schema/types";
import {eq} from "drizzle-orm";
import {isUuidv4} from "@/utils/verify-uuid";
export type databaseAgent = {
name: string,
@@ -34,6 +35,14 @@ export async function POST(
const body: Body = await request.json();
const lastContact = new Date();
if (!isUuidv4(agentId)) {
return NextResponse.json(
{error: "agentId is not a valid uuid"},
{status: 500}
);
}
const agent = await db.query.agent.findFirst({
where: eq(drizzleDb.schemas.agent.id, agentId),
+1 -1
View File
@@ -31,7 +31,7 @@ export async function GET(
{status: 403}
);
}
//@ts-ignore
const expiresAt = parseInt(expires, 10);
if (Date.now() > expiresAt) {
return NextResponse.json(
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Regular → Executable
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Executable
+3
View File
File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 90 KiB

Executable
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

+15 -12
View File
@@ -1,28 +1,31 @@
import React from "react";
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import type {Metadata} from "next";
import {Inter} from "next/font/google";
import "./globals.css";
import { Providers } from "./providers";
import { cn } from "@/lib/utils";
import {Providers} from "./providers";
import {cn} from "@/lib/utils";
const inter = Inter({ subsets: ["latin"] });
const inter = Inter({subsets: ["latin"]});
export const metadata: Metadata = {
title: "Portabase",
description: "Manage all your database instances from one place !",
title: process.env.NEXT_PUBLIC_PROJECT_NAME ?? "App Title",
description: process.env.NEXT_PUBLIC_PROJECT_DESCRIPTION ?? undefined,
};
export default function RootLayout({
children,
}: Readonly<{
children,
}: Readonly<{
children: React.ReactNode;
}>) {
return (
<html lang="en" suppressHydrationWarning>
<body className={cn(inter.className, "h-full")}>
<Providers>{children}</Providers>
</body>
<head>
<meta name="apple-mobile-web-app-title" content="Portabase"/>
</head>
<body className={cn(inter.className, "h-full")}>
<Providers>{children}</Providers>
</body>
</html>
);
}
+21
View File
@@ -0,0 +1,21 @@
{
"name": "Portabase",
"short_name": "Portabase",
"icons": [
{
"src": "/web-app-manifest-192x192.png",
"sizes": "192x192",
"type": "image/png",
"purpose": "maskable"
},
{
"src": "/web-app-manifest-512x512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
+1 -1
View File
@@ -1,6 +1,6 @@
FROM node:23.5.0-alpine AS base
ENV YARN_VERSION=4.6.0
ENV YARN_VERSION=4.9.1
RUN apk add --no-cache libc6-compat
RUN apk add --no-cache openssl
+2 -2
View File
@@ -3,7 +3,7 @@
"version": "1.1.0",
"private": true,
"scripts": {
"dev": "next dev -p 80",
"dev": "next dev --turbopack -p 80",
"build": "next build",
"start": "next start",
"lint": "next lint",
@@ -110,5 +110,5 @@
"typescript": "^5.8.3",
"zenstack": "2.14.2"
},
"packageManager": "yarn@4.8.1+sha512.bc946f2a022d7a1a38adfc15b36a66a3807a67629789496c3714dd1703d2e6c6b1c69ff9ec3b43141ac7a1dd853b7685638eb0074300386a59c18df351ef8ff6"
"packageManager": "yarn@4.9.1"
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

+86 -61
View File
@@ -1,17 +1,17 @@
"use client";
import { useEffect, useState } from "react";
import {useEffect, useState} from "react";
import { Check, ChevronDown } from "lucide-react";
import {Check, ChevronDown} from "lucide-react";
import { cn } from "@/lib/utils";
import { Button } from "@/components/ui/button";
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "@/components/ui/command";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import { FormControl } from "@/components/ui/form";
import { SidebarMenuButton } from "@/components/ui/sidebar";
import { Separator } from "@/components/ui/separator";
import { CreateOrganizationModal } from "@/components/wrappers/dashboard/organization/create-organisation-modal";
import {cn} from "@/lib/utils";
import {Button} from "@/components/ui/button";
import {Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList} from "@/components/ui/command";
import {Popover, PopoverContent, PopoverTrigger} from "@/components/ui/popover";
import {FormControl} from "@/components/ui/form";
import {SidebarMenuButton} from "@/components/ui/sidebar";
import {Separator} from "@/components/ui/separator";
import {CreateOrganizationModal} from "@/components/wrappers/dashboard/organization/create-organisation-modal";
export type comboBoxProps = {
values: Array<{ value: string; label: string }>;
@@ -19,10 +19,18 @@ export type comboBoxProps = {
onValueChange?: any;
searchField?: boolean;
sideBar?: boolean;
reload?: () => void;
};
export function ComboBox(props: comboBoxProps) {
const { values: choices, defaultValue: defaultChoice = "", onValueChange, searchField = false, sideBar = false } = props;
const {
values: choices,
defaultValue: defaultChoice = "",
onValueChange,
searchField = false,
sideBar = false
} = props;
const [value, setValue] = useState<string>();
@@ -31,53 +39,68 @@ export function ComboBox(props: comboBoxProps) {
}, [defaultChoice]);
const [open, setOpen] = useState(false);
const [openModal, setOpenModal] = useState(false);
return (
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>
{sideBar ? (
<SidebarMenuButton>
{value ? choices.find((choice) => choice.value === value)?.label : "Select choice..."}
<ChevronDown className="ml-auto" />
</SidebarMenuButton>
) : (
<Button variant="outline" role="combobox" aria-expanded={open} className="w-full justify-between">
{value ? choices.find((choice) => choice.value === value)?.label : "Select choice..."}
<ChevronDown className="opacity-50" />
</Button>
)}
</PopoverTrigger>
<PopoverContent className="p-0 popover-content-width-full">
<Command>
{searchField ? <CommandInput placeholder="Search choice..." className="h-9" /> : null}
<CommandList>
<CommandEmpty>No choice found.</CommandEmpty>
<CommandGroup>
{choices.map((choice) => (
<CommandItem
key={choice.value}
value={choice.value}
onSelect={(currentValue) => {
setValue(currentValue);
onValueChange(currentValue);
setOpen(false);
}}
>
{choice.label}
<Check className={cn("ml-auto", value === choice.value ? "opacity-100" : "opacity-0")} />
</CommandItem>
))}
</CommandGroup>
</CommandList>
</Command>
<Separator />
{sideBar ? (
<CreateOrganizationModal>
<SidebarMenuButton>+ Create new organization</SidebarMenuButton>
</CreateOrganizationModal>
) : null}
</PopoverContent>
</Popover>
<div>
<CreateOrganizationModal
open={openModal}
onSuccess={() => {
props.reload?.();
}}
onOpenChange={setOpenModal}
/>
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>
{sideBar ? (
<SidebarMenuButton>
{value ? choices.find((choice) => choice.value === value)?.label : "Select choice..."}
<ChevronDown className="ml-auto"/>
</SidebarMenuButton>
) : (
<Button variant="outline" role="combobox" aria-expanded={open}
className="w-full justify-between">
{value ? choices.find((choice) => choice.value === value)?.label : "Select choice..."}
<ChevronDown className="opacity-50"/>
</Button>
)}
</PopoverTrigger>
<PopoverContent className="p-0 popover-content-width-full">
<Command>
{searchField ? <CommandInput placeholder="Search choice..." className="h-9"/> : null}
<CommandList>
<CommandEmpty>No choice found.</CommandEmpty>
<CommandGroup>
{choices.map((choice) => (
<CommandItem
key={choice.value}
value={choice.value}
onSelect={(currentValue) => {
setValue(currentValue);
onValueChange(currentValue);
setOpen(false);
}}
>
{choice.label}
<Check
className={cn("ml-auto", value === choice.value ? "opacity-100" : "opacity-0")}/>
</CommandItem>
))}
</CommandGroup>
</CommandList>
</Command>
<Separator/>
{sideBar ? (
<SidebarMenuButton onClick={() => {
setOpen(false)
setOpenModal(true)
}
}>+ Create new organization</SidebarMenuButton>
) : null}
</PopoverContent>
</Popover>
</div>
);
}
@@ -89,7 +112,7 @@ export type comboBoxFormItemProps = comboBoxProps & {
/** Combobox to use when working with zodForm. */
export function ComboBoxFormItem(props: comboBoxFormItemProps) {
const { values: choices, searchField = false, value, name, onChange } = props;
const {values: choices, searchField = false, value, name, onChange} = props;
const [open, setOpen] = useState(false);
@@ -97,15 +120,16 @@ export function ComboBoxFormItem(props: comboBoxFormItemProps) {
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>
<FormControl>
<Button variant="outline" role="combobox" aria-expanded={open} className={cn("w-full justify-between", !value && "text-muted-foreground")}>
<Button variant="outline" role="combobox" aria-expanded={open}
className={cn("w-full justify-between", !value && "text-muted-foreground")}>
{value ? choices.find((choice) => choice.value === value)?.label : `Select ${name}`}
<ChevronDown className="opacity-50" />
<ChevronDown className="opacity-50"/>
</Button>
</FormControl>
</PopoverTrigger>
<PopoverContent className="p-0 popover-content-width-full">
<Command>
{searchField ? <CommandInput placeholder="Search choice..." className="h-9" /> : null}
{searchField ? <CommandInput placeholder="Search choice..." className="h-9"/> : null}
<CommandList>
<CommandEmpty>No {name} found.</CommandEmpty>
<CommandGroup>
@@ -119,7 +143,8 @@ export function ComboBoxFormItem(props: comboBoxFormItemProps) {
}}
>
{choice.label}
<Check className={cn("ml-auto", choice.value === value ? "opacity-100" : "opacity-0")} />
<Check
className={cn("ml-auto", choice.value === value ? "opacity-100" : "opacity-0")}/>
</CommandItem>
))}
</CommandGroup>
@@ -1,25 +1,26 @@
"use client";
import { useMutation } from "@tanstack/react-query";
import {useMutation} from "@tanstack/react-query";
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle, DialogTrigger } from "@/components/ui/dialog";
import { Button } from "@/components/ui/button";
import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage, useZodForm } from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import { OrganizationSchema } from "@/components/wrappers/dashboard/organization/organization.schema";
import { createOrganizationAction } from "@/components/wrappers/dashboard/organization/organization.action";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { authClient } from "@/lib/auth/auth-client";
import {Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle} from "@/components/ui/dialog";
import {Button} from "@/components/ui/button";
import {Form, FormControl, FormField, FormItem, FormLabel, FormMessage, useZodForm} from "@/components/ui/form";
import {Input} from "@/components/ui/input";
import {OrganizationSchema} from "@/components/wrappers/dashboard/organization/organization.schema";
import {createOrganizationAction} from "@/components/wrappers/dashboard/organization/organization.action";
import {useRouter} from "next/navigation";
import {useState} from "react";
import {authClient} from "@/lib/auth/auth-client";
export type createOrganizationModalProps = {
children: any;
open: boolean;
onOpenChange: (open: boolean) => void;
onSuccess?: () => void;
};
export function CreateOrganizationModal(props: createOrganizationModalProps) {
const [open, setOpen] = useState(false);
export function CreateOrganizationModal({open, onOpenChange, onSuccess}: createOrganizationModalProps) {
const { children } = props;
const router = useRouter();
@@ -27,6 +28,7 @@ export function CreateOrganizationModal(props: createOrganizationModalProps) {
schema: OrganizationSchema,
});
const mutation = useMutation({
mutationFn: async (values: OrganizationSchema) => {
console.log(values);
@@ -35,18 +37,18 @@ export function CreateOrganizationModal(props: createOrganizationModalProps) {
if (result && result.data) {
if (result.data.success && result.data.value) {
setOpen(false);
await authClient.organization.setActive({ organizationSlug: result.data.value.slug });
router.replace(`/dashboard/${result.data.value.slug}/home`);
onOpenChange(false);
await authClient.organization.setActive({organizationSlug: result.data.value.slug});
onSuccess?.();
router.replace(`/dashboard/home`);
// router.refresh();
}
}
},
});
return (
<Dialog open={open} onOpenChange={setOpen}>
<DialogTrigger asChild>{children}</DialogTrigger>
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="sm:max-w-[425px] w-full">
<DialogHeader>
<DialogTitle>Create a new organization</DialogTitle>
@@ -65,13 +67,13 @@ export function CreateOrganizationModal(props: createOrganizationModalProps) {
control={form.control}
name="name"
defaultValue=""
render={({ field }) => (
render={({field}) => (
<FormItem>
<FormLabel>Name</FormLabel>
<FormControl>
<Input {...field} />
</FormControl>
<FormMessage />
<FormMessage/>
</FormItem>
)}
/>
@@ -79,7 +81,7 @@ export function CreateOrganizationModal(props: createOrganizationModalProps) {
control={form.control}
name="slug"
defaultValue=""
render={({ field }) => (
render={({field}) => (
<FormItem>
<FormLabel>Slug</FormLabel>
<FormControl>
@@ -91,7 +93,7 @@ export function CreateOrganizationModal(props: createOrganizationModalProps) {
}}
/>
</FormControl>
<FormMessage />
<FormMessage/>
</FormItem>
)}
/>
@@ -1,16 +1,16 @@
"use client";
import { ComboBox } from "@/components/wrappers/common/combobox";
import { useSidebar } from "@/components/ui/sidebar";
import { useRouter } from "next/navigation";
import { authClient } from "@/lib/auth/auth-client";
import {ComboBox} from "@/components/wrappers/common/combobox";
import {useSidebar} from "@/components/ui/sidebar";
import {useRouter} from "next/navigation";
import {authClient} from "@/lib/auth/auth-client";
export function OrganizationCombobox() {
const router = useRouter();
const { state } = useSidebar();
const {state} = useSidebar();
const { data: organizations } = authClient.useListOrganizations();
const { data: activeOrganization } = authClient.useActiveOrganization();
const {data: organizations, refetch} = authClient.useListOrganizations();
const {data: activeOrganization, refetch: refetchActiveOrga} = authClient.useActiveOrganization();
if (!organizations) return null;
@@ -28,9 +28,16 @@ export function OrganizationCombobox() {
await authClient.organization.setActive({
organizationSlug: slug,
});
// router.replace(`/dashboard/${slug}/home`);
router.refresh();
};
return <>{state === "expanded" && <ComboBox sideBar values={values} defaultValue={activeOrganization?.slug} onValueChange={onValueChange} />}</>;
const handleReset = () => {
refetch();
refetchActiveOrga()
router.refresh();
}
return <>{state === "expanded" &&
<ComboBox sideBar values={values} defaultValue={activeOrganization?.slug} onValueChange={onValueChange}
reload={handleReset}/>}</>;
}
+1599 -2290
View File
File diff suppressed because it is too large Load Diff