From 410c24349bf62a7a81dc96f1d8ed4bef3f5b8184 Mon Sep 17 00:00:00 2001 From: minnakt <47064971+minnakt@users.noreply.github.com> Date: Fri, 30 Aug 2024 09:52:32 -0400 Subject: [PATCH] DEVPROD-7054: Omit changes tab for GitHub merge queue patches (#347) --- .../src/components/CodeChanges/index.tsx | 15 ++++-------- apps/spruce/src/pages/Version.tsx | 6 +---- apps/spruce/src/pages/version/VersionTabs.tsx | 24 +++++++++---------- 3 files changed, 18 insertions(+), 27 deletions(-) diff --git a/apps/spruce/src/components/CodeChanges/index.tsx b/apps/spruce/src/components/CodeChanges/index.tsx index 306063f9e..01b16b6c0 100644 --- a/apps/spruce/src/components/CodeChanges/index.tsx +++ b/apps/spruce/src/components/CodeChanges/index.tsx @@ -1,13 +1,7 @@ import { useQuery } from "@apollo/client"; import styled from "@emotion/styled"; import Button from "@leafygreen-ui/button"; -import { - Body, - BodyProps, - Description, - Subtitle, - SubtitleProps, -} from "@leafygreen-ui/typography"; +import { Body, BodyProps, Description } from "@leafygreen-ui/typography"; import { Skeleton } from "antd"; import { CodeChangesBadge } from "components/CodeChangesBadge"; import { CodeChangesTable } from "components/CodeChangesTable"; @@ -45,7 +39,8 @@ export const CodeChanges: React.FC = ({ patchId }) => { if (!moduleCodeChanges.length) { return ( - Code changes do not exist, or are too large to display. + No code changes were applied, or the code changes are too large to + display. ); } @@ -126,9 +121,9 @@ const StyledButton = styled(Button)` margin-right: ${size.xs}; `; -const Title = styled(Subtitle)` - font-weight: normal; +const Title = styled(Body)` margin-right: ${size.s}; + margin-left: ${size.s}; margin-bottom: ${size.s}; `; diff --git a/apps/spruce/src/pages/Version.tsx b/apps/spruce/src/pages/Version.tsx index c27ea3948..d0f6e22e9 100644 --- a/apps/spruce/src/pages/Version.tsx +++ b/apps/spruce/src/pages/Version.tsx @@ -160,7 +160,6 @@ export const VersionPage: React.FC = () => { } = version || {}; const { canEnqueueToCommitQueue, - childPatches, commitQueuePosition = null, patchNumber, } = patch || {}; @@ -229,11 +228,8 @@ export const VersionPage: React.FC = () => { diff --git a/apps/spruce/src/pages/version/VersionTabs.tsx b/apps/spruce/src/pages/version/VersionTabs.tsx index 146d5eed3..b397bb248 100644 --- a/apps/spruce/src/pages/version/VersionTabs.tsx +++ b/apps/spruce/src/pages/version/VersionTabs.tsx @@ -5,6 +5,7 @@ import { useVersionAnalytics } from "analytics"; import { CodeChanges } from "components/CodeChanges"; import { StyledTabs } from "components/styles/StyledTabs"; import { TabLabelWithBadge } from "components/TabLabelWithBadge"; +import { Requester } from "constants/requesters"; import { getVersionRoute, slugs } from "constants/routes"; import { VersionQuery } from "gql/generated/types"; import { usePrevious } from "hooks"; @@ -20,10 +21,9 @@ const { parseQueryString } = queryString; type ChildPatches = NonNullable< VersionQuery["version"]["patch"] >["childPatches"]; -interface Props { - taskCount: number; - isPatch: boolean; - childPatches: ChildPatches; + +interface VersionTabProps { + version: VersionQuery["version"]; } const getDownstreamTabName = ( @@ -118,11 +118,8 @@ const tabMap = ({ ), }); -export const VersionTabs: React.FC = ({ - childPatches, - isPatch, - taskCount, -}) => { + +export const VersionTabs: React.FC = ({ version }) => { const { [slugs.versionId]: versionId, [slugs.tab]: tab } = useParams<{ [slugs.versionId]: string; [slugs.tab]: PatchTab; @@ -132,14 +129,17 @@ export const VersionTabs: React.FC = ({ const { sendEvent } = useVersionAnalytics(versionId); const navigate = useNavigate(); + const { isPatch, patch, requester, taskCount } = version || {}; + const { childPatches } = patch || {}; + const tabIsActive = useMemo( () => ({ [PatchTab.Tasks]: true, [PatchTab.TaskDuration]: true, - [PatchTab.Changes]: isPatch, + [PatchTab.Changes]: isPatch && requester !== Requester.GitHubMergeQueue, [PatchTab.Downstream]: childPatches, }), - [isPatch, childPatches], + [isPatch, requester, childPatches], ); const allTabs = useMemo(() => { @@ -153,7 +153,7 @@ export const VersionTabs: React.FC = ({ ? childPatches.filter((c) => c.status === PatchStatus.Success).length : 0; return tabMap({ - taskCount, + taskCount: taskCount ?? 0, childPatches, numFailedChildPatches, numStartedChildPatches,