Skip to content

Commit

Permalink
Have a context menu to clear review status
Browse files Browse the repository at this point in the history
Fixes #6082
  • Loading branch information
alexr00 committed Dec 19, 2024
1 parent 03410cb commit 2867451
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/view/prChangesTreeDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class PullRequestChangesTreeDataProvider extends Disposable implements vs
this._view = this._register(vscode.window.createTreeView('prStatus:github', {
treeDataProvider: this,
showCollapseAll: true,
canSelectMany: true
}));

this._register(
Expand All @@ -54,7 +55,7 @@ export class PullRequestChangesTreeDataProvider extends Disposable implements vs
}),
);

this._register(this._view.onDidChangeCheckboxState(TreeUtils.processCheckboxUpdates));
this._register(this._view.onDidChangeCheckboxState(e => TreeUtils.processCheckboxUpdates(e, this._view.selection)));
}

refresh(treeNode?: TreeNode) {
Expand Down
2 changes: 1 addition & 1 deletion src/view/prsTreeDataProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class PullRequestsTreeDataProvider extends Disposable implements vscode.T
}
}));

this._register(this._view.onDidChangeCheckboxState(TreeUtils.processCheckboxUpdates));
this._register(this._view.onDidChangeCheckboxState(e => TreeUtils.processCheckboxUpdates(e, [])));

this._register(this._view.onDidExpandElement(expanded => {
this.prsTreeModel.updateExpandedQueries(expanded.element, true);
Expand Down
19 changes: 18 additions & 1 deletion src/view/treeNodes/treeUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { FileChangeNode } from './fileChangeNode';
import { TreeNode } from './treeNode';

export namespace TreeUtils {
export function processCheckboxUpdates(checkboxUpdates: vscode.TreeCheckboxChangeEvent<TreeNode>) {
export function processCheckboxUpdates(checkboxUpdates: vscode.TreeCheckboxChangeEvent<TreeNode>, selection: readonly TreeNode[]) {
const selectionContainsUpdates = selection.some(node => checkboxUpdates.items.some(update => update[0] === node));

const checkedNodes: FileChangeNode[] = [];
const uncheckedNodes: FileChangeNode[] = [];

Expand All @@ -27,6 +29,21 @@ export namespace TreeUtils {
node.updateFromCheckboxChanged(newState);
});

if (selectionContainsUpdates) {
for (const selected of selection) {
if (!(selected instanceof FileChangeNode)) {
continue;
}
if (!checkedNodes.includes(selected) && !uncheckedNodes.includes(selected)) {
if (selected.checkboxState.state === vscode.TreeItemCheckboxState.Unchecked) {
checkedNodes.push(selected);
} else {
uncheckedNodes.push(selected);
}
}
}
}

if (checkedNodes.length > 0) {
const prModel = checkedNodes[0].pullRequest;
const filenames = checkedNodes.map(n => n.fileName);
Expand Down

0 comments on commit 2867451

Please sign in to comment.