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-4608
Browse files Browse the repository at this point in the history
  • Loading branch information
ZackarySantana committed Mar 20, 2024
2 parents cec293f + 5dcee95 commit a52782f
Show file tree
Hide file tree
Showing 32 changed files with 1,614 additions and 1,102 deletions.
23 changes: 17 additions & 6 deletions .evergreen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ post:
- func: assume-ec2-role
- func: attach-codegen-diff
- func: attach-cypress-results
- func: attach-logkeeper-logs
- func: attach-source-map
- func: attach-storybook
- func: attach-test-results
Expand Down Expand Up @@ -251,12 +252,9 @@ functions:
shell: bash
script: |
${PREPARE_SHELL}
# Only record to cypress cloud if this is a pr, mainline commit or an intentional patch.
# And only allow spec filtering for an intentional patch.
if [[ "${requester}" == "github_pr" || "${requester}" == "commit" ]]; then
yarn cy:run --record --key "${spruce_cypress_record_key}" --reporter junit
elif [[ "${requester}" == "patch" ]]; then
yarn cy:run --record --key "${spruce_cypress_record_key}" --reporter junit --spec "${cypress_spec}"
# Allow spec filtering for an intentional patch.
if [[ "${requester}" == "patch" ]]; then
yarn cy:run --reporter junit --spec "${cypress_spec}"
else
yarn cy:run --reporter junit
fi
Expand Down Expand Up @@ -297,6 +295,19 @@ functions:
files:
- "./spruce/bin/cypress/*.xml"

attach-logkeeper-logs:
command: s3.put
type: system
params:
aws_key: ${AWS_ACCESS_KEY_ID}
aws_secret: ${AWS_SECRET_ACCESS_KEY}
aws_session_token: ${AWS_SESSION_TOKEN}
local_file: spruce/logkeeper/logkeeperapp.log
remote_file: spruce/${task_id}/${execution}/logkeeperapp.log
bucket: mciuploads
content_type: text/plain
permissions: public-read

attach-source-map:
command: s3.put
type: system
Expand Down
12 changes: 7 additions & 5 deletions cypress/integration/task/execution_task_table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ describe("Execution task table", () => {
});

it("Should have a default sort order applied", () => {
cy.location("search").should("contain", "sorts=STATUS%3AASC");
cy.location("search").should("contain", "sortBy=STATUS");
cy.location("search").should("contain", "sortDir=ASC");
});

