addons/isl/src/codeReview/UICodeReviewProvider.tsblame
View source
b69ab311/**
b69ab312 * Copyright (c) Meta Platforms, Inc. and affiliates.
b69ab313 *
b69ab314 * This source code is licensed under the MIT license found in the
b69ab315 * LICENSE file in the root directory of this source tree.
b69ab316 */
b69ab317
b69ab318import type {ReactNode} from 'react';
b69ab319import type {FieldConfig} from '../CommitInfoView/types';
b69ab3110import type {Operation} from '../operations/Operation';
b69ab3111import type {Dag} from '../previews';
b69ab3112import type {CodeReviewSystem, CommitInfo, DiffId, DiffSummary, Hash} from '../types';
b69ab3113import type {SyncStatus} from './syncStatus';
b69ab3114
b69ab3115/**
b69ab3116 * API to interact with Code Review for Repositories, e.g. GitHub and Phabricator.
b69ab3117 */
b69ab3118export interface UICodeReviewProvider {
b69ab3119 name: string;
b69ab3120 label: string;
b69ab3121 system: CodeReviewSystem;
b69ab3122
b69ab3123 /** name used to run commands provider-specific commands */
b69ab3124 cliName?: string;
b69ab3125
b69ab3126 DiffBadgeContent(props: {
b69ab3127 diff?: DiffSummary;
b69ab3128 children?: ReactNode;
b69ab3129 syncStatus?: SyncStatus;
b69ab3130 }): JSX.Element | null;
b69ab3131 /** If this provider is capable of landing from the UI, this component renders the land button */
b69ab3132 DiffLandButtonContent?(props: {diff?: DiffSummary; commit: CommitInfo}): JSX.Element | null;
b69ab3133 formatDiffNumber(diffId: DiffId): string;
b69ab3134 isSplitSuggestionSupported(): boolean;
b69ab3135 submitOperation(
b69ab3136 commits: Array<CommitInfo>,
b69ab3137 options?: {
b69ab3138 /** Whether to submit this diff as a draft. Note: some review providers only allow submitting new Diffs as drafts */
b69ab3139 draft?: boolean;
b69ab3140 /** If this diff is being resubmitted, this message will be added as a comment to explain what has changed */
b69ab3141 updateMessage?: string;
b69ab3142 /** Whether to update the remote message with the local commit message */
b69ab3143 updateFields?: boolean;
b69ab3144 /** Whether to automatically publish when all CI signals pass */
b69ab3145 publishWhenReady?: boolean;
b69ab3146 },
b69ab3147 ): Operation;
b69ab3148
b69ab3149 submitCommandName(): string;
b69ab3150
8d8e81551 /**
8d8e81552 * Label shown on the submit button. Defaults to "Submit" if not provided.
8d8e81553 * Grove uses "Push" when requireDiffs is off (single-dev workflow)
8d8e81554 * and "Submit" when diffs/code review are required.
8d8e81555 */
8d8e81556 submitButtonLabel?: string;
8d8e81557
b69ab3158 /** If provided, any form of submitting for code review is currently disabled for this provider for the given reason */
b69ab3159 submitDisabledReason?: () => string | undefined;
b69ab3160
b69ab3161 RepoInfo(): JSX.Element | null;
b69ab3162
b69ab3163 getRemoteTrackingBranch(
b69ab3164 allDiffSummaries?: Map<string, DiffSummary> | null,
b69ab3165 diffId?: DiffId | null,
b69ab3166 ): string | null;
b69ab3167
b69ab3168 getRemoteTrackingBranchFromDiffSummary(diff: DiffSummary | undefined | null): string | null;
b69ab3169
b69ab3170 isDiffClosed(summary: DiffSummary): boolean;
b69ab3171
b69ab3172 isDiffEligibleForCleanup(summary: DiffSummary): boolean;
b69ab3173
b69ab3174 getSyncStatuses(
b69ab3175 commits: Array<CommitInfo>,
b69ab3176 allDiffSummaries: Map<string, DiffSummary>,
b69ab3177 ): Map<Hash, SyncStatus>;
b69ab3178
b69ab3179 /**
b69ab3180 * Defines when this review provider can submit diffs as drafts,
b69ab3181 * submitting for the first time or also when resubmitting.
b69ab3182 */
b69ab3183 supportSubmittingAsDraft: 'always' | 'newDiffsOnly';
b69ab3184 /** Whether this review provider allows attaching a short update message when resubmitting a diff. */
b69ab3185 supportsUpdateMessage: boolean;
b69ab3186
b69ab3187 /** This provider supports "branch" Diff creation, where an entire stack is one unit of code review. */
b69ab3188 supportBranchingPrs: boolean;
b69ab3189
b69ab3190 /** Get the code review provider's branch corresponding to a remote bookmark */
b69ab3191 branchNameForRemoteBookmark?: (remoteBookmark: string) => string;
b69ab3192
b69ab3193 getSupportedStackActions(
b69ab3194 hash: Hash,
b69ab3195 dag: Dag,
b69ab3196 diffSummaries: Map<string, DiffSummary>,
b69ab3197 ): {
b69ab3198 resubmittableStack?: Array<CommitInfo>;
b69ab3199 submittableStack?: Array<CommitInfo>;
b69ab31100 };
b69ab31101
b69ab31102 /**
b69ab31103 * Given a set of a DiffSummaries, return which ones are ad-hoc submittable by this provider,
b69ab31104 * meaning you don't need to change the working copy to submit them.
b69ab31105 */
b69ab31106 getSubmittableDiffs(
b69ab31107 commits: Array<CommitInfo>,
b69ab31108 allDiffSummaries: Map<string, DiffSummary>,
b69ab31109 ): Array<CommitInfo>;
b69ab31110
b69ab31111 getUpdateDiffActions(summary: DiffSummary): Array<{label: ReactNode; onClick: () => void}>;
b69ab31112
b69ab31113 commitMessageFieldsSchema: Array<FieldConfig>;
b69ab31114
b69ab31115 enableMessageSyncing: boolean;
b69ab31116
b69ab31117 supportsSuggestedReviewers: boolean;
b69ab31118
b69ab31119 supportsComparingSinceLastSubmit: boolean;
b69ab31120
b69ab31121 supportsRenderingMarkup: boolean;
b69ab31122
b69ab31123 gotoDistanceWarningAgeCutoff: number;
b69ab31124}