Skip to content

Increase project name max length #18941

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 3 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
2 changes: 1 addition & 1 deletion components/dashboard/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function Header(p: HeaderProps) {
return (
<div className="app-container border-gray-200 dark:border-gray-800">
<div className="flex pb-8 pt-6">
<div>
<div className="w-full">
{p.complexTitle ? p.complexTitle : <Heading1 tracking="tight">{p.title}</Heading1>}
{typeof p.subtitle === "string" ? (
<Subheading tracking="wide">{p.subtitle}</Subheading>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ export const Heading1: FC<HeadingProps> = ({ id, color, tracking, className, chi
return (
<h1
id={id}
className={classNames(getHeadingColor(color), getTracking(tracking), "font-bold text-4xl", className)}
className={classNames(
getHeadingColor(color),
getTracking(tracking),
"font-bold text-4xl truncate",
className,
)}
>
{children}
</h1>
Expand Down
2 changes: 1 addition & 1 deletion components/dashboard/src/projects/ProjectListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ type ProjectLinkProps = {
};
const ProjectLink: FunctionComponent<ProjectLinkProps> = ({ project }) => {
return (
<Link to={`/projects/${project.id}`}>
<Link to={`/projects/${project.id}`} className="truncate">
<span className="text-xl font-semibold">{project.name}</span>
</Link>
);
Expand Down
8 changes: 5 additions & 3 deletions components/dashboard/src/projects/ProjectSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import { InputField } from "../components/forms/InputField";
import { SelectInputField } from "../components/forms/SelectInputField";
import debounce from "lodash.debounce";

const MAX_PROJECT_NAME_LENGTH = 100;

export function ProjectSettingsPage(props: { project?: Project; children?: React.ReactNode }) {
return (
<PageWithSubMenu
Expand All @@ -49,8 +51,8 @@ export default function ProjectSettingsView() {
let badProjectName: string | undefined;
if (project) {
badProjectName = projectName.length > 0 ? undefined : "Project name can not be blank.";
if (projectName.length > 32) {
badProjectName = "Project name can not be longer than 32 characters.";
if (projectName.length > MAX_PROJECT_NAME_LENGTH) {
badProjectName = `Project name can not be longer than ${MAX_PROJECT_NAME_LENGTH} characters.`;
}
}
const history = useHistory();
Expand Down Expand Up @@ -221,7 +223,7 @@ export default function ProjectSettingsView() {
<Heading2>Project Name</Heading2>
<form onSubmit={updateProjectName}>
<TextInputField
hint="The name can be up to 32 characters long."
hint={`The name can be up to ${MAX_PROJECT_NAME_LENGTH} characters long.`}
value={projectName}
error={badProjectName}
onChange={setProjectName}
Expand Down
19 changes: 13 additions & 6 deletions components/server/src/projects/projects-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import { TransactionalContext } from "@gitpod/gitpod-db/lib/typeorm/transactiona
import { ScmService } from "./scm-service";
import { daysBefore, isDateSmaller } from "@gitpod/gitpod-protocol/lib/util/timeutil";

const MAX_PROJECT_NAME_LENGTH = 100;

@injectable()
export class ProjectsService {
constructor(
Expand Down Expand Up @@ -205,8 +207,11 @@ export class ProjectsService {
throw new ApplicationError(ErrorCodes.BAD_REQUEST, "Clone URL must be less than 1k characters.");
}

if (name.length > 32) {
throw new ApplicationError(ErrorCodes.BAD_REQUEST, "Project name cannot be longer than 32 characters.");
if (name.length > MAX_PROJECT_NAME_LENGTH) {
throw new ApplicationError(
ErrorCodes.BAD_REQUEST,
`Project name cannot be longer than ${MAX_PROJECT_NAME_LENGTH} characters.`,
);
}

try {
Expand Down Expand Up @@ -245,7 +250,7 @@ export class ProjectsService {

const project = Project.create({
// Default to repository name
name: name || parsedUrl.repo.substring(0, 32),
name: name || parsedUrl.repo.substring(0, MAX_PROJECT_NAME_LENGTH),
cloneUrl,
teamId,
appInstallationId,
Expand Down Expand Up @@ -369,9 +374,11 @@ export class ProjectsService {
const partial: PartialProject = { id: partialProject.id };
if (partialProject.name) {
partialProject.name = partialProject.name.trim();
// check it is between 0 and 32 characters
if (partialProject.name.length > 32) {
throw new ApplicationError(ErrorCodes.BAD_REQUEST, "Project name must be less than 32 characters.");
if (partialProject.name.length > MAX_PROJECT_NAME_LENGTH) {
throw new ApplicationError(
ErrorCodes.BAD_REQUEST,
`Project name must be less than ${MAX_PROJECT_NAME_LENGTH} characters.`,
);
}
if (partialProject.name.length === 0) {
throw new ApplicationError(ErrorCodes.BAD_REQUEST, "Project name must not be empty.");
Expand Down