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' into DEVPROD-3283
Browse files Browse the repository at this point in the history
  • Loading branch information
khelif96 committed Dec 27, 2023
2 parents 8289f06 + 054203d commit a8da330
Show file tree
Hide file tree
Showing 40 changed files with 489 additions and 152 deletions.
8 changes: 8 additions & 0 deletions cypress/integration/distroSettings/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,11 @@ describe("using the distro dropdown", () => {
});
});
});

describe("/distros redirect route", () => {
it("should redirect to the first distro available", () => {
cy.visit("/distros");
cy.location("pathname").should("not.contain", "/distros");
cy.location("pathname").should("eq", "/distro/localhost/settings/general");
});
});
61 changes: 61 additions & 0 deletions cypress/integration/projectSettings/stepback_bisect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { clickSave } from "../../utils";
import { getGeneralRoute, project, projectUseRepoEnabled } from "./constants";

describe("Stepback bisect setting", () => {
describe("Repo project present", () => {
const destination = getGeneralRoute(projectUseRepoEnabled);

beforeEach(() => {
cy.visit(destination);
});

it("Starts as default to repo", () => {
cy.dataCy("stepback-bisect-group")
.contains("Default to repo")
.find("input")
.should("have.attr", "aria-checked", "true");
});

it("Clicking on enabled and then save shows a success toast", () => {
cy.dataCy("stepback-bisect-group").contains("Enable").click();
clickSave();
cy.validateToast("success", "Successfully updated project");

cy.reload();

cy.dataCy("stepback-bisect-group")
.contains("Enable")
.find("input")
.should("have.attr", "aria-checked", "true");
});
});

describe("Repo project not present", () => {
const destination = getGeneralRoute(project);

beforeEach(() => {
cy.visit(destination);
});

it("Starts as disabled", () => {
cy.dataCy("stepback-bisect-group")
.contains("Disable")
.find("input")
.should("have.attr", "aria-checked", "true");
});

it("Clicking on enabled and then save shows a success toast", () => {
cy.dataCy("stepback-bisect-group").contains("Enable").click();

clickSave();
cy.validateToast("success", "Successfully updated project");

cy.reload();

cy.dataCy("stepback-bisect-group")
.contains("Enable")
.find("input")
.should("have.attr", "aria-checked", "true");
});
});
});
2 changes: 1 addition & 1 deletion cypress/integration/spawn/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ describe("Navigating to Spawn Host page", () => {
cy.dataCy("distro-option-ubuntu1804-workstation")
.should("be.visible")
.click();
cy.dataCy("volume-select").should("be.disabled");
cy.dataCy("volume-select").should("have.attr", "aria-disabled", "true");
});