it("Updates the url when column headers are clicked", () => {
cy.dataCy("tasks-table").find("th").contains("Name").click();
cy.location("search").should("contain", "NAME%3AASC");
const nameSortControl = "button[aria-label='Sort by Name']";
cy.get(nameSortControl).click();
cy.location("search").should("contain", "STATUS%3AASC%3BNAME%3AASC");

cy.dataCy("tasks-table").find("th").contains("Name").click();
cy.location("search").should("contain", "NAME%3ADESC");
cy.get(nameSortControl).click();
cy.location("search").should("contain", "STATUS%3AASC%3BNAME%3ADESC");
});
});
2 changes: 1 addition & 1 deletion cypress/integration/task/task_actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ const tasks = {
1: "/task/evergreen_ubuntu1604_test_model_patch_5e823e1f28baeaa22ae00823d83e03082cd148ab_5e4ff3abe3c3317e352062e4_20_02_21_15_13_48",
2: "/task/evergreen_lint_lint_service_patch_5e823e1f28baeaa22ae00823d83e03082cd148ab_5e4ff3abe3c3317e352062e4_20_02_21_15_13_48",
3: "/task/evergreen_ubuntu1604_dist_patch_33016573166a36bd5f46b4111151899d5c4e95b1_5ecedafb562343215a7ff297_20_05_27_21_39_46",
4: "/task/mci_ubuntu1604_display_asdf_patch_a1d2c8f70bf5c543de8b9641ac1ec08def1ddb26_5f74d99ab2373627c047c5e5_20_09_30_19_16_47/execution-tasks?execution=0&sorts=STATUS%3AASC",
4: "/task/mci_ubuntu1604_display_asdf_patch_a1d2c8f70bf5c543de8b9641ac1ec08def1ddb26_5f74d99ab2373627c047c5e5_20_09_30_19_16_47/execution-tasks?execution=0",
5: "/task/evergreen_test_model_patch_5e823e1f28baeaa22ae00823d83e03082cd148ab_5e4ff3abe3c3317e352062e4_20_02_21_15_13_48",
};
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "spruce",
"version": "3.0.223",
"version": "3.0.226",
"private": true,
"scripts": {
"bootstrap-logkeeper": "./scripts/bootstrap-logkeeper.sh",
Expand Down Expand Up @@ -65,10 +65,10 @@
"@leafygreen-ui/card": "10.0.5",
"@leafygreen-ui/checkbox": "12.0.5",
"@leafygreen-ui/code": "14.2.18",
"@leafygreen-ui/combobox": "7.2.0",
"@leafygreen-ui/combobox": "8.1.1",
"@leafygreen-ui/confirmation-modal": "5.0.9",
"@leafygreen-ui/emotion": "4.0.7",
"@leafygreen-ui/expandable-card": "3.0.5",
"@leafygreen-ui/expandable-card": "3.1.0",
"@leafygreen-ui/guide-cue": "5.0.5",
"@leafygreen-ui/icon": "11.26.0",
"@leafygreen-ui/icon-button": "15.0.19",
Expand Down Expand Up @@ -109,7 +109,7 @@
"deep-object-diff": "1.1.9",
"env-cmd": "10.1.0",
"graphql": "16.8.1",
"html-react-parser": "4.2.9",
"html-react-parser": "5.1.8",
"js-cookie": "3.0.5",
"linkify-html": "4.1.1",
"linkifyjs": "4.1.0",
Expand Down
7 changes: 6 additions & 1 deletion src/analytics/projectHealth/useProjectHealthAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ type Action =
name: "Add Notification";
subscription: SaveSubscriptionForUserMutationVariables["subscription"];
}
| { name: "Toggle view"; toggle: ProjectHealthView };
| { name: "Toggle view"; toggle: ProjectHealthView }
| {
name: "Redirect to project identifier";
projectId: string;
projectIdentifier: string;
};

export const useProjectHealthAnalytics = (p: { page: pageType }) =>
useAnalyticsRoot<Action>("ProjectHealthPages", { page: p.page });
6 changes: 1 addition & 5 deletions src/analytics/task/useTaskAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,7 @@ type Action =
}
| {
name: "Sort Execution Tasks Table";
sortBy:
| TaskSortCategory.Name
| TaskSortCategory.Status
| TaskSortCategory.BaseStatus
| TaskSortCategory.Variant;
sortBy: TaskSortCategory | TaskSortCategory[];
}
| { name: "Restart" }
| { name: "Schedule" }
Expand Down
17 changes: 12 additions & 5 deletions src/components/Header/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ import { useAuthStateContext } from "context/Auth";
import { UserQuery, SpruceConfigQuery } from "gql/generated/types";
import { USER, SPRUCE_CONFIG } from "gql/queries";
import { useLegacyUIURL } from "hooks";
import { validators } from "utils";
import { AuxiliaryDropdown } from "./AuxiliaryDropdown";
import { UserDropdown } from "./UserDropdown";

const { validateObjectId } = validators;

const { blue, gray, white } = palette;

