Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' of https://github.com/evergreen-ci/spruce into DE…
Browse files Browse the repository at this point in the history
  • Loading branch information
sophstad committed Feb 29, 2024
2 parents 3e570c7 + d52e011 commit fde4455
Show file tree
Hide file tree
Showing 16 changed files with 62 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spruce",
"version": "3.0.213",
"version": "3.0.214",
"private": true,
"scripts": {
"bootstrap-logkeeper": "./scripts/bootstrap-logkeeper.sh",
Expand Down
2 changes: 2 additions & 0 deletions src/components/SpruceForm/customFormats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const {
validateJira,
validateJiraURL,
validateNoSpecialCharacters,
validateNoStartingOrTrailingWhitespace,
validatePercentage,
validateRegexp,
validateSlack,
Expand All @@ -17,6 +18,7 @@ export const customFormats = (jiraHost: string) => ({
noSpecialCharacters: validateNoSpecialCharacters,
// Permit empty string but disallow whitespace
noSpaces: /^$|^\S+$/,
noStartingOrTrailingWhitespace: validateNoStartingOrTrailingWhitespace,
validDuration: validateDuration,
validEmail: validateEmail,
validJiraTicket: validateJira,
Expand Down
5 changes: 5 additions & 0 deletions src/components/SpruceForm/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ export const transformErrors = (errors: AjvError[]) =>
...error,
message: "Value should not contain spaces.",
};
case "noStartingOrTrailingWhitespace":
return {
...error,
message: "Value should not start or end with whitespace.",
};
case "validDuration":
return {
...error,
Expand Down
2 changes: 2 additions & 0 deletions src/constants/externalResources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export const ignoredFilesDocumentationUrl = `${wikiBaseUrl}/Project-Configuratio

export const cliDocumentationUrl = `${wikiBaseUrl}/CLI`;

export const containersOnboardingDocumentationUrl = `${wikiBaseUrl}/Containers/Container-Tasks`;

export const windowsPasswordRulesURL =
"https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2003/cc786468(v=ws.10)?redirectedfrom=MSDN";

Expand Down
2 changes: 1 addition & 1 deletion src/pages/projectSettings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const ProjectSettings: React.FC = () => {
projectData?.projectSettings?.projectRef?.repoRefId || identifier;

// Assign project type in order to show/hide elements that should only appear for repos, attached projects, etc.
let projectType;
let projectType: ProjectType;
if (isRepo) {
projectType = ProjectType.Repo;
} else if (projectData?.projectSettings?.projectRef?.repoRefId) {
Expand Down
1 change: 1 addition & 0 deletions src/pages/projectSettings/tabs/AccessTab/getFormSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const getFormSchema = (
title: "Username",
default: "",
minLength: 1,
format: "noStartingOrTrailingWhitespace",
},
},
},
Expand Down
13 changes: 9 additions & 4 deletions src/pages/projectSettings/tabs/ContainersTab/ContainersTab.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { useMemo } from "react";
import Banner from "@leafygreen-ui/banner";
import { StyledLink } from "components/styles";
import { containersOnboardingDocumentationUrl } from "constants/externalResources";
import { ProjectSettingsTabRoutes } from "constants/routes";
import { useSpruceConfig } from "hooks";
import { BaseTab } from "../BaseTab";
Expand All @@ -26,10 +28,13 @@ export const ContainersTab: React.FC<TabProps> = ({
return (
<>
<Banner variant="warning">
Running tasks on containers is currently in beta, and is only available
to a select group of initial candidates. If you have any questions about
container tasks or are interested in exploring how this feature could
benefit your project, please reach out to us in #evergreen-users
We will not be implementing any new features or enhancements to our
existing container offerings, but will continue to provide maintenance
support for them. For more information on how to get started, please
refer to our{" "}
<StyledLink href={containersOnboardingDocumentationUrl}>
container onboarding guide.
</StyledLink>
</Banner>
<BaseTab
formSchema={formSchema}
Expand Down
4 changes: 4 additions & 0 deletions src/pages/projectSettings/tabs/GeneralTab/getFormSchema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const getFormSchema = (
branch: {
type: "string" as "string",
title: "Branch Name",
format: "noStartingOrTrailingWhitespace",
},
}),
other: {
Expand All @@ -75,6 +76,7 @@ export const getFormSchema = (
displayName: {
type: "string" as "string",
title: "Display Name",
format: "noStartingOrTrailingWhitespace",
},
...(projectType !== ProjectType.Repo && {
identifier: {
Expand All @@ -96,10 +98,12 @@ export const getFormSchema = (
remotePath: {
type: "string" as "string",
title: "Config File",
format: "noStartingOrTrailingWhitespace",
},
spawnHostScriptPath: {
type: "string" as "string",
title: "Spawn Host Script Path",
format: "noStartingOrTrailingWhitespace",
},
versionControlEnabled: {
type: ["boolean", "null"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export const getFormSchema = (
title: "Username",
default: "",
minLength: 1,
format: "noStartingOrTrailingWhitespace",
},
},
),
Expand All @@ -168,6 +169,7 @@ export const getFormSchema = (
title: "Team",
default: "",
minLength: 1,
format: "noStartingOrTrailingWhitespace",
},
},
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,19 @@ export const getFormSchema = (
title: "Alias",
default: "",
minLength: 1,
format: "noStartingOrTrailingWhitespace",
},
childProjectIdentifier: {
type: "string" as "string",
title: "Project",
default: "",
minLength: 1,
format: "noStartingOrTrailingWhitespace",
},
parentAsModule: {
type: "string" as "string",
title: "Module",
format: "noStartingOrTrailingWhitespace",
},
status: {
type: "string" as "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const getFormSchema = (
title: "Config File",
minLength: 1,
default: "",
format: "noStartingOrTrailingWhitespace",
},
alias: {
type: "string" as "string",
Expand Down
2 changes: 2 additions & 0 deletions src/pages/projectSettings/tabs/PluginsTab/getFormSchema.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export const getFormSchema = (
createProject: {
type: "string" as "string",
title: "",
format: "noStartingOrTrailingWhitespace",
},
},
},
Expand Down Expand Up @@ -204,6 +205,7 @@ export const getFormSchema = (
default: "",
minLength: 1,
maxLength: 40,
format: "noStartingOrTrailingWhitespace",
},
urlTemplate: {
type: "string" as "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ export const getFormSchema = (
title: "Project",
default: "",
minLength: 1,
format: "noStartingOrTrailingWhitespace",
},
configFile: {
type: "string" as "string",
title: "Config File",
default: "",
minLength: 1,
format: "noStartingOrTrailingWhitespace",
},
level: {
type: "string" as "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const getFormSchema = (
title: "Variable Name",
default: "",
minLength: 1,
format: "noStartingOrTrailingWhitespace",
},
varValue: {
type: "string" as "string",
Expand Down
11 changes: 11 additions & 0 deletions src/utils/validators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,24 @@ const validateNoSpecialCharacters = (str: string): boolean => {
return noSpecialCharacters.test(str);
};

/**
* `validateNoStartingOrTrailingWhitespace` tests if a provided string contains no starting or trailing whitespace
* @param str - The string to test.
* @returns - true if the string has no starting or trailing whitespace and false otherwise
*/
const validateNoStartingOrTrailingWhitespace = (str: string): boolean => {
const noStartingOrTrailingWhitespaceRegex = /^(?! ).*(?<! )$/;
return noStartingOrTrailingWhitespaceRegex.test(str);
};

export {
allowedSymbols,
validateDuration,
validateEmail,
validateJira,
validateJiraURL,
validateNoSpecialCharacters,
validateNoStartingOrTrailingWhitespace,
validateObjectId,
validatePercentage,
validateRegexp,
Expand Down
15 changes: 15 additions & 0 deletions src/utils/validators/validators.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
validateJira,
validateJiraURL,
validateNoSpecialCharacters,
validateNoStartingOrTrailingWhitespace,
validateObjectId,
validateRegexp,
validateSlack,
Expand All @@ -24,6 +25,20 @@ describe("validateNoSpecialCharacters", () => {
});
});

describe("validateNoStartingOrTrailingWhitespace", () => {
it("returns true if string has no starting or trailing whitespace", () => {
expect(validateNoStartingOrTrailingWhitespace("")).toBe(true);
expect(validateNoStartingOrTrailingWhitespace("a")).toBe(true);
expect(validateNoStartingOrTrailingWhitespace("helloworld")).toBe(true);
expect(validateNoStartingOrTrailingWhitespace(" helloWorld123")).toBe(
false,
);
expect(validateNoStartingOrTrailingWhitespace("helloWorld123 ")).toBe(
false,
);
});
});

describe("validateObjectId", () => {
it("validates object ids", () => {
expect(validateObjectId("5f74d99ab2373627c047c5e5")).toBeTruthy();
Expand Down

0 comments on commit fde4455

Please sign in to comment.