From cb2ffdaab36576724fa8c4510ab6ca903b428c94 Mon Sep 17 00:00:00 2001 From: "yongen.loong" Date: Thu, 29 Aug 2024 14:17:48 +0800 Subject: [PATCH] feat: icons for buttons --- components/build-deploy-panel.tsx | 128 +++++++++++++++++------------- 1 file changed, 75 insertions(+), 53 deletions(-) diff --git a/components/build-deploy-panel.tsx b/components/build-deploy-panel.tsx index 065a98e..9841ea2 100644 --- a/components/build-deploy-panel.tsx +++ b/components/build-deploy-panel.tsx @@ -6,6 +6,7 @@ import { useCliCommands } from "./workspace/use-cli-commands"; import useSWR, { mutate } from "swr"; import { db } from "@/data/db"; import { useWorkspaceId } from "./workspace/use-workspace-id"; +import { Download, Rocket, ShieldCheck, Wrench } from "lucide-react"; export function BuildDeployPanel() { const commands = useCliCommands(); @@ -22,61 +23,82 @@ export function BuildDeployPanel() { } ); + const buttons: Array<{ + disabled: boolean; + title: string; + onClick: () => void; + icon: React.FunctionComponent<{ className?: string }>; + }> = [ + { + disabled: isAuditing, + title: "AI Audit", + onClick: async () => { + setIsAuditing(true); + try { + await commands.audit(); + } catch (err) { + console.log(err); + } finally { + setIsAuditing(false); + } + }, + icon: ShieldCheck, + }, + { + disabled: isBuilding, + title: "Build", + onClick: async () => { + try { + setIsBuilding(true); + await commands.build(); + mutate(`deployable-${id}`); + } catch (err) { + } finally { + setIsBuilding(false); + } + }, + icon: Wrench, + }, + { + disabled: isBuilding || !isDeployable || isDeploying, + title: "Deploy", + onClick: async () => { + try { + setIsDeploying(true); + await commands.deploy(); + } catch (err) { + } finally { + setIsDeploying(false); + } + }, + icon: Rocket, + }, + { + disabled: false, + title: "Export", + onClick: async () => { + try { + await commands.export(); + } catch (err) {} + }, + icon: Download, + }, + ]; + return (
- - - - + {buttons.map((button) => ( + + ))}
); }