comment out all old marketplace componets

This commit is contained in:
SwiftyOS 2024-12-11 15:35:55 +01:00
parent 6fcceeabdb
commit 32c15434d2
8 changed files with 711 additions and 711 deletions

View File

@ -1,149 +1,149 @@
"use client";
// "use client";
import {
Dialog,
DialogContent,
DialogClose,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";
import { Button } from "@/components/ui/button";
import {
MultiSelector,
MultiSelectorContent,
MultiSelectorInput,
MultiSelectorItem,
MultiSelectorList,
MultiSelectorTrigger,
} from "@/components/ui/multiselect";
import { Controller, useForm } from "react-hook-form";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { useState } from "react";
import { addFeaturedAgent } from "./actions";
import { Agent } from "@/lib/marketplace-api/types";
// import {
// Dialog,
// DialogContent,
// DialogClose,
// DialogFooter,
// DialogHeader,
// DialogTitle,
// DialogTrigger,
// } from "@/components/ui/dialog";
// import { Button } from "@/components/ui/button";
// import {
// MultiSelector,
// MultiSelectorContent,
// MultiSelectorInput,
// MultiSelectorItem,
// MultiSelectorList,
// MultiSelectorTrigger,
// } from "@/components/ui/multiselect";
// import { Controller, useForm } from "react-hook-form";
// import {
// Select,
// SelectContent,
// SelectItem,
// SelectTrigger,
// SelectValue,
// } from "@/components/ui/select";
// import { useState } from "react";
// import { addFeaturedAgent } from "./actions";
// import { Agent } from "@/lib/marketplace-api/types";
type FormData = {
agent: string;
categories: string[];
};
// type FormData = {
// agent: string;
// categories: string[];
// };
export const AdminAddFeaturedAgentDialog = ({
categories,
agents,
}: {
categories: string[];
agents: Agent[];
}) => {
const [selectedAgent, setSelectedAgent] = useState<string>("");
const [selectedCategories, setSelectedCategories] = useState<string[]>([]);
// export const AdminAddFeaturedAgentDialog = ({
// categories,
// agents,
// }: {
// categories: string[];
// agents: Agent[];
// }) => {
// const [selectedAgent, setSelectedAgent] = useState<string>("");
// const [selectedCategories, setSelectedCategories] = useState<string[]>([]);
const {
control,
handleSubmit,
watch,
setValue,
formState: { errors },
} = useForm<FormData>({
defaultValues: {
agent: "",
categories: [],
},
});
// const {
// control,
// handleSubmit,
// watch,
// setValue,
// formState: { errors },
// } = useForm<FormData>({
// defaultValues: {
// agent: "",
// categories: [],
// },
// });
return (
<Dialog>
<DialogTrigger asChild>
<Button variant="outline" size="sm">
Add Featured Agent
</Button>
</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Add Featured Agent</DialogTitle>
</DialogHeader>
<div className="flex flex-col gap-4">
<Controller
name="agent"
control={control}
rules={{ required: true }}
render={({ field }) => (
<div>
<label htmlFor={field.name}>Agent</label>
<Select
onValueChange={(value) => {
field.onChange(value);
setSelectedAgent(value);
}}
value={field.value || ""}
>
<SelectTrigger>
<SelectValue placeholder="Select an agent" />
</SelectTrigger>
<SelectContent>
{/* Populate with agents */}
{agents.map((agent) => (
<SelectItem key={agent.id} value={agent.id}>
{agent.name}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
)}
/>
<Controller
name="categories"
control={control}
render={({ field }) => (
<MultiSelector
values={field.value || []}
onValuesChange={(values) => {
field.onChange(values);
setSelectedCategories(values);
}}
>
<MultiSelectorTrigger>
<MultiSelectorInput placeholder="Select categories" />
</MultiSelectorTrigger>
<MultiSelectorContent>
<MultiSelectorList>
{categories.map((category) => (
<MultiSelectorItem key={category} value={category}>
{category}
</MultiSelectorItem>
))}
</MultiSelectorList>
</MultiSelectorContent>
</MultiSelector>
)}
/>
</div>
<DialogFooter>
<DialogClose asChild>
<Button variant="outline">Cancel</Button>
</DialogClose>
<DialogClose asChild>
<Button
type="submit"
onClick={async () => {
// Handle adding the featured agent
await addFeaturedAgent(selectedAgent, selectedCategories);
// close the dialog
}}
>
Add
</Button>
</DialogClose>
</DialogFooter>
</DialogContent>
</Dialog>
);
};
// return (
// <Dialog>
// <DialogTrigger asChild>
// <Button variant="outline" size="sm">
// Add Featured Agent
// </Button>
// </DialogTrigger>
// <DialogContent>
// <DialogHeader>
// <DialogTitle>Add Featured Agent</DialogTitle>
// </DialogHeader>
// <div className="flex flex-col gap-4">
// <Controller
// name="agent"
// control={control}
// rules={{ required: true }}
// render={({ field }) => (
// <div>
// <label htmlFor={field.name}>Agent</label>
// <Select
// onValueChange={(value) => {
// field.onChange(value);
// setSelectedAgent(value);
// }}
// value={field.value || ""}
// >
// <SelectTrigger>
// <SelectValue placeholder="Select an agent" />
// </SelectTrigger>
// <SelectContent>
// {/* Populate with agents */}
// {agents.map((agent) => (
// <SelectItem key={agent.id} value={agent.id}>
// {agent.name}
// </SelectItem>
// ))}
// </SelectContent>
// </Select>
// </div>
// )}
// />
// <Controller
// name="categories"
// control={control}
// render={({ field }) => (
// <MultiSelector
// values={field.value || []}
// onValuesChange={(values) => {
// field.onChange(values);
// setSelectedCategories(values);
// }}
// >
// <MultiSelectorTrigger>
// <MultiSelectorInput placeholder="Select categories" />
// </MultiSelectorTrigger>
// <MultiSelectorContent>
// <MultiSelectorList>
// {categories.map((category) => (
// <MultiSelectorItem key={category} value={category}>
// {category}
// </MultiSelectorItem>
// ))}
// </MultiSelectorList>
// </MultiSelectorContent>
// </MultiSelector>
// )}
// />
// </div>
// <DialogFooter>
// <DialogClose asChild>
// <Button variant="outline">Cancel</Button>
// </DialogClose>
// <DialogClose asChild>
// <Button
// type="submit"
// onClick={async () => {
// // Handle adding the featured agent
// await addFeaturedAgent(selectedAgent, selectedCategories);
// // close the dialog
// }}
// >
// Add
// </Button>
// </DialogClose>
// </DialogFooter>
// </DialogContent>
// </Dialog>
// );
// };

View File

@ -1,74 +1,74 @@
import { Button } from "@/components/ui/button";
import {
getFeaturedAgents,
removeFeaturedAgent,
getCategories,
getNotFeaturedAgents,
} from "./actions";
// import { Button } from "@/components/ui/button";
// import {
// getFeaturedAgents,
// removeFeaturedAgent,
// getCategories,
// getNotFeaturedAgents,
// } from "./actions";
import FeaturedAgentsTable from "./FeaturedAgentsTable";
import { AdminAddFeaturedAgentDialog } from "./AdminAddFeaturedAgentDialog";
import { revalidatePath } from "next/cache";
import * as Sentry from "@sentry/nextjs";
// import FeaturedAgentsTable from "./FeaturedAgentsTable";
// import { AdminAddFeaturedAgentDialog } from "./AdminAddFeaturedAgentDialog";
// import { revalidatePath } from "next/cache";
// import * as Sentry from "@sentry/nextjs";
export default async function AdminFeaturedAgentsControl({
className,
}: {
className?: string;
}) {
// add featured agent button
// modal to select agent?
// modal to select categories?
// table of featured agents
// in table
// remove featured agent button
// edit featured agent categories button
// table footer
// Next page button
// Previous page button
// Page number input
// Page size input
// Total pages input
// Go to page button
// export default async function AdminFeaturedAgentsControl({
// className,
// }: {
// className?: string;
// }) {
// // add featured agent button
// // modal to select agent?
// // modal to select categories?
// // table of featured agents
// // in table
// // remove featured agent button
// // edit featured agent categories button
// // table footer
// // Next page button
// // Previous page button
// // Page number input
// // Page size input
// // Total pages input
// // Go to page button
const page = 1;
const pageSize = 10;
// const page = 1;
// const pageSize = 10;
const agents = await getFeaturedAgents(page, pageSize);
// const agents = await getFeaturedAgents(page, pageSize);
const categories = await getCategories();
// const categories = await getCategories();
const notFeaturedAgents = await getNotFeaturedAgents();
// const notFeaturedAgents = await getNotFeaturedAgents();
return (
<div className={`flex flex-col gap-4 ${className}`}>
<div className="mb-4 flex justify-between">
<h3 className="text-lg font-semibold">Featured Agent Controls</h3>
<AdminAddFeaturedAgentDialog
categories={categories.unique_categories}
agents={notFeaturedAgents.items}
/>
</div>
<FeaturedAgentsTable
agents={agents.items}
globalActions={[
{
component: <Button>Remove</Button>,
action: async (rows) => {
"use server";
return await Sentry.withServerActionInstrumentation(
"removeFeaturedAgent",
{},
async () => {
const all = rows.map((row) => removeFeaturedAgent(row.id));
await Promise.all(all);
revalidatePath("/marketplace");
},
);
},
},
]}
/>
</div>
);
}
// return (
// <div className={`flex flex-col gap-4 ${className}`}>
// <div className="mb-4 flex justify-between">
// <h3 className="text-lg font-semibold">Featured Agent Controls</h3>
// <AdminAddFeaturedAgentDialog
// categories={categories.unique_categories}
// agents={notFeaturedAgents.items}
// />
// </div>
// <FeaturedAgentsTable
// agents={agents.items}
// globalActions={[
// {
// component: <Button>Remove</Button>,
// action: async (rows) => {
// "use server";
// return await Sentry.withServerActionInstrumentation(
// "removeFeaturedAgent",
// {},
// async () => {
// const all = rows.map((row) => removeFeaturedAgent(row.id));
// await Promise.all(all);
// revalidatePath("/marketplace");
// },
// );
// },
// },
// ]}
// />
// </div>
// );
// }

View File

@ -1,36 +1,36 @@
import { Agent } from "@/lib/marketplace-api";
import AdminMarketplaceCard from "./AdminMarketplaceCard";
import { ClipboardX } from "lucide-react";
// import { Agent } from "@/lib/marketplace-api";
// import AdminMarketplaceCard from "./AdminMarketplaceCard";
// import { ClipboardX } from "lucide-react";
export default function AdminMarketplaceAgentList({
agents,
className,
}: {
agents: Agent[];
className?: string;
}) {
if (agents.length === 0) {
return (
<div className={className}>
<h3 className="text-lg font-semibold">Agents to review</h3>
<div className="flex flex-col items-center justify-center py-12 text-gray-500">
<ClipboardX size={48} />
<p className="mt-4 text-lg font-semibold">No agents to review</p>
</div>
</div>
);
}
// export default function AdminMarketplaceAgentList({
// agents,
// className,
// }: {
// agents: Agent[];
// className?: string;
// }) {
// if (agents.length === 0) {
// return (
// <div className={className}>
// <h3 className="text-lg font-semibold">Agents to review</h3>
// <div className="flex flex-col items-center justify-center py-12 text-gray-500">
// <ClipboardX size={48} />
// <p className="mt-4 text-lg font-semibold">No agents to review</p>
// </div>
// </div>
// );
// }
return (
<div className={`flex flex-col gap-4 ${className}`}>
<div>
<h3 className="text-lg font-semibold">Agents to review</h3>
</div>
<div className="flex flex-col gap-4">
{agents.map((agent) => (
<AdminMarketplaceCard agent={agent} key={agent.id} />
))}
</div>
</div>
);
}
// return (
// <div className={`flex flex-col gap-4 ${className}`}>
// <div>
// <h3 className="text-lg font-semibold">Agents to review</h3>
// </div>
// <div className="flex flex-col gap-4">
// {agents.map((agent) => (
// <AdminMarketplaceCard agent={agent} key={agent.id} />
// ))}
// </div>
// </div>
// );
// }

View File

@ -1,113 +1,113 @@
"use client";
import { Card } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
import { Badge } from "@/components/ui/badge";
import { ScrollArea } from "@/components/ui/scroll-area";
import { approveAgent, rejectAgent } from "./actions";
import { Agent } from "@/lib/marketplace-api";
import Link from "next/link";
import { useState } from "react";
import { Input } from "@/components/ui/input";
// "use client";
// import { Card } from "@/components/ui/card";
// import { Button } from "@/components/ui/button";
// import { Badge } from "@/components/ui/badge";
// import { ScrollArea } from "@/components/ui/scroll-area";
// import { approveAgent, rejectAgent } from "./actions";
// import { Agent } from "@/lib/marketplace-api";
// import Link from "next/link";
// import { useState } from "react";
// import { Input } from "@/components/ui/input";
function AdminMarketplaceCard({ agent }: { agent: Agent }) {
const [isApproved, setIsApproved] = useState(false);
const [isRejected, setIsRejected] = useState(false);
const [comment, setComment] = useState("");
// function AdminMarketplaceCard({ agent }: { agent: Agent }) {
// const [isApproved, setIsApproved] = useState(false);
// const [isRejected, setIsRejected] = useState(false);
// const [comment, setComment] = useState("");
const approveAgentWithId = approveAgent.bind(
null,
agent.id,
agent.version,
comment,
);
const rejectAgentWithId = rejectAgent.bind(
null,
agent.id,
agent.version,
comment,
);
// const approveAgentWithId = approveAgent.bind(
// null,
// agent.id,
// agent.version,
// comment,
// );
// const rejectAgentWithId = rejectAgent.bind(
// null,
// agent.id,
// agent.version,
// comment,
// );
const handleApprove = async (e: React.FormEvent) => {
e.preventDefault();
await approveAgentWithId();
setIsApproved(true);
};
// const handleApprove = async (e: React.FormEvent) => {
// e.preventDefault();
// await approveAgentWithId();
// setIsApproved(true);
// };
const handleReject = async (e: React.FormEvent) => {
e.preventDefault();
await rejectAgentWithId();
setIsRejected(true);
};
// const handleReject = async (e: React.FormEvent) => {
// e.preventDefault();
// await rejectAgentWithId();
// setIsRejected(true);
// };
return (
<>
{!isApproved && !isRejected && (
<Card key={agent.id} className="m-3 flex h-[300px] flex-col p-4">
<div className="mb-2 flex items-start justify-between">
<Link
href={`/marketplace/${agent.id}`}
className="text-lg font-semibold hover:underline"
>
{agent.name}
</Link>
<Badge variant="outline">v{agent.version}</Badge>
</div>
<p className="mb-2 text-sm text-gray-500">by {agent.author}</p>
<ScrollArea className="flex-grow">
<p className="mb-2 text-sm text-gray-600">{agent.description}</p>
<div className="mb-2 flex flex-wrap gap-1">
{agent.categories.map((category) => (
<Badge key={category} variant="secondary">
{category}
</Badge>
))}
</div>
<div className="flex flex-wrap gap-1">
{agent.keywords.map((keyword) => (
<Badge key={keyword} variant="outline">
{keyword}
</Badge>
))}
</div>
</ScrollArea>
<div className="mb-2 flex justify-between text-xs text-gray-500">
<span>
Created: {new Date(agent.createdAt).toLocaleDateString()}
</span>
<span>
Updated: {new Date(agent.updatedAt).toLocaleDateString()}
</span>
</div>
<div className="mb-4 flex justify-between text-sm">
<span>👁 {agent.views}</span>
<span> {agent.downloads}</span>
</div>
<div className="mt-auto space-y-2">
<div className="flex justify-end space-x-2">
<Input
type="text"
placeholder="Add a comment (optional)"
value={comment}
onChange={(e) => setComment(e.target.value)}
/>
{!isRejected && (
<form onSubmit={handleReject}>
<Button variant="outline" type="submit">
Reject
</Button>
</form>
)}
{!isApproved && (
<form onSubmit={handleApprove}>
<Button type="submit">Approve</Button>
</form>
)}
</div>
</div>
</Card>
)}
</>
);
}
// return (
// <>
// {!isApproved && !isRejected && (
// <Card key={agent.id} className="m-3 flex h-[300px] flex-col p-4">
// <div className="mb-2 flex items-start justify-between">
// <Link
// href={`/marketplace/${agent.id}`}
// className="text-lg font-semibold hover:underline"
// >
// {agent.name}
// </Link>
// <Badge variant="outline">v{agent.version}</Badge>
// </div>
// <p className="mb-2 text-sm text-gray-500">by {agent.author}</p>
// <ScrollArea className="flex-grow">
// <p className="mb-2 text-sm text-gray-600">{agent.description}</p>
// <div className="mb-2 flex flex-wrap gap-1">
// {agent.categories.map((category) => (
// <Badge key={category} variant="secondary">
// {category}
// </Badge>
// ))}
// </div>
// <div className="flex flex-wrap gap-1">
// {agent.keywords.map((keyword) => (
// <Badge key={keyword} variant="outline">
// {keyword}
// </Badge>
// ))}
// </div>
// </ScrollArea>
// <div className="mb-2 flex justify-between text-xs text-gray-500">
// <span>
// Created: {new Date(agent.createdAt).toLocaleDateString()}
// </span>
// <span>
// Updated: {new Date(agent.updatedAt).toLocaleDateString()}
// </span>
// </div>
// <div className="mb-4 flex justify-between text-sm">
// <span>👁 {agent.views}</span>
// <span>⬇️ {agent.downloads}</span>
// </div>
// <div className="mt-auto space-y-2">
// <div className="flex justify-end space-x-2">
// <Input
// type="text"
// placeholder="Add a comment (optional)"
// value={comment}
// onChange={(e) => setComment(e.target.value)}
// />
// {!isRejected && (
// <form onSubmit={handleReject}>
// <Button variant="outline" type="submit">
// Reject
// </Button>
// </form>
// )}
// {!isApproved && (
// <form onSubmit={handleApprove}>
// <Button type="submit">Approve</Button>
// </form>
// )}
// </div>
// </div>
// </Card>
// )}
// </>
// );
// }
export default AdminMarketplaceCard;
// export default AdminMarketplaceCard;

View File

@ -1,114 +1,114 @@
"use client";
// "use client";
import { Button } from "@/components/ui/button";
import { Checkbox } from "@/components/ui/checkbox";
import { DataTable } from "@/components/ui/data-table";
import { Agent } from "@/lib/marketplace-api";
import { ColumnDef } from "@tanstack/react-table";
import { ArrowUpDown } from "lucide-react";
import { removeFeaturedAgent } from "./actions";
import { GlobalActions } from "@/components/ui/data-table";
// import { Button } from "@/components/ui/button";
// import { Checkbox } from "@/components/ui/checkbox";
// import { DataTable } from "@/components/ui/data-table";
// import { Agent } from "@/lib/marketplace-api";
// import { ColumnDef } from "@tanstack/react-table";
// import { ArrowUpDown } from "lucide-react";
// import { removeFeaturedAgent } from "./actions";
// import { GlobalActions } from "@/components/ui/data-table";
export const columns: ColumnDef<Agent>[] = [
{
id: "select",
header: ({ table }) => (
<Checkbox
checked={
table.getIsAllPageRowsSelected() ||
(table.getIsSomePageRowsSelected() && "indeterminate")
}
onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)}
aria-label="Select all"
/>
),
cell: ({ row }) => (
<Checkbox
checked={row.getIsSelected()}
onCheckedChange={(value) => row.toggleSelected(!!value)}
aria-label="Select row"
/>
),
},
{
header: ({ column }) => {
return (
<Button
variant="ghost"
onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
>
Name
<ArrowUpDown className="ml-2 h-4 w-4" />
</Button>
);
},
accessorKey: "name",
},
{
header: "Description",
accessorKey: "description",
},
{
header: "Categories",
accessorKey: "categories",
},
{
header: "Keywords",
accessorKey: "keywords",
},
{
header: "Downloads",
accessorKey: "downloads",
},
{
header: "Author",
accessorKey: "author",
},
{
header: "Version",
accessorKey: "version",
},
{
header: "actions",
cell: ({ row }) => {
const handleRemove = async () => {
await removeFeaturedAgentWithId();
};
// const handleEdit = async () => {
// console.log("edit");
// };
const removeFeaturedAgentWithId = removeFeaturedAgent.bind(
null,
row.original.id,
);
return (
<div className="flex justify-end gap-2">
<Button variant="outline" size="sm" onClick={handleRemove}>
Remove
</Button>
{/* <Button variant="outline" size="sm" onClick={handleEdit}>
Edit
</Button> */}
</div>
);
},
},
];
// export const columns: ColumnDef<Agent>[] = [
// {
// id: "select",
// header: ({ table }) => (
// <Checkbox
// checked={
// table.getIsAllPageRowsSelected() ||
// (table.getIsSomePageRowsSelected() && "indeterminate")
// }
// onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)}
// aria-label="Select all"
// />
// ),
// cell: ({ row }) => (
// <Checkbox
// checked={row.getIsSelected()}
// onCheckedChange={(value) => row.toggleSelected(!!value)}
// aria-label="Select row"
// />
// ),
// },
// {
// header: ({ column }) => {
// return (
// <Button
// variant="ghost"
// onClick={() => column.toggleSorting(column.getIsSorted() === "asc")}
// >
// Name
// <ArrowUpDown className="ml-2 h-4 w-4" />
// </Button>
// );
// },
// accessorKey: "name",
// },
// {
// header: "Description",
// accessorKey: "description",
// },
// {
// header: "Categories",
// accessorKey: "categories",
// },
// {
// header: "Keywords",
// accessorKey: "keywords",
// },
// {
// header: "Downloads",
// accessorKey: "downloads",
// },
// {
// header: "Author",
// accessorKey: "author",
// },
// {
// header: "Version",
// accessorKey: "version",
// },
// {
// header: "actions",
// cell: ({ row }) => {
// const handleRemove = async () => {
// await removeFeaturedAgentWithId();
// };
// // const handleEdit = async () => {
// // console.log("edit");
// // };
// const removeFeaturedAgentWithId = removeFeaturedAgent.bind(
// null,
// row.original.id,
// );
// return (
// <div className="flex justify-end gap-2">
// <Button variant="outline" size="sm" onClick={handleRemove}>
// Remove
// </Button>
// {/* <Button variant="outline" size="sm" onClick={handleEdit}>
// Edit
// </Button> */}
// </div>
// );
// },
// },
// ];
export default function FeaturedAgentsTable({
agents,
globalActions,
}: {
agents: Agent[];
globalActions: GlobalActions<Agent>[];
}) {
return (
<DataTable
columns={columns}
data={agents}
filterPlaceholder="Search agents..."
filterColumn="name"
globalActions={globalActions}
/>
);
}
// export default function FeaturedAgentsTable({
// agents,
// globalActions,
// }: {
// agents: Agent[];
// globalActions: GlobalActions<Agent>[];
// }) {
// return (
// <DataTable
// columns={columns}
// data={agents}
// filterPlaceholder="Search agents..."
// filterColumn="name"
// globalActions={globalActions}
// />
// );
// }

View File

@ -1,155 +1,155 @@
"use server";
import MarketplaceAPI from "@/lib/marketplace-api";
import ServerSideMarketplaceAPI from "@/lib/marketplace-api/server-client";
import { revalidatePath } from "next/cache";
import * as Sentry from "@sentry/nextjs";
import { checkAuth, createServerClient } from "@/lib/supabase/server";
import { redirect } from "next/navigation";
import { createClient } from "@/lib/supabase/client";
// "use server";
// import MarketplaceAPI from "@/lib/marketplace-api";
// import ServerSideMarketplaceAPI from "@/lib/marketplace-api/server-client";
// import { revalidatePath } from "next/cache";
// import * as Sentry from "@sentry/nextjs";
// import { checkAuth, createServerClient } from "@/lib/supabase/server";
// import { redirect } from "next/navigation";
// import { createClient } from "@/lib/supabase/client";
export async function approveAgent(
agentId: string,
version: number,
comment: string,
) {
return await Sentry.withServerActionInstrumentation(
"approveAgent",
{},
async () => {
await checkAuth();
// export async function approveAgent(
// agentId: string,
// version: number,
// comment: string,
// ) {
// return await Sentry.withServerActionInstrumentation(
// "approveAgent",
// {},
// async () => {
// await checkAuth();
const api = new ServerSideMarketplaceAPI();
await api.approveAgentSubmission(agentId, version, comment);
console.debug(`Approving agent ${agentId}`);
revalidatePath("/marketplace");
},
);
}
// const api = new ServerSideMarketplaceAPI();
// await api.approveAgentSubmission(agentId, version, comment);
// console.debug(`Approving agent ${agentId}`);
// revalidatePath("/marketplace");
// },
// );
// }
export async function rejectAgent(
agentId: string,
version: number,
comment: string,
) {
return await Sentry.withServerActionInstrumentation(
"rejectAgent",
{},
async () => {
await checkAuth();
const api = new ServerSideMarketplaceAPI();
await api.rejectAgentSubmission(agentId, version, comment);
console.debug(`Rejecting agent ${agentId}`);
revalidatePath("/marketplace");
},
);
}
// export async function rejectAgent(
// agentId: string,
// version: number,
// comment: string,
// ) {
// return await Sentry.withServerActionInstrumentation(
// "rejectAgent",
// {},
// async () => {
// await checkAuth();
// const api = new ServerSideMarketplaceAPI();
// await api.rejectAgentSubmission(agentId, version, comment);
// console.debug(`Rejecting agent ${agentId}`);
// revalidatePath("/marketplace");
// },
// );
// }
export async function getReviewableAgents() {
return await Sentry.withServerActionInstrumentation(
"getReviewableAgents",
{},
async () => {
await checkAuth();
const api = new ServerSideMarketplaceAPI();
return api.getAgentSubmissions();
},
);
}
// export async function getReviewableAgents() {
// return await Sentry.withServerActionInstrumentation(
// "getReviewableAgents",
// {},
// async () => {
// await checkAuth();
// const api = new ServerSideMarketplaceAPI();
// return api.getAgentSubmissions();
// },
// );
// }
export async function getFeaturedAgents(
page: number = 1,
pageSize: number = 10,
) {
return await Sentry.withServerActionInstrumentation(
"getFeaturedAgents",
{},
async () => {
await checkAuth();
const api = new ServerSideMarketplaceAPI();
const featured = await api.getFeaturedAgents(page, pageSize);
console.debug(`Getting featured agents ${featured.items.length}`);
return featured;
},
);
}
// export async function getFeaturedAgents(
// page: number = 1,
// pageSize: number = 10,
// ) {
// return await Sentry.withServerActionInstrumentation(
// "getFeaturedAgents",
// {},
// async () => {
// await checkAuth();
// const api = new ServerSideMarketplaceAPI();
// const featured = await api.getFeaturedAgents(page, pageSize);
// console.debug(`Getting featured agents ${featured.items.length}`);
// return featured;
// },
// );
// }
export async function getFeaturedAgent(agentId: string) {
return await Sentry.withServerActionInstrumentation(
"getFeaturedAgent",
{},
async () => {
await checkAuth();
const api = new ServerSideMarketplaceAPI();
const featured = await api.getFeaturedAgent(agentId);
console.debug(`Getting featured agent ${featured.agentId}`);
return featured;
},
);
}
// export async function getFeaturedAgent(agentId: string) {
// return await Sentry.withServerActionInstrumentation(
// "getFeaturedAgent",
// {},
// async () => {
// await checkAuth();
// const api = new ServerSideMarketplaceAPI();
// const featured = await api.getFeaturedAgent(agentId);
// console.debug(`Getting featured agent ${featured.agentId}`);
// return featured;
// },
// );
// }
export async function addFeaturedAgent(
agentId: string,
categories: string[] = ["featured"],
) {
return await Sentry.withServerActionInstrumentation(
"addFeaturedAgent",
{},
async () => {
await checkAuth();
const api = new ServerSideMarketplaceAPI();
await api.addFeaturedAgent(agentId, categories);
console.debug(`Adding featured agent ${agentId}`);
revalidatePath("/marketplace");
},
);
}
// export async function addFeaturedAgent(
// agentId: string,
// categories: string[] = ["featured"],
// ) {
// return await Sentry.withServerActionInstrumentation(
// "addFeaturedAgent",
// {},
// async () => {
// await checkAuth();
// const api = new ServerSideMarketplaceAPI();
// await api.addFeaturedAgent(agentId, categories);
// console.debug(`Adding featured agent ${agentId}`);
// revalidatePath("/marketplace");
// },
// );
// }
export async function removeFeaturedAgent(
agentId: string,
categories: string[] = ["featured"],
) {
return await Sentry.withServerActionInstrumentation(
"removeFeaturedAgent",
{},
async () => {
await checkAuth();
const api = new ServerSideMarketplaceAPI();
await api.removeFeaturedAgent(agentId, categories);
console.debug(`Removing featured agent ${agentId}`);
revalidatePath("/marketplace");
},
);
}
// export async function removeFeaturedAgent(
// agentId: string,
// categories: string[] = ["featured"],
// ) {
// return await Sentry.withServerActionInstrumentation(
// "removeFeaturedAgent",
// {},
// async () => {
// await checkAuth();
// const api = new ServerSideMarketplaceAPI();
// await api.removeFeaturedAgent(agentId, categories);
// console.debug(`Removing featured agent ${agentId}`);
// revalidatePath("/marketplace");
// },
// );
// }
export async function getCategories() {
return await Sentry.withServerActionInstrumentation(
"getCategories",
{},
async () => {
await checkAuth();
const api = new ServerSideMarketplaceAPI();
const categories = await api.getCategories();
console.debug(
`Getting categories ${categories.unique_categories.length}`,
);
return categories;
},
);
}
// export async function getCategories() {
// return await Sentry.withServerActionInstrumentation(
// "getCategories",
// {},
// async () => {
// await checkAuth();
// const api = new ServerSideMarketplaceAPI();
// const categories = await api.getCategories();
// console.debug(
// `Getting categories ${categories.unique_categories.length}`,
// );
// return categories;
// },
// );
// }
export async function getNotFeaturedAgents(
page: number = 1,
pageSize: number = 100,
) {
return await Sentry.withServerActionInstrumentation(
"getNotFeaturedAgents",
{},
async () => {
await checkAuth();
const api = new ServerSideMarketplaceAPI();
const agents = await api.getNotFeaturedAgents(page, pageSize);
console.debug(`Getting not featured agents ${agents.items.length}`);
return agents;
},
);
}
// export async function getNotFeaturedAgents(
// page: number = 1,
// pageSize: number = 100,
// ) {
// return await Sentry.withServerActionInstrumentation(
// "getNotFeaturedAgents",
// {},
// async () => {
// await checkAuth();
// const api = new ServerSideMarketplaceAPI();
// const agents = await api.getNotFeaturedAgents(page, pageSize);
// console.debug(`Getting not featured agents ${agents.items.length}`);
// return agents;
// },
// );
// }

View File

@ -1,96 +1,96 @@
"use client";
import Link from "next/link";
import { ArrowLeft, Download, Calendar, Tag } from "lucide-react";
import { Button } from "@/components/ui/button";
import AutoGPTServerAPI, { GraphCreatable } from "@/lib/autogpt-server-api";
import "@xyflow/react/dist/style.css";
import { useToast } from "../ui/use-toast";
// "use client";
// import Link from "next/link";
// import { ArrowLeft, Download, Calendar, Tag } from "lucide-react";
// import { Button } from "@/components/ui/button";
// import AutoGPTServerAPI, { GraphCreatable } from "@/lib/autogpt-server-api";
// import "@xyflow/react/dist/style.css";
// import { useToast } from "../ui/use-toast";
function AgentDetailContent({ agent }: { agent: GraphCreatable }) {
const { toast } = useToast();
// function AgentDetailContent({ agent }: { agent: GraphCreatable }) {
// const { toast } = useToast();
// const downloadAgent = async (id: string): Promise<void> => {
// const api = new MarketplaceAPI();
// try {
// const file = await api.downloadAgentFile(id);
// console.debug(`Agent file downloaded:`, file);
// // const downloadAgent = async (id: string): Promise<void> => {
// // const api = new MarketplaceAPI();
// // try {
// // const file = await api.downloadAgentFile(id);
// // console.debug(`Agent file downloaded:`, file);
// // Create a Blob from the file content
// const blob = new Blob([file], { type: "application/json" });
// // // Create a Blob from the file content
// // const blob = new Blob([file], { type: "application/json" });
// // Create a temporary URL for the Blob
// const url = window.URL.createObjectURL(blob);
// // // Create a temporary URL for the Blob
// // const url = window.URL.createObjectURL(blob);
// // Create a temporary anchor element
// const a = document.createElement("a");
// a.href = url;
// a.download = `agent_${id}.json`; // Set the filename
// // // Create a temporary anchor element
// // const a = document.createElement("a");
// // a.href = url;
// // a.download = `agent_${id}.json`; // Set the filename
// // Append the anchor to the body, click it, and remove it
// document.body.appendChild(a);
// a.click();
// document.body.removeChild(a);
// // // Append the anchor to the body, click it, and remove it
// // document.body.appendChild(a);
// // a.click();
// // document.body.removeChild(a);
// // Revoke the temporary URL
// window.URL.revokeObjectURL(url);
// } catch (error) {
// console.error(`Error downloading agent:`, error);
// throw error;
// }
// };
// // // Revoke the temporary URL
// // window.URL.revokeObjectURL(url);
// // } catch (error) {
// // console.error(`Error downloading agent:`, error);
// // throw error;
// // }
// // };
return (
<div className="mx-auto max-w-7xl px-4 py-4 sm:px-6 lg:px-8">
<div className="mb-4 flex items-center justify-between">
<Link
href="/marketplace"
className="inline-flex items-center text-indigo-600 hover:text-indigo-500"
>
<ArrowLeft className="mr-2" size={20} />
Back to Marketplace
</Link>
<div className="flex space-x-4">
<Button
onClick={() => downloadAgent(agent.id)}
className="inline-flex items-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
>
<Download className="mr-2" size={16} />
Download Agent
</Button>
</div>
</div>
<div className="overflow-hidden bg-white shadow sm:rounded-lg">
<div className="px-4 py-5 sm:px-6">
<h1 className="text-3xl font-bold text-gray-900">{agent.name}</h1>
<p className="mt-1 max-w-2xl text-sm text-gray-500">
{agent.description}
</p>
</div>
<div className="border-t border-gray-300 px-4 py-5 sm:p-0">
<dl className="sm:divide-y sm:divide-gray-200">
<div className="py-4 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:py-5">
<dt className="flex items-center text-sm font-medium text-gray-500">
<Calendar className="mr-2" size={16} />
Last Updated
</dt>
<dd className="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0">
{new Date(agent.updatedAt).toLocaleDateString()}
</dd>
</div>
<div className="py-4 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:py-5">
<dt className="flex items-center text-sm font-medium text-gray-500">
<Tag className="mr-2" size={16} />
Categories
</dt>
<dd className="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0">
{agent.categories.join(", ")}
</dd>
</div>
</dl>
</div>
</div>
</div>
);
}
// return (
// <div className="mx-auto max-w-7xl px-4 py-4 sm:px-6 lg:px-8">
// <div className="mb-4 flex items-center justify-between">
// <Link
// href="/marketplace"
// className="inline-flex items-center text-indigo-600 hover:text-indigo-500"
// >
// <ArrowLeft className="mr-2" size={20} />
// Back to Marketplace
// </Link>
// <div className="flex space-x-4">
// <Button
// onClick={() => downloadAgent(agent.id)}
// className="inline-flex items-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
// >
// <Download className="mr-2" size={16} />
// Download Agent
// </Button>
// </div>
// </div>
// <div className="overflow-hidden bg-white shadow sm:rounded-lg">
// <div className="px-4 py-5 sm:px-6">
// <h1 className="text-3xl font-bold text-gray-900">{agent.name}</h1>
// <p className="mt-1 max-w-2xl text-sm text-gray-500">
// {agent.description}
// </p>
// </div>
// <div className="border-t border-gray-300 px-4 py-5 sm:p-0">
// <dl className="sm:divide-y sm:divide-gray-200">
// <div className="py-4 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:py-5">
// <dt className="flex items-center text-sm font-medium text-gray-500">
// <Calendar className="mr-2" size={16} />
// Last Updated
// </dt>
// <dd className="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0">
// {new Date(agent.updatedAt).toLocaleDateString()}
// </dd>
// </div>
// <div className="py-4 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6 sm:py-5">
// <dt className="flex items-center text-sm font-medium text-gray-500">
// <Tag className="mr-2" size={16} />
// Categories
// </dt>
// <dd className="mt-1 text-sm text-gray-900 sm:col-span-2 sm:mt-0">
// {agent.categories.join(", ")}
// </dd>
// </div>
// </dl>
// </div>
// </div>
// </div>
// );
// }
export default AgentDetailContent;
// export default AgentDetailContent;

View File

@ -1,18 +1,18 @@
"use server";
// "use server";
import * as Sentry from "@sentry/nextjs";
import MarketplaceAPI, { AnalyticsEvent } from "@/lib/marketplace-api";
import { checkAuth } from "@/lib/supabase/server";
// import * as Sentry from "@sentry/nextjs";
// import MarketplaceAPI, { AnalyticsEvent } from "@/lib/marketplace-api";
// import { checkAuth } from "@/lib/supabase/server";
export async function makeAnalyticsEvent(event: AnalyticsEvent) {
return await Sentry.withServerActionInstrumentation(
"makeAnalyticsEvent",
{},
async () => {
await checkAuth();
const apiUrl = process.env.AGPT_SERVER_API_URL;
const api = new MarketplaceAPI();
await api.makeAnalyticsEvent(event);
},
);
}
// export async function makeAnalyticsEvent(event: AnalyticsEvent) {
// return await Sentry.withServerActionInstrumentation(
// "makeAnalyticsEvent",
// {},
// async () => {
// await checkAuth();
// const apiUrl = process.env.AGPT_SERVER_API_URL;
// const api = new MarketplaceAPI();
// await api.makeAnalyticsEvent(event);
// },
// );
// }