дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 09:11:10 +02:00
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]>
61 рядки
2.8 KiB
TypeScript
61 рядки
2.8 KiB
TypeScript
/**
|
|
* The pull request timeline editor tab (IntelliJ's `GHPRTimelineVirtualFile`): its input,
|
|
* title (`{title} #N` once the details are known, else `#N`) and state icon.
|
|
*/
|
|
import { editorService, maybeEditorService, type EditorInput } from "@/workbench/contributions";
|
|
import type { GHRepositoryCoordinates } from "../api/types";
|
|
import { pullRequestStateIcon } from "../data/model";
|
|
import { cachedDetails } from "../data/pullRequest";
|
|
import { requireConnection, sameRepository, useGhRepository } from "../data/repository";
|
|
|
|
export const TIMELINE_KIND = "github.timeline";
|
|
|
|
/** `input.data` of a timeline tab. */
|
|
export interface TimelineInputData extends GHRepositoryCoordinates {
|
|
number: number;
|
|
}
|
|
|
|
export function timelineInput(repo: GHRepositoryCoordinates, number: number): EditorInput {
|
|
const data: TimelineInputData = { owner: repo.owner, name: repo.name, number };
|
|
return { kind: TIMELINE_KIND, key: `${TIMELINE_KIND}:${repo.owner}/${repo.name}#${number}`, data };
|
|
}
|
|
|
|
/** The timeline tab's data, or null for another kind of input. */
|
|
export function timelineData(input: EditorInput | null | undefined): TimelineInputData | null {
|
|
if (input?.kind !== TIMELINE_KIND) return null;
|
|
const d = input.data as Partial<TimelineInputData> | undefined;
|
|
return d && typeof d.number === "number" && typeof d.owner === "string" && typeof d.name === "string"
|
|
? (d as TimelineInputData)
|
|
: null;
|
|
}
|
|
|
|
/** The details when the tab is of the connected repository and they are loaded. */
|
|
function detailsOf(input: EditorInput) {
|
|
const d = timelineData(input);
|
|
if (!d || !sameRepository(useGhRepository.getState().connection?.coordinates, d)) return undefined;
|
|
return cachedDetails(d.number);
|
|
}
|
|
|
|
export function timelineTitle(input: EditorInput): string {
|
|
const d = timelineData(input);
|
|
const details = detailsOf(input);
|
|
return details ? `${details.title} #${d!.number}` : `#${d?.number ?? "?"}`;
|
|
}
|
|
|
|
export function timelineIcon(input: EditorInput): string {
|
|
const details = detailsOf(input);
|
|
return details ? pullRequestStateIcon(details.state, details.isDraft) : "github-timeline";
|
|
}
|
|
|
|
/** "View Timeline": opens the timeline of `number` of the connected repository (`focus`: like a file open). */
|
|
export async function openTimeline(number: number, opts: { focus?: boolean } = {}): Promise<void> {
|
|
const repo = requireConnection().coordinates;
|
|
await editorService().openInput(timelineInput(repo, number), { focus: opts.focus ?? true });
|
|
}
|
|
|
|
/** The pull request whose timeline is the active editor tab, when it is of the connected repository. */
|
|
export function activeTimelinePullRequest(): number | null {
|
|
const d = timelineData(maybeEditorService()?.activeInput?.() ?? null);
|
|
return d && sameRepository(useGhRepository.getState().connection?.coordinates, d) ? d.number : null;
|
|
}
|