Skip to content

Commit

Permalink
DEVPROD-7054: Omit changes tab for GitHub merge queue patches (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
minnakt authored Aug 30, 2024
1 parent 6fb31a4 commit 410c243
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 27 deletions.
15 changes: 5 additions & 10 deletions apps/spruce/src/components/CodeChanges/index.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -45,7 +39,8 @@ export const CodeChanges: React.FC<CodeChangesProps> = ({ patchId }) => {
if (!moduleCodeChanges.length) {
return (
<Title className="cy-no-code-changes">
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.
</Title>
);
}
Expand Down Expand Up @@ -126,9 +121,9 @@ const StyledButton = styled(Button)`
margin-right: ${size.xs};
`;

const Title = styled(Subtitle)<SubtitleProps>`
font-weight: normal;
const Title = styled(Body)<BodyProps>`
margin-right: ${size.s};
margin-left: ${size.s};
margin-bottom: ${size.s};
`;

Expand Down
6 changes: 1 addition & 5 deletions apps/spruce/src/pages/Version.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ export const VersionPage: React.FC = () => {
} = version || {};
const {
canEnqueueToCommitQueue,
childPatches,
commitQueuePosition = null,
patchNumber,
} = patch || {};
Expand Down Expand Up @@ -229,11 +228,8 @@ export const VersionPage: React.FC = () => {
<PageLayout>
<PageContent>
<VersionTabs
childPatches={childPatches}
// @ts-expect-error: FIXME. This comment was added by an automated script.
isPatch={version?.isPatch}
// @ts-expect-error: FIXME. This comment was added by an automated script.
taskCount={version?.taskCount}
version={version}
/>
</PageContent>
</PageLayout>
Expand Down
24 changes: 12 additions & 12 deletions apps/spruce/src/pages/version/VersionTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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 = (
Expand Down Expand Up @@ -118,11 +118,8 @@ const tabMap = ({
</Tab>
),
});
export const VersionTabs: React.FC<Props> = ({
childPatches,
isPatch,
taskCount,
}) => {

export const VersionTabs: React.FC<VersionTabProps> = ({ version }) => {
const { [slugs.versionId]: versionId, [slugs.tab]: tab } = useParams<{
[slugs.versionId]: string;
[slugs.tab]: PatchTab;
Expand All @@ -132,14 +129,17 @@ export const VersionTabs: React.FC<Props> = ({
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(() => {
Expand All @@ -153,7 +153,7 @@ export const VersionTabs: React.FC<Props> = ({
? childPatches.filter((c) => c.status === PatchStatus.Success).length
: 0;
return tabMap({
taskCount,
taskCount: taskCount ?? 0,
childPatches,
numFailedChildPatches,
numStartedChildPatches,
Expand Down

0 comments on commit 410c243

Please sign in to comment.