4.1 KB125 lines
Blame
1/**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8import type {ReactNode} from 'react';
9import type {FieldConfig} from '../CommitInfoView/types';
10import type {Operation} from '../operations/Operation';
11import type {Dag} from '../previews';
12import type {CodeReviewSystem, CommitInfo, DiffId, DiffSummary, Hash} from '../types';
13import type {SyncStatus} from './syncStatus';
14
15/**
16 * API to interact with Code Review for Repositories, e.g. GitHub and Phabricator.
17 */
18export interface UICodeReviewProvider {
19 name: string;
20 label: string;
21 system: CodeReviewSystem;
22
23 /** name used to run commands provider-specific commands */
24 cliName?: string;
25
26 DiffBadgeContent(props: {
27 diff?: DiffSummary;
28 children?: ReactNode;
29 syncStatus?: SyncStatus;
30 }): JSX.Element | null;
31 /** If this provider is capable of landing from the UI, this component renders the land button */
32 DiffLandButtonContent?(props: {diff?: DiffSummary; commit: CommitInfo}): JSX.Element | null;
33 formatDiffNumber(diffId: DiffId): string;
34 isSplitSuggestionSupported(): boolean;
35 submitOperation(
36 commits: Array<CommitInfo>,
37 options?: {
38 /** Whether to submit this diff as a draft. Note: some review providers only allow submitting new Diffs as drafts */
39 draft?: boolean;
40 /** If this diff is being resubmitted, this message will be added as a comment to explain what has changed */
41 updateMessage?: string;
42 /** Whether to update the remote message with the local commit message */
43 updateFields?: boolean;
44 /** Whether to automatically publish when all CI signals pass */
45 publishWhenReady?: boolean;
46 },
47 ): Operation;
48
49 submitCommandName(): string;
50
51 /**
52 * Label shown on the submit button. Defaults to "Submit" if not provided.
53 * Grove uses "Push" when requireDiffs is off (single-dev workflow)
54 * and "Submit" when diffs/code review are required.
55 */
56 submitButtonLabel?: string;
57
58 /** If provided, any form of submitting for code review is currently disabled for this provider for the given reason */
59 submitDisabledReason?: () => string | undefined;
60
61 RepoInfo(): JSX.Element | null;
62
63 getRemoteTrackingBranch(
64 allDiffSummaries?: Map<string, DiffSummary> | null,
65 diffId?: DiffId | null,
66 ): string | null;
67
68 getRemoteTrackingBranchFromDiffSummary(diff: DiffSummary | undefined | null): string | null;
69
70 isDiffClosed(summary: DiffSummary): boolean;
71
72 isDiffEligibleForCleanup(summary: DiffSummary): boolean;
73
74 getSyncStatuses(
75 commits: Array<CommitInfo>,
76 allDiffSummaries: Map<string, DiffSummary>,
77 ): Map<Hash, SyncStatus>;
78
79 /**
80 * Defines when this review provider can submit diffs as drafts,
81 * submitting for the first time or also when resubmitting.
82 */
83 supportSubmittingAsDraft: 'always' | 'newDiffsOnly';
84 /** Whether this review provider allows attaching a short update message when resubmitting a diff. */
85 supportsUpdateMessage: boolean;
86
87 /** This provider supports "branch" Diff creation, where an entire stack is one unit of code review. */
88 supportBranchingPrs: boolean;
89
90 /** Get the code review provider's branch corresponding to a remote bookmark */
91 branchNameForRemoteBookmark?: (remoteBookmark: string) => string;
92
93 getSupportedStackActions(
94 hash: Hash,
95 dag: Dag,
96 diffSummaries: Map<string, DiffSummary>,
97 ): {
98 resubmittableStack?: Array<CommitInfo>;
99 submittableStack?: Array<CommitInfo>;
100 };
101
102 /**
103 * Given a set of a DiffSummaries, return which ones are ad-hoc submittable by this provider,
104 * meaning you don't need to change the working copy to submit them.
105 */
106 getSubmittableDiffs(
107 commits: Array<CommitInfo>,
108 allDiffSummaries: Map<string, DiffSummary>,
109 ): Array<CommitInfo>;
110
111 getUpdateDiffActions(summary: DiffSummary): Array<{label: ReactNode; onClick: () => void}>;
112
113 commitMessageFieldsSchema: Array<FieldConfig>;
114
115 enableMessageSyncing: boolean;
116
117 supportsSuggestedReviewers: boolean;
118
119 supportsComparingSinceLastSubmit: boolean;
120
121 supportsRenderingMarkup: boolean;
122
123 gotoDistanceWarningAgeCutoff: number;
124}
125