fix(web): match composer pull request state icons (#9375)
This commit is contained in:
1 parent
93c3ab4ffe
commit
706231535c
4 files changed
+43
-8
No files matched your search
@@ -745,7 +745,11 @@ export function BranchToolbarBranchSelector({
|
||||
/>
|
||||
}
|
||||
>
|
||||
<ChangeRequestStatusIcon className="size-3" />
|
||||
<ChangeRequestStatusIcon
|
||||
state={branchPr.state}
|
||||
isDraft={branchPr.isDraft}
|
||||
className="size-3"
|
||||
/>
|
||||
<span
|
||||
data-composer-label
|
||||
className="min-w-0 max-w-12 overflow-hidden group-data-[compact]/composer-context:max-w-0"
|
||||
|
||||
@@ -720,7 +720,7 @@ export const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThr
|
||||
onContextMenu={handleRowContextMenu}
|
||||
>
|
||||
<div className="flex min-w-0 flex-1 items-center gap-1.5 text-left">
|
||||
{prStatus && (
|
||||
{prStatus && pr && (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
@@ -733,7 +733,11 @@ export const SidebarThreadRow = memo(function SidebarThreadRow(props: SidebarThr
|
||||
onPointerDown={(event) => event.stopPropagation()}
|
||||
onClick={handlePrClick}
|
||||
>
|
||||
<ChangeRequestStatusIcon className="size-3" />
|
||||
<ChangeRequestStatusIcon
|
||||
state={pr.state}
|
||||
isDraft={pr.isDraft}
|
||||
className="size-3"
|
||||
/>
|
||||
</a>
|
||||
}
|
||||
/>
|
||||
|
||||
@@ -2,8 +2,15 @@ import { ProjectId, type PullRequestSummary, type VcsStatusResult } from "@t3too
|
||||
import { describe, expect, it } from "@effect/vitest";
|
||||
import * as Effect from "effect/Effect";
|
||||
import { AtomRegistry } from "effect/unstable/reactivity";
|
||||
import {
|
||||
GitMergeIcon,
|
||||
GitPullRequestClosedIcon,
|
||||
GitPullRequestDraftIcon,
|
||||
GitPullRequestIcon,
|
||||
} from "lucide-react";
|
||||
|
||||
import {
|
||||
ChangeRequestStatusIcon,
|
||||
nextThreadChangeRequestSnapshot,
|
||||
prStatusIndicator,
|
||||
resolveDisplayedThreadPr,
|
||||
@@ -16,6 +23,17 @@ import {
|
||||
} from "./ThreadStatusIndicators";
|
||||
import { newestPullRequestSummary } from "../state/pullRequests";
|
||||
|
||||
describe("ChangeRequestStatusIcon", () => {
|
||||
it.each([
|
||||
["open", "open", false, GitPullRequestIcon],
|
||||
["draft", "open", true, GitPullRequestDraftIcon],
|
||||
["closed", "closed", false, GitPullRequestClosedIcon],
|
||||
["merged", "merged", false, GitMergeIcon],
|
||||
] as const)("uses the %s pull request glyph", (_label, state, isDraft, expectedIcon) => {
|
||||
expect(ChangeRequestStatusIcon({ state, isDraft }).type).toBe(expectedIcon);
|
||||
});
|
||||
});
|
||||
|
||||
function status(overrides: Partial<VcsStatusResult> = {}): VcsStatusResult {
|
||||
return {
|
||||
isRepo: true,
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
type VcsStatusResult,
|
||||
} from "@t3tools/contracts";
|
||||
import { Atom } from "effect/unstable/reactivity";
|
||||
import { FolderGit2Icon, GitPullRequestIcon, TerminalIcon } from "lucide-react";
|
||||
import { FolderGit2Icon, TerminalIcon } from "lucide-react";
|
||||
import { useMemo } from "react";
|
||||
import { appAtomRegistry } from "../rpc/atomRegistry";
|
||||
import { useEnvironment, usePrimaryEnvironmentId } from "../state/environments";
|
||||
@@ -24,6 +24,7 @@ import { vcsEnvironment } from "../state/vcs";
|
||||
import { useUiStateStore } from "../uiStateStore";
|
||||
import { resolveChangeRequestPresentation } from "../sourceControlPresentation";
|
||||
import { resolveThreadStatusPill, type ThreadStatusPill } from "./Sidebar.logic";
|
||||
import { resolvePullRequestState } from "./pullRequest/pullRequestPresentation";
|
||||
import type { SidebarThreadSummary } from "../types";
|
||||
import { formatWorktreePathForDisplay } from "../worktreeCleanup";
|
||||
import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
|
||||
@@ -155,8 +156,16 @@ export function prStatusIndicator(
|
||||
return null;
|
||||
}
|
||||
|
||||
export function ChangeRequestStatusIcon({ className }: { className?: string }) {
|
||||
return <GitPullRequestIcon className={className} />;
|
||||
export function ChangeRequestStatusIcon({
|
||||
state,
|
||||
isDraft = false,
|
||||
className,
|
||||
}: Pick<NonNullable<ThreadPr>, "state"> & {
|
||||
readonly isDraft?: boolean | undefined;
|
||||
readonly className?: string | undefined;
|
||||
}) {
|
||||
const presentation = resolvePullRequestState({ state, isDraft });
|
||||
return <presentation.Icon className={className} />;
|
||||
}
|
||||
|
||||
export function PrStatusTooltipContent({ status }: { status: PrStatusIndicator }) {
|
||||
@@ -585,7 +594,7 @@ export function ThreadRowLeadingStatus({ thread }: { thread: SidebarThreadSummar
|
||||
|
||||
return (
|
||||
<span className="inline-flex shrink-0 items-center gap-1.5">
|
||||
{prStatus ? (
|
||||
{prStatus && pr ? (
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
@@ -595,7 +604,7 @@ export function ThreadRowLeadingStatus({ thread }: { thread: SidebarThreadSummar
|
||||
/>
|
||||
}
|
||||
>
|
||||
<ChangeRequestStatusIcon className="size-3" />
|
||||
<ChangeRequestStatusIcon state={pr.state} isDraft={pr.isDraft} className="size-3" />
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup side="top">
|
||||
<PrStatusTooltipContent status={prStatus} />
|
||||
|
||||
Reference in new issue
Block a user