|
@@ -1,5 +1,5 @@
|
|
|
import { VSCodeButton } from "@vscode/webview-ui-toolkit/react"
|
|
import { VSCodeButton } from "@vscode/webview-ui-toolkit/react"
|
|
|
-import { useEffect, useState } from "react"
|
|
|
|
|
|
|
+import { useState } from "react"
|
|
|
import { useExtensionState } from "../../context/ExtensionStateContext"
|
|
import { useExtensionState } from "../../context/ExtensionStateContext"
|
|
|
import { validateApiConfiguration } from "../../utils/validate"
|
|
import { validateApiConfiguration } from "../../utils/validate"
|
|
|
import { vscode } from "../../utils/vscode"
|
|
import { vscode } from "../../utils/vscode"
|
|
@@ -8,18 +8,18 @@ import ApiOptions from "../settings/ApiOptions"
|
|
|
const WelcomeView = () => {
|
|
const WelcomeView = () => {
|
|
|
const { apiConfiguration } = useExtensionState()
|
|
const { apiConfiguration } = useExtensionState()
|
|
|
|
|
|
|
|
- const [apiErrorMessage, setApiErrorMessage] = useState<string | undefined>(undefined)
|
|
|
|
|
-
|
|
|
|
|
- const disableLetsGoButton = apiErrorMessage !== null && apiErrorMessage !== undefined
|
|
|
|
|
|
|
+ const [errorMessage, setErrorMessage] = useState<string | undefined>(undefined)
|
|
|
|
|
|
|
|
const handleSubmit = () => {
|
|
const handleSubmit = () => {
|
|
|
|
|
+ const error = validateApiConfiguration(apiConfiguration)
|
|
|
|
|
+ if (error) {
|
|
|
|
|
+ setErrorMessage(error)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ setErrorMessage(undefined)
|
|
|
vscode.postMessage({ type: "apiConfiguration", apiConfiguration })
|
|
vscode.postMessage({ type: "apiConfiguration", apiConfiguration })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- useEffect(() => {
|
|
|
|
|
- setApiErrorMessage(validateApiConfiguration(apiConfiguration))
|
|
|
|
|
- }, [apiConfiguration])
|
|
|
|
|
-
|
|
|
|
|
return (
|
|
return (
|
|
|
<div style={{ position: "fixed", top: 0, left: 0, right: 0, bottom: 0, padding: "0 20px" }}>
|
|
<div style={{ position: "fixed", top: 0, left: 0, right: 0, bottom: 0, padding: "0 20px" }}>
|
|
|
<h2>Hi, I'm Roo!</h2>
|
|
<h2>Hi, I'm Roo!</h2>
|
|
@@ -33,10 +33,13 @@ const WelcomeView = () => {
|
|
|
<b>To get started, this extension needs an API provider.</b>
|
|
<b>To get started, this extension needs an API provider.</b>
|
|
|
|
|
|
|
|
<div style={{ marginTop: "10px" }}>
|
|
<div style={{ marginTop: "10px" }}>
|
|
|
- <ApiOptions />
|
|
|
|
|
- <VSCodeButton onClick={handleSubmit} disabled={disableLetsGoButton} style={{ marginTop: "3px" }}>
|
|
|
|
|
- Let's go!
|
|
|
|
|
- </VSCodeButton>
|
|
|
|
|
|
|
+ <ApiOptions fromWelcomeView />
|
|
|
|
|
+ <div style={{ display: "flex", flexDirection: "column", gap: "5px" }}>
|
|
|
|
|
+ <VSCodeButton onClick={handleSubmit} style={{ marginTop: "3px" }}>
|
|
|
|
|
+ Let's go!
|
|
|
|
|
+ </VSCodeButton>
|
|
|
|
|
+ {errorMessage && <span className="text-destructive">{errorMessage}</span>}
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
)
|
|
)
|