Skip to content

Commit 2a9e0b8

Browse files
committed
Splits commands in home for viewing pull request changes
1 parent eb722f6 commit 2a9e0b8

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

src/webviews/apps/plus/home/components/active-work.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ export class GlActiveWork extends SignalWatcher(LitElement) {
219219
html`<action-item
220220
label="Open Pull Request Changes"
221221
icon="request-changes"
222-
href=${createCommandLink('gitlens.home.openPullRequestComparison', branchRefs)}
222+
href=${createCommandLink('gitlens.home.openPullRequestChanges', branchRefs)}
223223
></action-item>`,
224224
);
225225
actions.push(

src/webviews/apps/plus/home/components/branch-section.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,6 @@ export const headingLoaderStyles = css`
117117
`;
118118

119119
export const branchCardStyles = css`
120-
:host {
121-
--gl-card-hover-background: color-mix(in lab, var(--vscode-sideBar-background) 100%, #fff 8%);
122-
}
123120
.branch-item {
124121
position: relative;
125122
}
@@ -196,13 +193,9 @@ export const branchCardStyles = css`
196193
right: 0.4rem;
197194
bottom: 0.4rem;
198195
padding: 0.2rem 0.4rem;
199-
background-color: var(--gl-card-background);
200-
}
201-
202-
.branch-item:hover .branch-item__actions,
203-
.branch-item:focus-within .branch-item__actions {
204196
background-color: var(--gl-card-hover-background);
205197
}
198+
206199
.branch-item:not(:focus-within):not(:hover) .branch-item__actions {
207200
${srOnlyStyles}
208201
}
@@ -358,7 +351,7 @@ export class GlBranchCard extends LitElement {
358351
html`<action-item
359352
label="Open Pull Request Changes"
360353
icon="request-changes"
361-
href=${this.createCommandLink('gitlens.home.openPullRequestComparison')}
354+
href=${this.createCommandLink('gitlens.home.openPullRequestChanges')}
362355
></action-item>`,
363356
);
364357
actions.push(

src/webviews/home/homeWebview.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type { ContextKeys } from '../../constants.context';
99
import type { HomeTelemetryContext } from '../../constants.telemetry';
1010
import type { Container } from '../../container';
1111
import { executeGitCommand } from '../../git/actions';
12+
import { openComparisonChanges } from '../../git/actions/commit';
1213
import * as RepoActions from '../../git/actions/repository';
1314
import type { BranchContributorOverview } from '../../git/gitProvider';
1415
import type { GitBranch } from '../../git/models/branch';
@@ -266,6 +267,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
266267
() => this.container.subscription.validate({ force: true }),
267268
this,
268269
),
270+
registerCommand('gitlens.home.openPullRequestChanges', this.pullRequestChanges, this),
269271
registerCommand('gitlens.home.openPullRequestComparison', this.pullRequestCompare, this),
270272
registerCommand('gitlens.home.openPullRequestOnRemote', this.pullRequestViewOnRemote, this),
271273
registerCommand('gitlens.home.createPullRequest', this.pullRequestCreate, this),
@@ -773,11 +775,27 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
773775
if (pr?.refs?.base == null || pr.refs.head == null) return;
774776

775777
const comparisonRefs = getComparisonRefsForPullRequest(refs.repoPath, pr.refs);
776-
return this.container.views.searchAndCompare
777-
.compare(comparisonRefs.repoPath, comparisonRefs.head, comparisonRefs.base)
778-
.then(compareNode => {
779-
executeCommand(Commands.ViewsOpenAllChangedFileDiffs, compareNode);
780-
});
778+
return this.container.views.searchAndCompare.compare(
779+
comparisonRefs.repoPath,
780+
comparisonRefs.head,
781+
comparisonRefs.base,
782+
);
783+
}
784+
785+
private async pullRequestChanges(refs: BranchRef) {
786+
const pr = await this.findPullRequest(refs);
787+
if (pr?.refs?.base == null || pr.refs.head == null) return;
788+
789+
const comparisonRefs = getComparisonRefsForPullRequest(refs.repoPath, pr.refs);
790+
return openComparisonChanges(
791+
this.container,
792+
{
793+
repoPath: comparisonRefs.repoPath,
794+
lhs: comparisonRefs.base.ref,
795+
rhs: comparisonRefs.head.ref,
796+
},
797+
{ title: `Changes in Pull Request #${pr.id}` },
798+
);
781799
}
782800

783801
private async pullRequestViewOnRemote(refs: BranchRef, clipboard?: boolean) {

0 commit comments

Comments
 (0)