@@ -2,16 +2,17 @@ import Button from "@mui/material/Button";
2
2
import FormControlLabel from "@mui/material/FormControlLabel" ;
3
3
import Radio from "@mui/material/Radio" ;
4
4
import RadioGroup from "@mui/material/RadioGroup" ;
5
- import TextField from "@mui/material/TextField" ;
6
5
import { API } from "api/api" ;
7
6
import type { Template , TemplateVersionParameter } from "api/typesGenerated" ;
8
7
import { FormSection , VerticalForm } from "components/Form/Form" ;
8
+ import { Input } from "components/Input/Input" ;
9
+ import { Label } from "components/Label/Label" ;
9
10
import { Loader } from "components/Loader/Loader" ;
10
11
import { RichParameterInput } from "components/RichParameterInput/RichParameterInput" ;
11
12
import { useClipboard } from "hooks/useClipboard" ;
12
13
import { CheckIcon , CopyIcon } from "lucide-react" ;
13
14
import { useTemplateLayoutContext } from "pages/TemplatePage/TemplateLayout" ;
14
- import { type FC , useEffect , useState } from "react" ;
15
+ import { type FC , useEffect , useId , useState } from "react" ;
15
16
import { Helmet } from "react-helmet-async" ;
16
17
import { useQuery } from "react-query" ;
17
18
import { nameValidator } from "utils/formUtils" ;
@@ -58,6 +59,9 @@ function getClipboardCopyContent(
58
59
const deploymentUrl = `${ window . location . protocol } //${ window . location . host } ` ;
59
60
const createWorkspaceUrl = `${ deploymentUrl } /templates/${ organization } /${ templateName } /workspace` ;
60
61
const createWorkspaceParams = new URLSearchParams ( buttonValues ) ;
62
+ if ( createWorkspaceParams . get ( "name" ) === "" ) {
63
+ createWorkspaceParams . delete ( "name" ) ; // skip default workspace name if undefined
64
+ }
61
65
const buttonUrl = `${ createWorkspaceUrl } ?${ createWorkspaceParams . toString ( ) } ` ;
62
66
63
67
return `[](${ buttonUrl } )` ;
@@ -84,6 +88,7 @@ export const TemplateEmbedPageView: FC<TemplateEmbedPageViewProps> = ({
84
88
if ( templateParameters && ! buttonValues ) {
85
89
const buttonValues : ButtonValues = {
86
90
mode : "manual" ,
91
+ name : "" ,
87
92
} ;
88
93
for ( const parameter of getInitialRichParameterValues (
89
94
templateParameters ,
@@ -108,6 +113,9 @@ export const TemplateEmbedPageView: FC<TemplateEmbedPageViewProps> = ({
108
113
}
109
114
} ;
110
115
116
+ const hookId = useId ( ) ;
117
+ const defaultWorkspaceNameID = `${ hookId } -default-ws` ;
118
+
111
119
return (
112
120
< >
113
121
< Helmet >
@@ -145,25 +153,39 @@ export const TemplateEmbedPageView: FC<TemplateEmbedPageViewProps> = ({
145
153
</ RadioGroup >
146
154
</ FormSection >
147
155
148
- < FormSection
149
- title = "Workspace name"
150
- description = "Default name for the new workspace"
151
- >
152
- < TextField
153
- data-testid = "default-workspace-name"
154
- defaultValue = { buttonValues . name }
155
- fullWidth
156
+ < div className = "flex flex-col gap-1" >
157
+ < Label className = "text-md" htmlFor = { defaultWorkspaceNameID } >
158
+ Workspace name
159
+ </ Label >
160
+ < div
161
+ className = { "text-sm mb-3" }
162
+ css = { ( theme ) => ( {
163
+ color : theme . palette . text . secondary ,
164
+ } ) }
165
+ >
166
+ Default name for the new workspace
167
+ </ div >
168
+ < Input
169
+ id = { defaultWorkspaceNameID }
170
+ value = { buttonValues . name }
156
171
onChange = { ( event ) => {
157
172
validateWorkspaceName ( event . target . value ) ;
158
173
setButtonValues ( ( buttonValues ) => ( {
159
174
...buttonValues ,
160
175
name : event . target . value ,
161
176
} ) ) ;
162
177
} }
163
- error = { workspaceNameError !== "" }
164
- helperText = { workspaceNameError }
165
178
/>
166
- </ FormSection >
179
+ < div
180
+ className = "text-sm mt-1"
181
+ role = "alert"
182
+ css = { ( theme ) => ( {
183
+ color : theme . palette . error . main ,
184
+ } ) }
185
+ >
186
+ { workspaceNameError || "\u00A0" }
187
+ </ div >
188
+ </ div >
167
189
168
190
{ templateParameters . length > 0 && (
169
191
< div
0 commit comments