it("Clicking 'Add new key' hides the key name dropdown and shows the key value text area", () => {
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/spawn/volume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ describe("Spawn volume page", () => {
).click();
cy.dataCy("distro-input").click();
cy.dataCy("distro-option-ubuntu1804-workstation").click();
cy.dataCy("region-select").should("be.disabled");
cy.dataCy("region-select").should("have.attr", "aria-disabled", "true");
cy.dataCy("migrate-modal").contains("Next").click({ force: true });
cy.dataCy("migrate-modal")
.contains("Migrate Volume")
Expand Down
2 changes: 1 addition & 1 deletion cypress/integration/task/files_tables.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
describe("files table", () => {
const FILES_ROUTE = "/task/evergreen_ubuntu1604_89/files";
const FILES_ROUTE_WITHOUT_FILES =
"/task/evergreen_ubuntu1604_test_model_commitqueue_patch_5e823e1f28baeaa22ae00823d83e03082cd148ab_5e4ff3abe3c3317e352062e4_20_02_21_15_13_48/files ";
"/task/evergreen_ubuntu1604_test_model_commitqueue_patch_5e823e1f28baeaa22ae00823d83e03082cd148ab_5e4ff3abe3c3317e352062e4_20_02_21_15_13_48/files";

it("File names under name column should link to a new tab", () => {
cy.visit(FILES_ROUTE);
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spruce",
"version": "3.0.184",
"version": "3.0.185",
"private": true,
"scripts": {
"bootstrap-logkeeper": "./scripts/bootstrap-logkeeper.sh",
Expand Down Expand Up @@ -69,8 +69,8 @@
"@leafygreen-ui/confirmation-modal": "5.0.6",
"@leafygreen-ui/emotion": "4.0.7",
"@leafygreen-ui/expandable-card": "3.0.5",
"@leafygreen-ui/guide-cue": "5.0.4",
"@leafygreen-ui/icon": "11.12.1",
"@leafygreen-ui/guide-cue": "5.0.5",
"@leafygreen-ui/icon": "11.26.0",
"@leafygreen-ui/icon-button": "15.0.5",
"@leafygreen-ui/inline-definition": "6.0.14",
"@leafygreen-ui/interaction-ring": "7.0.2",
Expand All @@ -86,7 +86,7 @@
"@leafygreen-ui/radio-group": "10.1.1",
"@leafygreen-ui/search-input": "2.0.8",
"@leafygreen-ui/segmented-control": "8.2.6",
"@leafygreen-ui/select": "10.2.0",
"@leafygreen-ui/select": "11.1.1",
"@leafygreen-ui/side-nav": "14.0.3",
"@leafygreen-ui/skeleton-loader": "1.1.0",
"@leafygreen-ui/table": "12.1.4",
Expand Down Expand Up @@ -158,7 +158,7 @@
"@types/new-relic-browser": "0.1212.2",
"@types/node": "^16.11.47",
"@types/pluralize": "0.0.29",
"@types/prompts": "2.4.6",
"@types/prompts": "2.4.9",
"@types/react": "18.2.0",
"@types/react-dom": "18.2.0",
"@typescript-eslint/eslint-plugin": "5.57.1",
Expand Down
5 changes: 5 additions & 0 deletions src/components/Content/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Route, Routes, Navigate } from "react-router-dom";
import {
DistroSettingsRedirect,
ProjectSettingsRedirect,
UserPatchesRedirect,
WaterfallCommitsRedirect,
Expand Down Expand Up @@ -45,6 +46,10 @@ export const Content: React.FC = () => (
<Route path={`${routes.distroSettings}/*`} element={<Distro />}>
<Route path={tab} element={null} />
</Route>
<Route
path={redirectRoutes.distroSettings}
element={<DistroSettingsRedirect />}
/>
<Route path={routes.host} element={<Host />} />
<Route path={routes.hosts} element={<Hosts />} />
<Route path={routes.jobLogs} element={<JobLogs />}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header/AuxiliaryDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const AuxiliaryDropdown: React.FC<AuxiliaryDropdownProps> = ({
projectIdentifier,
}) => {
const { sendEvent } = useNavbarAnalytics();
const distro = useFirstDistro();
const { distro } = useFirstDistro();

const menuItems = [
{
Expand Down
1 change: 0 additions & 1 deletion src/components/Hosts/UpdateStatusModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ export const UpdateStatusModal: React.FC<Props> = ({
);
};

// @ts-expect-error
const StyledSelect = styled(Select)`
margin-bottom: ${size.xs};
`;
Expand Down
1 change: 0 additions & 1 deletion src/components/PageSizeSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const PageSizeSelector: React.FC<Props> = ({ onChange, value, ...rest }) => (
</StyledSelect>
);

// @ts-expect-error
const StyledSelect = styled(Select)`
width: 120px;
`;
Expand Down
19 changes: 19 additions & 0 deletions src/components/Redirects/DistroSettingsRedirect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Navigate } from "react-router-dom";
import {
getDistroSettingsRoute,
DistroSettingsTabRoutes,
} from "constants/routes";
import { useFirstDistro } from "hooks";

export const DistroSettingsRedirect: React.FC = () => {
const { distro, loading } = useFirstDistro();

if (loading) {
return null;
}
return (
<Navigate
to={getDistroSettingsRoute(distro, DistroSettingsTabRoutes.General)}
/>
);
};
2 changes: 2 additions & 0 deletions src/components/Redirects/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { DistroSettingsRedirect } from "./DistroSettingsRedirect";
import { ProjectSettingsRedirect } from "./ProjectSettingsRedirect";
import { UserPatchesRedirect } from "./UserPatchesRedirect";
import { WaterfallCommitsRedirect } from "./WaterfallCommitsRedirect";

export {
DistroSettingsRedirect,
ProjectSettingsRedirect,
UserPatchesRedirect,
WaterfallCommitsRedirect,
Expand Down
1 change: 0 additions & 1 deletion src/components/TupleSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ const LabelContainer = styled.div`
flex-direction: row;
`;

// @ts-expect-error
const GroupedSelect = styled(Select)`
width: 30%;
/* overwrite lg borders https://jira.mongodb.org/browse/PD-1995 */
Expand Down
2 changes: 2 additions & 0 deletions src/constants/cookies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ export const INCLUDE_COMMIT_QUEUE_USER_PATCHES =
"include-commit-queue-user-patches";
export const INCLUDE_HIDDEN_PATCHES = "include-hidden-patches";
export const SEEN_HONEYCOMB_GUIDE_CUE = "seen-honeycomb-guide-cue";
export const SEEN_PARSLEY_FILES_GUIDE_CUE = "seen-parsley-files-guide-cue";
export const SEEN_MIGRATE_GUIDE_CUE = "seen-migrate-guide-cue";
export const SLACK_NOTIFICATION_BANNER = "has-closed-slack-banner";
export const SUBSCRIPTION_METHOD = "subscription-method";
2 changes: 2 additions & 0 deletions src/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const paths = {
commits: "/commits",
container: "/container",
distro: "/distro",
distros: "/distros",
host: "/host",
hosts: "/hosts",
jobLogs: "/job-logs",
Expand All @@ -74,6 +75,7 @@ const paths = {
waterfall: "/waterfall",
};
export const redirectRoutes = {
distroSettings: paths.distros,
projectSettings: paths.projects,
userPatches: `${paths.user}/:id`,
waterfall: `${paths.waterfall}/:projectIdentifier`,
Expand Down
2 changes: 2 additions & 0 deletions src/gql/fragments/projectSettings/general.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ fragment ProjectGeneralSettings on Project {
repo
repotrackerDisabled
spawnHostScriptPath
stepbackBisect
stepbackDisabled
taskSync {
configEnabled
Expand All @@ -32,6 +33,7 @@ fragment RepoGeneralSettings on RepoRef {
repo
repotrackerDisabled
spawnHostScriptPath
stepbackBisect
stepbackDisabled
taskSync {
configEnabled
Expand Down
11 changes: 11 additions & 0 deletions src/gql/generated/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3459,6 +3459,7 @@ export type ProjectGeneralSettingsFragment = {
repo: string;
repotrackerDisabled?: boolean | null;
spawnHostScriptPath: string;
stepbackBisect?: boolean | null;
stepbackDisabled?: boolean | null;
versionControlEnabled?: boolean | null;
taskSync: {
Expand All @@ -3481,6 +3482,7 @@ export type RepoGeneralSettingsFragment = {
repo: string;
repotrackerDisabled: boolean;
spawnHostScriptPath: string;
stepbackBisect?: boolean | null;
stepbackDisabled: boolean;
versionControlEnabled: boolean;
taskSync: {
Expand Down Expand Up @@ -3628,6 +3630,7 @@ export type ProjectSettingsFieldsFragment = {
repo: string;
repotrackerDisabled?: boolean | null;
spawnHostScriptPath: string;
stepbackBisect?: boolean | null;
stepbackDisabled?: boolean | null;
versionControlEnabled?: boolean | null;
notifyOnBuildFailure?: boolean | null;
Expand Down Expand Up @@ -3834,6 +3837,7 @@ export type RepoSettingsFieldsFragment = {
repo: string;
repotrackerDisabled: boolean;
spawnHostScriptPath: string;
stepbackBisect?: boolean | null;
stepbackDisabled: boolean;
versionControlEnabled: boolean;
notifyOnBuildFailure: boolean;
Expand Down Expand Up @@ -4235,6 +4239,7 @@ export type ProjectEventSettingsFragment = {
repo: string;
repotrackerDisabled?: boolean | null;
spawnHostScriptPath: string;
stepbackBisect?: boolean | null;
stepbackDisabled?: boolean | null;
notifyOnBuildFailure?: boolean | null;
githubTriggerAliases?: Array<string> | null;
Expand Down Expand Up @@ -6698,6 +6703,7 @@ export type ProjectEventLogsQuery = {
repo: string;
repotrackerDisabled?: boolean | null;
spawnHostScriptPath: string;
stepbackBisect?: boolean | null;
stepbackDisabled?: boolean | null;
notifyOnBuildFailure?: boolean | null;
githubTriggerAliases?: Array<string> | null;
Expand Down Expand Up @@ -6910,6 +6916,7 @@ export type ProjectEventLogsQuery = {
repo: string;
repotrackerDisabled?: boolean | null;
spawnHostScriptPath: string;
stepbackBisect?: boolean | null;
stepbackDisabled?: boolean | null;
notifyOnBuildFailure?: boolean | null;
githubTriggerAliases?: Array<string> | null;
Expand Down Expand Up @@ -7197,6 +7204,7 @@ export type ProjectSettingsQuery = {
repo: string;
repotrackerDisabled?: boolean | null;
spawnHostScriptPath: string;
stepbackBisect?: boolean | null;
stepbackDisabled?: boolean | null;
versionControlEnabled?: boolean | null;
notifyOnBuildFailure?: boolean | null;
Expand Down Expand Up @@ -7455,6 +7463,7 @@ export type RepoEventLogsQuery = {
repo: string;
repotrackerDisabled?: boolean | null;
spawnHostScriptPath: string;
stepbackBisect?: boolean | null;
stepbackDisabled?: boolean | null;
notifyOnBuildFailure?: boolean | null;
githubTriggerAliases?: Array<string> | null;
Expand Down Expand Up @@ -7667,6 +7676,7 @@ export type RepoEventLogsQuery = {
repo: string;
repotrackerDisabled?: boolean | null;
spawnHostScriptPath: string;
stepbackBisect?: boolean | null;
stepbackDisabled?: boolean | null;
notifyOnBuildFailure?: boolean | null;
githubTriggerAliases?: Array<string> | null;
Expand Down Expand Up @@ -7883,6 +7893,7 @@ export type RepoSettingsQuery = {
repo: string;
repotrackerDisabled: boolean;
spawnHostScriptPath: string;
stepbackBisect?: boolean | null;
stepbackDisabled: boolean;
versionControlEnabled: boolean;
notifyOnBuildFailure: boolean;
Expand Down
1 change: 1 addition & 0 deletions src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ export { useDateFormat } from "./useDateFormat";
export { useFirstDistro } from "./useFirstDistro";
export { useBreadcrumbRoot } from "./useBreadcrumbRoot";
export { useResize } from "./useResize";
export { useRunningTime } from "./useRunningTime";
17 changes: 10 additions & 7 deletions src/hooks/useFirstDistro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@ import { DISTROS } from "gql/queries";
/**
* `useFirstDistro` returns the alphabetically first distro from Evergreen's list of distros.
* This can be used to generate a general link to distro settings.
* @returns the distro ID
* @returns an object containing the distro ID (string) and loading state (boolean)
*/
export const useFirstDistro = () => {
const { data } = useQuery<DistrosQuery, DistrosQueryVariables>(DISTROS, {
variables: {
onlySpawnable: false,
},
});
const { data, loading } = useQuery<DistrosQuery, DistrosQueryVariables>(
DISTROS,
{
variables: {
onlySpawnable: false,
},
}
);

return data?.distros?.[0]?.name ?? "ubuntu2204-large";
return { distro: data?.distros?.[0]?.name ?? "ubuntu2204-large", loading };
};
Loading

0 comments on commit a8da330

Please sign in to comment.