mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
feat(site): added URL param name to allow setting workspace name (#7528)
* feat: added URL param name to allow setting workspace name * fix: format --------- Co-authored-by: SaschaPfau <Sascha.Pfau@ilabnordlb.onmicrosoft.com>
This commit is contained in:
@ -44,6 +44,7 @@ const CreateWorkspacePage: FC = () => {
|
||||
} = createWorkspaceState.context
|
||||
const [searchParams] = useSearchParams()
|
||||
const defaultParameterValues = getDefaultParameterValues(searchParams)
|
||||
const name = getName(searchParams)
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -51,6 +52,7 @@ const CreateWorkspacePage: FC = () => {
|
||||
<title>{pageTitle("Create Workspace")}</title>
|
||||
</Helmet>
|
||||
<CreateWorkspacePageView
|
||||
name={name}
|
||||
defaultParameterValues={defaultParameterValues}
|
||||
loadingTemplates={createWorkspaceState.matches("gettingTemplates")}
|
||||
loadingTemplateSchema={createWorkspaceState.matches(
|
||||
@ -96,6 +98,10 @@ const CreateWorkspacePage: FC = () => {
|
||||
)
|
||||
}
|
||||
|
||||
const getName = (urlSearchParams: URLSearchParams): string => {
|
||||
return urlSearchParams.get("name") ?? ""
|
||||
}
|
||||
|
||||
const getDefaultParameterValues = (
|
||||
urlSearchParams: URLSearchParams,
|
||||
): Record<string, string> => {
|
||||
|
@ -38,6 +38,7 @@ export enum CreateWorkspaceErrors {
|
||||
}
|
||||
|
||||
export interface CreateWorkspacePageViewProps {
|
||||
name: string
|
||||
loadingTemplates: boolean
|
||||
loadingTemplateSchema: boolean
|
||||
creatingWorkspace: boolean
|
||||
@ -95,7 +96,7 @@ export const CreateWorkspacePageView: FC<
|
||||
const form: FormikContextType<TypesGen.CreateWorkspaceRequest> =
|
||||
useFormik<TypesGen.CreateWorkspaceRequest>({
|
||||
initialValues: {
|
||||
name: "",
|
||||
name: props.name,
|
||||
template_id: props.selectedTemplate ? props.selectedTemplate.id : "",
|
||||
rich_parameter_values: initialRichParameterValues,
|
||||
},
|
||||
|
Reference in New Issue
Block a user