Skip to content
TypeScript

fix(web): pull request embed chip shows the state icon (#12951)

oliver2c2fa8cd7ded
diff --git a/apps/web/src/components/contextChipParts.tsx b/apps/web/src/components/contextChipParts.tsx
index 9f8fa9998b4..f0a47b22e3c 100644
--- a/apps/web/src/components/contextChipParts.tsx
+++ b/apps/web/src/components/contextChipParts.tsx
@@ -9,7 +9,7 @@ import {
} from "react";
import { cn } from "~/lib/utils";
-import { PullRequestGlyph } from "~/components/pullRequest/pullRequestIcons";
+import { PULL_REQUEST_STATE_PRESENTATION } from "~/components/pullRequest/pullRequestIcons";
import { PierreEntryIcon } from "./chat/PierreEntryIcon";
import {
COMPOSER_INLINE_CHIP_ICON_CLASS_NAME,
@@ -123,6 +123,9 @@ export function PullRequestChip(props: {
onOpen: (event: MouseEvent<HTMLElement>, url: string) => void;
}) {
const previewTarget = usePullRequestPreviewTarget(props.environmentId, props.metadata.url);
+ const displayState =
+ props.metadata.state === "open" && props.metadata.isDraft ? "draft" : props.metadata.state;
+ const StateIcon = PULL_REQUEST_STATE_PRESENTATION[displayState].Icon;
const button = (
<Button
variant="chip"
@@ -136,9 +139,7 @@ export function PullRequestChip(props: {
data-markdown-copy={props.copyMarkdown}
onClick={(event) => props.onOpen(event, props.metadata.url)}
>
- <PullRequestGlyph.pullRequest
- className={cn(COMPOSER_INLINE_CHIP_ICON_CLASS_NAME, "size-3.5")}
- />
+ <StateIcon className={cn(COMPOSER_INLINE_CHIP_ICON_CLASS_NAME, "size-3.5")} />
<span className={props.labelClassName}>{props.label}</span>
</Button>
);