Skip to content

feat: added URL param name to allow setting workspace name #7528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: added URL param name to allow setting workspace name
  • Loading branch information
MrPeacockNLB committed May 16, 2023
commit a6a6683a735a8974def00ddf336df160b705f401
8 changes: 8 additions & 0 deletions site/src/pages/CreateWorkspacePage/CreateWorkspacePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ const CreateWorkspacePage: FC = () => {
} = createWorkspaceState.context
const [searchParams] = useSearchParams()
const defaultParameterValues = getDefaultParameterValues(searchParams)
const name = getName(searchParams)

return (
<>
<Helmet>
<title>{pageTitle("Create Workspace")}</title>
</Helmet>
<CreateWorkspacePageView
name={name}
defaultParameterValues={defaultParameterValues}
loadingTemplates={createWorkspaceState.matches("gettingTemplates")}
loadingTemplateSchema={createWorkspaceState.matches(
Expand Down Expand Up @@ -96,6 +98,12 @@ const CreateWorkspacePage: FC = () => {
)
}

const getName = (
urlSearchParams: URLSearchParams,
): string => {
return urlSearchParams.get("name") ?? ""
}

const getDefaultParameterValues = (
urlSearchParams: URLSearchParams,
): Record<string, string> => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export enum CreateWorkspaceErrors {
}

export interface CreateWorkspacePageViewProps {
name: string
loadingTemplates: boolean
loadingTemplateSchema: boolean
creatingWorkspace: boolean
Expand Down Expand Up @@ -92,7 +93,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,
},
Expand Down