mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-17 16:09:36 +00: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 <30753807+imacross@users.noreply.github.com>
46 lines
1.8 KiB
TypeScript
46 lines
1.8 KiB
TypeScript
/**
|
|
* Implementations of registered actions that live in other parts of the port (the
|
|
* details panel, review diff, review mode). A part provides its handler on activation;
|
|
* until then the action is disabled (`when` reads the `github.<name>` context key).
|
|
*
|
|
* const dispose = provideGithubHandler("submitReview", (number) => showSubmitReview(number));
|
|
*/
|
|
import { setContext } from "@/platform/context";
|
|
|
|
export interface GithubHandlers {
|
|
/** Submit Review… for the pull request (its pending review, if any). */
|
|
submitReview: (number: number) => void;
|
|
/** Toggle viewed/not viewed state of the selected files / the file in the active diff. */
|
|
toggleViewed: () => void;
|
|
/** Review mode: Show Pull Request in the Tool Window (the current branch's PR). */
|
|
showCurrentBranchPullRequest: () => void;
|
|
/** Review mode: Update to Enable Review Mode… */
|
|
updateReviewBranch: () => void;
|
|
/** Review mode: the Review Mode toggle. */
|
|
toggleReviewMode: () => void;
|
|
/** Review mode: whether it is on (the toggle's state). */
|
|
isReviewModeOn: () => boolean;
|
|
}
|
|
|
|
export type GithubHandlerName = keyof GithubHandlers;
|
|
|
|
const handlers: Partial<GithubHandlers> = {};
|
|
|
|
/** The context key enabling the action(s) of handler `name`. */
|
|
export const handlerContextKey = (name: GithubHandlerName) => `github.${name}`;
|
|
|
|
/** Provides handler `name`, enabling its actions; returns the disposer. */
|
|
export function provideGithubHandler<K extends GithubHandlerName>(name: K, handler: GithubHandlers[K]): () => void {
|
|
handlers[name] = handler;
|
|
setContext(handlerContextKey(name), true);
|
|
return () => {
|
|
if (handlers[name] !== handler) return;
|
|
delete handlers[name];
|
|
setContext(handlerContextKey(name), false);
|
|
};
|
|
}
|
|
|
|
export function githubHandler<K extends GithubHandlerName>(name: K): GithubHandlers[K] | undefined {
|
|
return handlers[name];
|
|
}
|