Файли
openidea/src/features/github/diff/ReviewToolbar.tsx
T
imacross 059fd8a69b feat(github): pull request tool window, timeline and review flow (#477)
Replaces the Pull Requests tool window with a full review workflow on top of gh's authentication.

- List with search, quick filters and paging; a tab per pull request and a New Pull Request tab.
- Details: commit picker, changes tree with viewed state, CI and reviewer status, merge, close and reopen.
- Timeline editor: comments, review threads, reactions and suggested changes.
- Review in the diff viewer and, for the checked-out branch, in the editor (review mode).
- New generic vcs extension points: registerDiffViewerProvider, lineInlays, reviewGutter, branch widget extensions; new vcs_merge_base and gh_api commands.
- CSP: img-src allows https://avatars.githubusercontent.com for avatars.

Fixed while testing against a real repository: remotes behind an SSH host alias, mergeability stuck on UNKNOWN, Apply Locally staying disabled after a checkout, relative links navigating the app's page, and review inlays wider than the pane.

Co-authored-by: imacross <[email protected]>
2026-10-31 07:50:43 +08:00

52 рядки
1.9 KiB
TypeScript

/**
* The review actions of a pull request's diff toolbar (`GHPRDiffService` `CONTEXT_ACTIONS`):
* Refresh Review Data, the Submit Review button ("Submit Review…" / "Submit Review ({n})…",
* the details panel's popup through the `submitReview` handler), Previous / Next Comment.
*/
import { useContextKeys } from "@/platform/context";
import { tx } from "@/platform/i18n";
import { Button, IconButton } from "@/ui";
import { usePullRequestData } from "../data/pullRequest";
import { githubHandler, handlerContextKey } from "../toolwindow/handlers";
import type { ReviewDiff } from "./reviewDiff";
import styles from "./ReviewDiff.module.css";
/** `{0, choice, 0#Submit Review…|1#Submit Review ({0})…}`. */
const submitReviewText = (pending: number) => (pending > 0 ? tx`Submit Review (${pending})…` : tx("Submit Review…"));
export function ReviewToolbar({ diff }: { diff: ReviewDiff }) {
const pending = usePullRequestData(diff.number, "pendingReview");
const threads = usePullRequestData(diff.number, "threads");
const canSubmit = useContextKeys((k) => !!k[handlerContextKey("submitReview")]);
const loading = pending.loading || threads.loading;
return (
<>
<span className={styles.sep} />
<IconButton
icon="refresh"
title="Refresh Review Data"
size="small"
disabled={loading}
onClick={() => diff.refresh()}
/>
<Button size="small" disabled={!canSubmit} onClick={() => githubHandler("submitReview")?.(diff.number)}>
{submitReviewText(pending.value?.commentsCount ?? 0)}
</Button>
<IconButton
icon="arrow-up"
title="Previous Comment"
size="small"
disabled={!diff.canNavigate}
onClick={() => void diff.gotoComment(-1)}
/>
<IconButton
icon="arrow-down"
title="Next Comment"
size="small"
disabled={!diff.canNavigate}
onClick={() => void diff.gotoComment(1)}
/>
</>
);
}