Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Disable deploy button when deploying; Enable code highlight in logs

Tomas Valenta5d6c7824cedd
diff --git a/components/Editor/RightSidebar/DeployButton.tsx b/components/Editor/RightSidebar/DeployButton.tsx
index 22917a081..ae361a25c 100644
--- a/components/Editor/RightSidebar/DeployButton.tsx
+++ b/components/Editor/RightSidebar/DeployButton.tsx
@@ -8,6 +8,7 @@ export interface Props {
deploy: () => void
deployStatus?: deployment_state | null
isInitializingDeploy?: boolean
+ isDeployRequestRunning?: boolean
}
interface DeploymentRepresentation {
@@ -47,12 +48,14 @@ function getDeploymentRepresentation(deployStatus: deployment_state | null | und
function DeployButton({
deploy,
deployStatus,
+ isDeployRequestRunning,
isInitializingDeploy,
}: Props) {
const representation = getDeploymentRepresentation(deployStatus, isInitializingDeploy)
return (
<Button
+ isDisabled={isDeployRequestRunning}
text={representation.text}
onClick={deploy}
variant={Button.variant.Full}
diff --git a/components/Editor/RightSidebar/Logs/LogEntry.tsx b/components/Editor/RightSidebar/Logs/LogEntry.tsx
index e98018109..dc817e63e 100644
--- a/components/Editor/RightSidebar/Logs/LogEntry.tsx
+++ b/components/Editor/RightSidebar/Logs/LogEntry.tsx
@@ -1,5 +1,3 @@
-
-
import {
Code2,
Package,
@@ -7,7 +5,9 @@ import {
Wrench,
Loader,
} from 'lucide-react'
-import { ReactMarkdown } from 'react-markdown/lib/react-markdown'
+import ReactMarkdown from 'react-markdown'
+import hljs from 'highlight.js'
+import { useEffect } from 'react'
import { Log } from 'db/types'
@@ -30,11 +30,11 @@ export interface Props {
}
function LogEntry({ log }: Props) {
- // useEffect(function highlightCode() {
- // if (log.type === 'tool' && log.name === 'RunJavaScriptCode') {
- // hljs.highlightAll()
- // }
- // }, [log])
+ useEffect(function highlightCode() {
+ if (log.type === 'tool' && log.name === 'RunJavaScriptCode') {
+ hljs.highlightAll()
+ }
+ }, [log])
return (
<div className="
rounded-lg
@@ -74,16 +74,19 @@ function LogEntry({ log }: Props) {
</div>
{log.input.trim() &&
<div className="
- border-t
- mt-2
pt-2
"
>
- <pre>
+ {log.name === 'RunJavaScriptCode' &&
+ <ReactMarkdown>
+ {'```\n' + log.input.trim() + '\n```'}
+ </ReactMarkdown>
+ }
+ {log.name !== 'RunJavaScriptCode' &&
<ReactMarkdown>
{log.input}
</ReactMarkdown>
- </pre>
+ }
</div>
}
{log.output?.trim() &&
diff --git a/components/Editor/RightSidebar/index.tsx b/components/Editor/RightSidebar/index.tsx
index 3198ba5f9..3db9407cf 100644
--- a/components/Editor/RightSidebar/index.tsx
+++ b/components/Editor/RightSidebar/index.tsx
@@ -20,11 +20,13 @@ export interface Props {
deployedURL?: string | null
deployStatus?: deployment_state | null
isInitializingDeploy?: boolean
+ isDeployRequestRunning?: boolean
}
function RightSidebar({
logs,
logsRaw,
+ isDeployRequestRunning,
deploy,
deployedURL,
deployStatus,
@@ -92,6 +94,7 @@ function RightSidebar({
/>
<DeployButton
deploy={deploy}
+ isDeployRequestRunning={isDeployRequestRunning}
isInitializingDeploy={isInitializingDeploy}
deployStatus={deployStatus}
/>
diff --git a/components/Editor/index.tsx b/components/Editor/index.tsx
index c87d7a6df..5fe995541 100644
--- a/components/Editor/index.tsx
+++ b/components/Editor/index.tsx
@@ -90,7 +90,11 @@ function Editor({ project }: Props) {
}, [deployment])
const [focusedBlock, setFocusedBlock] = useState({ index: 0 })
- const { trigger: generate } = useSWRMutation(`${apiHost}/generate`, handlePostGenerate)
+ const {
+ trigger: generate,
+ isMutating: isDeployRequestRunning,
+ error,
+ } = useSWRMutation(`${apiHost}/generate`, handlePostGenerate)
async function deploy() {
if (!selectedRoute) return
@@ -225,6 +229,7 @@ function Editor({ project }: Props) {
deployStatus={deployment?.state}
isInitializingDeploy={isInitializingDeploy}
logs={logs}
+ isDeployRequestRunning={isDeployRequestRunning}
logsRaw={logsRaw}
deploy={deploy}
deployedURL={deployment?.url}