Skip to content

Commit

Permalink
Revert button to already merged pull requests (#6097)
Browse files Browse the repository at this point in the history
Fixes #2103
  • Loading branch information
alexr00 authored Jul 19, 2024
1 parent 9cd8269 commit a963d76
Show file tree
Hide file tree
Showing 33 changed files with 1,002 additions and 737 deletions.
1 change: 1 addition & 0 deletions common/views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export interface CreatePullRequestNew {
// #region new create view

export interface CreateParamsNew {
canModifyBranches: boolean;
defaultBaseRemote?: RemoteInfo;
defaultBaseBranch?: string;
defaultCompareRemote?: RemoteInfo;
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@
"id": "github:createPullRequestWebview",
"type": "webview",
"name": "%view.github.create.pull.request.name%",
"when": "github:createPullRequest",
"when": "github:createPullRequest || github:revertPullRequest",
"visibility": "visible",
"initialSize": 2
},
Expand All @@ -706,7 +706,7 @@
{
"id": "prStatus:github",
"name": "%view.pr.status.github.name%",
"when": "github:inReviewMode && !github:createPullRequest",
"when": "github:inReviewMode && !github:createPullRequest && !github:revertPullRequest",
"icon": "$(git-pull-request)",
"visibility": "visible",
"initialSize": 3
Expand All @@ -715,7 +715,7 @@
"id": "github:activePullRequest",
"type": "webview",
"name": "%view.github.active.pull.request.name%",
"when": "github:inReviewMode && github:focusedReview && !github:createPullRequest && github:activePRCount <= 1",
"when": "github:inReviewMode && github:focusedReview && !github:createPullRequest && !github:revertPullRequest && github:activePRCount <= 1",
"initialSize": 2
},
{
Expand Down
8 changes: 8 additions & 0 deletions src/@types/vscode.proposed.commentThreadApplicability.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,13 @@ declare module 'vscode' {
* Worth noting that we already have this problem for the `comments` property.
*/
state?: CommentThreadState | { resolved?: CommentThreadState; applicability?: CommentThreadApplicability };
readonly uri: Uri;
range: Range | undefined;
comments: readonly Comment[];
collapsibleState: CommentThreadCollapsibleState;
canReply: boolean;
contextValue?: string;
label?: string;
dispose(): void;
}
}
65 changes: 12 additions & 53 deletions src/@types/vscode.proposed.fileComments.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,68 +6,27 @@
declare module 'vscode' {

export interface CommentThread2 {
/**
* The uri of the document the thread has been created on.
*/
readonly uri: Uri;

/**
* The range the comment thread is located within the document. The thread icon will be shown
* at the last line of the range.
* at the last line of the range. When set to undefined, the comment will be associated with the
* file, and not a specific range.
*/
range: Range | undefined;
}

/**
* The ranges a CommentingRangeProvider enables commenting on.
*/
export interface CommentingRanges {
/**
* The ordered comments of the thread.
*/
comments: readonly Comment[];

/**
* Whether the thread should be collapsed or expanded when opening the document.
* Defaults to Collapsed.
*/
collapsibleState: CommentThreadCollapsibleState;

/**
* Whether the thread supports reply.
* Defaults to true.
*/
canReply: boolean;

/**
* Context value of the comment thread. This can be used to contribute thread specific actions.
* For example, a comment thread is given a context value as `editable`. When contributing actions to `comments/commentThread/title`
* using `menus` extension point, you can specify context value for key `commentThread` in `when` expression like `commentThread == editable`.
* ```json
* "contributes": {
* "menus": {
* "comments/commentThread/title": [
* {
* "command": "extension.deleteCommentThread",
* "when": "commentThread == editable"
* }
* ]
* }
* }
* ```
* This will show action `extension.deleteCommentThread` only for comment threads with `contextValue` is `editable`.
*/
contextValue?: string;

/**
* The optional human-readable label describing the {@link CommentThread Comment Thread}
* Enables comments to be added to a file without a specific range.
*/
label?: string;

// from the commentThreadRelevance proposal
state?: CommentThreadState | { resolved?: CommentThreadState; applicability?: CommentThreadApplicability };
enableFileComments: boolean;

/**
* Dispose this comment thread.
*
* Once disposed, this comment thread will be removed from visible editors and Comment Panel when appropriate.
* The ranges which allow new comment threads creation.
*/
dispose(): void;
ranges?: Range[];
}

export interface CommentController {
Expand All @@ -78,6 +37,6 @@ declare module 'vscode' {
/**
* Provide a list of ranges which allow new comment threads creation or null for a given document
*/
provideCommentingRanges(document: TextDocument, token: CancellationToken): ProviderResult<Range[] | { enableFileComments: boolean; ranges?: Range[] }>;
provideCommentingRanges(document: TextDocument, token: CancellationToken): ProviderResult<Range[] | CommentingRanges>;
}
}
9 changes: 4 additions & 5 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ function ensurePR(folderRepoManager: FolderRepositoryManager, pr?: PRNode | Pull
}

export async function openDescription(
context: vscode.ExtensionContext,
telemetry: ITelemetry,
pullRequestModel: PullRequestModel,
descriptionNode: DescriptionNode | undefined,
Expand All @@ -74,7 +73,7 @@ export async function openDescription(
descriptionNode?.reveal(descriptionNode, { select: true, focus: true });
}
// Create and show a new webview
await PullRequestOverviewPanel.createOrShow(context.extensionUri, folderManager, pullRequest, undefined, preserveFocus);
await PullRequestOverviewPanel.createOrShow(telemetry, folderManager.context.extensionUri, folderManager, pullRequest, undefined, preserveFocus);

if (notificationProvider?.hasNotification(pullRequest)) {
notificationProvider.markPrNotificationsAsRead(pullRequest);
Expand Down Expand Up @@ -124,7 +123,7 @@ export function registerCommands(
reposManager: RepositoriesManager,
reviewsManager: ReviewsManager,
telemetry: ITelemetry,
tree: PullRequestsTreeDataProvider
tree: PullRequestsTreeDataProvider,
) {
context.subscriptions.push(
vscode.commands.registerCommand(
Expand Down Expand Up @@ -812,7 +811,7 @@ export function registerCommands(
descriptionNode = reviewManager.changesInPrDataProvider.getDescriptionNode(folderManager);
}

await openDescription(context, telemetry, pullRequestModel, descriptionNode, folderManager, !(argument instanceof DescriptionNode), !(argument instanceof RepositoryChangesNode), tree.notificationProvider);
await openDescription(telemetry, pullRequestModel, descriptionNode, folderManager, !(argument instanceof DescriptionNode), !(argument instanceof RepositoryChangesNode), tree.notificationProvider);
},
),
);
Expand Down Expand Up @@ -843,7 +842,7 @@ export function registerCommands(
const pullRequest = ensurePR(folderManager, pr);
descriptionNode.reveal(descriptionNode, { select: true, focus: true });
// Create and show a new webview
PullRequestOverviewPanel.createOrShow(context.extensionUri, folderManager, pullRequest, true);
PullRequestOverviewPanel.createOrShow(telemetry, context.extensionUri, folderManager, pullRequest, true);

/* __GDPR__
"pr.openDescriptionToTheSide" : {}
Expand Down
12 changes: 7 additions & 5 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ async function init(
liveshareApiPromise: Promise<LiveShare | undefined>,
showPRController: ShowPullRequest,
reposManager: RepositoriesManager,
createPrHelper: CreatePullRequestHelper
): Promise<void> {
context.subscriptions.push(Logger);
Logger.appendLine('Git repository found, initializing review manager and pr tree view.');
Expand Down Expand Up @@ -146,8 +147,7 @@ async function init(

const activePrViewCoordinator = new WebviewViewCoordinator(context);
context.subscriptions.push(activePrViewCoordinator);
const createPrHelper = new CreatePullRequestHelper();
context.subscriptions.push(createPrHelper);

let reviewManagerIndex = 0;
const reviewManagers = reposManager.folderManagers.map(
folderManager => new ReviewManager(reviewManagerIndex++, context, folderManager.repository, folderManager, telemetry, changesTree, tree, showPRController, activePrViewCoordinator, createPrHelper, git),
Expand All @@ -170,7 +170,7 @@ async function init(
Logger.appendLine(`Repo ${repo.rootUri} has already been setup.`);
return;
}
const newFolderManager = new FolderRepositoryManager(reposManager.folderManagers.length, context, repo, telemetry, git, credentialStore);
const newFolderManager = new FolderRepositoryManager(reposManager.folderManagers.length, context, repo, telemetry, git, credentialStore, createPrHelper);
reposManager.insertFolderManager(newFolderManager);
const newReviewManager = new ReviewManager(
reviewManagerIndex++,
Expand Down Expand Up @@ -364,10 +364,12 @@ async function deferredActivate(context: vscode.ExtensionContext, apiImpl: GitAp
Logger.appendLine('Looking for git repository');
const repositories = apiImpl.repositories;
Logger.appendLine(`Found ${repositories.length} repositories during activation`);
const createPrHelper = new CreatePullRequestHelper();
context.subscriptions.push(createPrHelper);

let folderManagerIndex = 0;
const folderManagers = repositories.map(
repository => new FolderRepositoryManager(folderManagerIndex++, context, repository, telemetry, apiImpl, credentialStore),
repository => new FolderRepositoryManager(folderManagerIndex++, context, repository, telemetry, apiImpl, credentialStore, createPrHelper),
);
context.subscriptions.push(...folderManagers);
for (const folderManager of folderManagers) {
Expand All @@ -379,7 +381,7 @@ async function deferredActivate(context: vscode.ExtensionContext, apiImpl: GitAp
readOnlyMessage.isTrusted = { enabledCommands: ['pr.checkoutFromReadonlyFile'] };
context.subscriptions.push(vscode.workspace.registerFileSystemProvider(Schemes.Pr, inMemPRFileSystemProvider, { isReadonly: readOnlyMessage }));

await init(context, apiImpl, credentialStore, repositories, prTree, liveshareApiPromise, showPRController, reposManager);
await init(context, apiImpl, credentialStore, repositories, prTree, liveshareApiPromise, showPRController, reposManager, createPrHelper);
}

export async function deactivate() {
Expand Down
Loading

0 comments on commit a963d76

Please sign in to comment.