diff --git a/components/dashboard/src/components/DropDown2.tsx b/components/dashboard/src/components/DropDown2.tsx index bd4e2d15332247..95f9ec2b2cc64a 100644 --- a/components/dashboard/src/components/DropDown2.tsx +++ b/components/dashboard/src/components/DropDown2.tsx @@ -41,7 +41,6 @@ export const DropDown2: FunctionComponent = ({ onSelectionChange, onSearchChange, }) => { - const triggerEl = useRef(null); const inputEl = useRef(null); const [showDropDown, setShowDropDown] = useState(!disabled && !!expanded); const [search, setSearch] = useState(""); @@ -140,9 +139,10 @@ export const DropDown2: FunctionComponent = ({ } return; } + // Capture escape ourselves instead of letting radix do it + // allows us to close the dropdown and preventDefault on event if (e.key === "Escape") { setShowDropDown(false); - triggerEl.current?.focus(); e.preventDefault(); } if (e.key === "Enter") { @@ -173,7 +173,6 @@ export const DropDown2: FunctionComponent = ({ return ( = ({ onClose, onCreated }) => { return; } - const projectName = selectedRepo.repositoryName || selectedRepo.projectName || selectedRepo.url; - const newProjectArgs: CreateProjectArgs = { - name: projectName, - slug: projectName, + // leave the name empty to let the backend generate the name + name: "", + // deprecated + slug: "", cloneUrl: selectedRepo.url, appInstallationId: "", }; diff --git a/components/server/src/workspace/gitpod-server-impl.ts b/components/server/src/workspace/gitpod-server-impl.ts index c094cce713457b..2a24fe3f9205c2 100644 --- a/components/server/src/workspace/gitpod-server-impl.ts +++ b/components/server/src/workspace/gitpod-server-impl.ts @@ -2541,6 +2541,10 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable { await this.guardTeamOperation(params.teamId || "", "get"); await this.auth.checkPermissionOnOrganization(user.id, "create_project", params.teamId); + if ((params.name || "").length > 32) { + throw new ApplicationError(ErrorCodes.BAD_REQUEST, "A project name cannot be longer than 32 characters."); + } + // Ensure we can parse the provided url ok const { host, owner, repo } = RepoURL.parseRepoUrl(params.cloneUrl) || {}; if (!host || !owner || !repo) { @@ -2564,7 +2568,18 @@ export class GitpodServerImpl implements GitpodServerWithTracing, Disposable { ); } - const project = await this.projectsService.createProject(params, user); + const newProjectParams: CreateProjectParams = { + cloneUrl: params.cloneUrl, + teamId: params.teamId, + // Default to repo name (capped at 32 chars) if name is not provided + name: params.name || repo.substring(0, 32), + // TODO: we should be able to remove this - field deprecated + slug: "", + // TODO: we should be able to remove this since we don't use it anymore + appInstallationId: params.appInstallationId, + }; + + const project = await this.projectsService.createProject(newProjectParams, user); // update client registration for the logged in user if (this.client && !this.disposables.disposed) {