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