export const Navbar: React.FC = () => {
Expand All @@ -33,16 +36,20 @@ export const Navbar: React.FC = () => {
const { projectIdentifier: projectFromUrl } = useParams<{
projectIdentifier: string;
}>();
const currProject = Cookies.get(CURRENT_PROJECT);

// Update current project cookie if the project in the URL does not equal the cookie value.
// Update current project cookie if the project in the URL is not an objectId and is not equal
// to the current project.
// This will inform future navigations to the /commits page.
useEffect(() => {
if (projectFromUrl && projectFromUrl !== Cookies.get(CURRENT_PROJECT)) {
if (
projectFromUrl &&
!validateObjectId(projectFromUrl) &&
projectFromUrl !== currProject
) {
Cookies.set(CURRENT_PROJECT, projectFromUrl);
}
}, [projectFromUrl]);

const currProject = projectFromUrl ?? Cookies.get(CURRENT_PROJECT);
}, [currProject, projectFromUrl]);

const { data: configData } = useQuery<SpruceConfigQuery>(SPRUCE_CONFIG, {
skip: currProject !== undefined,
Expand Down
155 changes: 155 additions & 0 deletions src/components/TasksTable/Columns.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
import { LGColumnDef } from "@leafygreen-ui/table";
import Tooltip from "@leafygreen-ui/tooltip";
import pluralize from "pluralize";
import { ConditionalWrapper } from "components/ConditionalWrapper";
import { StyledRouterLink } from "components/styles";
import TaskStatusBadge from "components/TaskStatusBadge";
import { TreeDataEntry } from "components/TreeSelect";
import { getVariantHistoryRoute } from "constants/routes";
import { mergeTaskVariant } from "constants/task";
import { zIndex } from "constants/tokens";
import { TaskSortCategory } from "gql/generated/types";
import { TaskStatus } from "types/task";
import { TaskLink } from "./TaskLink";
import { TaskTableInfo } from "./types";

export const getColumnsTemplate = ({
baseStatusOptions = [],
isPatch = false,
onClickTaskLink = () => {},
showTaskExecutionLabel = false,
statusOptions = [],
}: {
baseStatusOptions?: TreeDataEntry[];
isPatch?: boolean;
onClickTaskLink?: (taskId: string) => void;
showTaskExecutionLabel?: boolean;
statusOptions?: TreeDataEntry[];
}): LGColumnDef<TaskTableInfo>[] => [
{
header: "Name",
accessorKey: "displayName",
id: TaskSortCategory.Name,
cell: ({
getValue,
row: {
original: { execution, id },
},
}): JSX.Element => (
<TaskLink
execution={execution}
onClick={onClickTaskLink}
showTaskExecutionLabel={showTaskExecutionLabel}
taskId={id}
taskName={getValue() as string}
/>
),
meta: {
search: {
"data-cy": "task-name-filter-popover",
placeholder: "Task name regex",
},
},
enableSorting: true,
size: 300,
},
{
accessorKey: "status",
id: TaskSortCategory.Status,
header: "Task Status",
cell: ({
getValue,
row: {
original: { dependsOn, execution, id },
},
}) => {
const status = getValue() as string;

return dependsOn?.length && getValue() === TaskStatus.Blocked ? (
<Tooltip
data-cy="depends-on-tooltip"
justify="middle"
popoverZIndex={zIndex.tooltip}
trigger={
<span>
<TaskStatusBadge status={status} id={id} execution={execution} />
</span>
}
>
Depends on {pluralize("task", dependsOn.length)}:{" "}
{dependsOn.map(({ name }) => `“${name}”`).join(", ")}
</Tooltip>
) : (
getValue() && (
<TaskStatusBadge status={status} id={id} execution={execution} />
)
);
},
meta: {
treeSelect: {
"data-cy": "status-filter-popover",
options: statusOptions,
},
},
enableSorting: true,
size: 80,
},
{
id: TaskSortCategory.BaseStatus,
accessorKey: "baseTask.status",
header: `${isPatch ? "Base" : "Previous"} Status`,
cell: ({
getValue,
row: {
original: { baseTask },
},
}) =>
getValue() && (
<TaskStatusBadge
status={getValue() as string}
id={baseTask?.id}
execution={baseTask?.execution}
/>
),
meta: {
treeSelect: {
"data-cy": "base-status-filter-popover",
options: baseStatusOptions,
},
},
enableSorting: true,
size: 80,
},
{
accessorKey: "buildVariantDisplayName",
id: TaskSortCategory.Variant,
header: "Variant",
cell: ({
getValue,
row: {
original: { buildVariant, projectIdentifier },
},
}) => (
<ConditionalWrapper
condition={buildVariant !== mergeTaskVariant}
wrapper={(children) => (
<StyledRouterLink
to={getVariantHistoryRoute(projectIdentifier, buildVariant)}
>
{children}
</StyledRouterLink>
)}
>
{getValue() as string}
</ConditionalWrapper>
),
meta: {
search: {
"data-cy": "variant-filter-popover",
placeholder: "Variant name regex",
},
},
enableSorting: true,
size: 250,
},
];
Loading

0 comments on commit a52782f

Please sign in to comment.