-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6c96eed
commit c6ed64d
Showing
6 changed files
with
260 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
"use client"; | ||
|
||
import { useState } from "react"; | ||
import { Button } from "./ui/button"; | ||
import { useCliCommands } from "./workspace/use-cli-commands"; | ||
import useSWR from "swr"; | ||
import { useParams } from "next/navigation"; | ||
import { db } from "@/data/db"; | ||
|
||
export function BuildDeployPanel() { | ||
const commands = useCliCommands(); | ||
const [isBuilding, setIsBuilding] = useState(false); | ||
const [isDeploying, setIsDeploying] = useState(false); | ||
|
||
const { id } = useParams<{ id: string }>(); | ||
const { data: isDeployable } = useSWR( | ||
id ? `deployable-${id}` : undefined, | ||
async () => { | ||
const ws = await db.workspaces.get(id); | ||
return typeof ws?.dll === "string"; | ||
} | ||
); | ||
|
||
return ( | ||
<div className="p-4 border-b-2 flex gap-2"> | ||
<Button | ||
disabled={isBuilding} | ||
onClick={async () => { | ||
try { | ||
setIsDeploying(false); | ||
setIsBuilding(true); | ||
await commands.build(); | ||
} catch (err) { | ||
} finally { | ||
setIsBuilding(false); | ||
} | ||
}} | ||
> | ||
Build | ||
</Button> | ||
<Button | ||
disabled={isBuilding || !isDeployable || isDeploying} | ||
onClick={async () => { | ||
try { | ||
setIsDeploying(true); | ||
await commands.deploy(); | ||
} catch (err) { | ||
} finally { | ||
setIsDeploying(false); | ||
} | ||
}} | ||
> | ||
Deploy | ||
</Button> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.