From 1d85b3df6ee234309aecbe578ed09ab1e00056f7 Mon Sep 17 00:00:00 2001 From: ankushKun Date: Thu, 22 Aug 2024 11:30:39 +0530 Subject: [PATCH] file selection --- .../drawer/components/marketplace.tsx | 2 +- .../menubar/components/publish-template.tsx | 60 ++++++++++++--- next_app/src/components/menubar/index.tsx | 20 +++-- .../views/components/marketplace.tsx | 73 +++++++++++++++---- next_app/src/hooks/useProjectManager.ts | 2 +- next_app/src/pages/renderer.tsx | 2 + 6 files changed, 125 insertions(+), 34 deletions(-) diff --git a/next_app/src/components/drawer/components/marketplace.tsx b/next_app/src/components/drawer/components/marketplace.tsx index 2833339..5d9622f 100644 --- a/next_app/src/components/drawer/components/marketplace.tsx +++ b/next_app/src/components/drawer/components/marketplace.tsx @@ -17,7 +17,7 @@ function TemplateMarketplace() {
- To publish your own template, simply use the Project Publish Template option from the menu + To publish your own template, simply use the Project Publish Template option from the menu
diff --git a/next_app/src/components/menubar/components/publish-template.tsx b/next_app/src/components/menubar/components/publish-template.tsx index 5fc920d..16c4554 100644 --- a/next_app/src/components/menubar/components/publish-template.tsx +++ b/next_app/src/components/menubar/components/publish-template.tsx @@ -19,6 +19,7 @@ import { useState } from "react"; import { extractHandlerNames } from "@/lib/utils"; import { Label } from "@/components/ui/label"; import { FileCode, LoaderIcon, SquareFunction } from "lucide-react"; +import { Checkbox } from "@/components/ui/checkbox"; export type TemplateAsset = { name: string; @@ -38,6 +39,8 @@ export default function PublishTemplateBtn() { const project = globalState.activeProject && manager.getProject(globalState.activeProject) const files = project && project.files + console.log(files) + const [selectedFiles, setSelectedFiles] = useState(Object.keys(files || {})) async function publishTemplateHandler() { if (!globalState.activeProject) return toast.error("No active project") @@ -58,12 +61,13 @@ export default function PublishTemplateBtn() { //strip process ids from project.files const templateFiles = Object.values(project.files).map((file) => { - return { - name: file.name, - content: file.content, - language: file.language, - type: file.type, - } + if (selectedFiles.includes(file.name)) + return { + name: file.name, + content: file.content, + language: file.language, + type: file.type, + } }) if (templateFiles.length === 0) return toast.error("Project must have at least one file to publish as a template") @@ -172,12 +176,48 @@ export default function PublishTemplateBtn() { This will publish your project as an atomic asset on the bazar marketplace - + setTname(e.target.value)} /> - +