Skip to content

Commit 0abbc4a

Browse files
authored
Add session log icon and small fixes (#7172)
Fixes #7167
1 parent 2fc1786 commit 0abbc4a

File tree

5 files changed

+33
-23
lines changed

5 files changed

+33
-23
lines changed

resources/icons/dark/output.svg

Lines changed: 13 additions & 0 deletions
Loading

resources/icons/output.svg

Lines changed: 1 addition & 0 deletions
Loading

src/view/sessionLogView.ts

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,12 @@ export class SessionLogViewManager extends Disposable implements vscode.WebviewP
9191
}
9292

9393
async openForPull(pullRequest: PullRequestModel, link: SessionLinkInfo, openToTheSide?: boolean): Promise<void> {
94-
const source: SessionLogSource = { type: 'pull', pullRequest: toPullInfo(pullRequest), link };
94+
const source: SessionLogSource = {
95+
type: 'pull', pullRequest: {
96+
...link,
97+
title: pullRequest.title
98+
}, link
99+
};
95100
const existingPanel = this.getPanelForPullRequest(pullRequest);
96101
if (existingPanel) {
97102
existingPanel.revealAndRefresh(source);
@@ -167,7 +172,7 @@ export class SessionLogViewManager extends Disposable implements vscode.WebviewP
167172
}
168173

169174
type SessionLogSource =
170-
| { type: 'pull', readonly pullRequest: SessionPullInfo & { title: string }; readonly link: SessionLinkInfo }
175+
| { type: 'pull', readonly pullRequest: SessionLinkInfo & { title: string }; readonly link: SessionLinkInfo }
171176
| { type: 'session', readonly sessionId: string }
172177
;
173178

@@ -256,11 +261,7 @@ class SessionLogView extends Disposable {
256261
}
257262

258263
public isForPullRequest(pullRequest: PullRequestModel): boolean {
259-
if (this._source.type !== 'pull') {
260-
return false;
261-
}
262-
const inInfo = toPullInfo(pullRequest);
263-
return arePullInfosEqual(this._source.pullRequest, inInfo);
264+
return this._source.type === 'pull' && this._source.pullRequest.id === pullRequest.id;
264265
}
265266

266267
public isForSession(sessionId: string): boolean {
@@ -270,7 +271,7 @@ class SessionLogView extends Disposable {
270271
public revealAndRefresh(source: SessionLogSource): void {
271272
if (
272273
(this._source.type === 'session' && source.type === 'session' && this._source.sessionId === source.sessionId)
273-
|| (this._source.type === 'pull' && source.type === 'pull' && arePullInfosEqual(this._source.pullRequest, source.pullRequest))
274+
|| (this._source.type === 'pull' && source.type === 'pull' && arePullLinksEqual(this._source.pullRequest, source.pullRequest))
274275
) {
275276
// No need to reload content
276277
this.webviewPanel.reveal();
@@ -283,6 +284,10 @@ class SessionLogView extends Disposable {
283284

284285
private async initialize() {
285286
this.webviewPanel.title = this._source.type === 'pull' ? vscode.l10n.t(`Session Log (Pull #{0})`, this._source.pullRequest.pullNumber) : vscode.l10n.t('Session Log');
287+
this.webviewPanel.iconPath = {
288+
light: vscode.Uri.joinPath(this.context.extensionUri, 'resources/icons/output.svg'),
289+
dark: vscode.Uri.joinPath(this.context.extensionUri, 'resources/icons/dark/output.svg')
290+
};
286291

287292
const distDir = vscode.Uri.joinPath(this.context.extensionUri, 'dist');
288293

@@ -393,6 +398,7 @@ class SessionLogView extends Disposable {
393398

394399
this.webviewPanel.webview.postMessage({
395400
type: 'loaded',
401+
pullInfo: this._source.type === 'pull' ? this._source.pullRequest : undefined,
396402
info: apiResponse.info,
397403
logs: apiResponse.logs
398404
} as messages.LoadedMessage);
@@ -413,6 +419,7 @@ class SessionLogView extends Disposable {
413419

414420
this.webviewPanel.webview.postMessage({
415421
type: 'update',
422+
pullInfo: this._source.type === 'pull' ? this._source.pullRequest : undefined,
416423
info: apiResult.info,
417424
logs: apiResult.logs
418425
} as messages.UpdateMessage);
@@ -434,17 +441,6 @@ class SessionLogView extends Disposable {
434441
}
435442
}
436443

437-
function toPullInfo(pullRequest: PullRequestModel): SessionPullInfo & { title: string; } {
438-
return {
439-
id: pullRequest.id,
440-
host: pullRequest.githubRepository.remote.gitProtocol.host,
441-
owner: pullRequest.githubRepository.remote.owner,
442-
repo: pullRequest.githubRepository.remote.repositoryName,
443-
pullNumber: pullRequest.number,
444-
title: pullRequest.title,
445-
};
446-
}
447-
448-
function arePullInfosEqual(a: SessionPullInfo, b: SessionPullInfo): boolean {
449-
return a.id === b.id;
444+
function arePullLinksEqual(a: SessionLinkInfo, b: SessionLinkInfo): boolean {
445+
return a.id === b.id && a.sessionIndex === b.sessionIndex;
450446
}

webviews/sessionLogView/index.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
color: inherit;
7676

7777
.pull-request-id {
78-
color: var(--vscode-textLink-foreground);
78+
color: var(--vscode-descriptionForeground);
7979
}
8080
}
8181
}

webviews/sessionLogView/sessionView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const SessionHeader: React.FC<SessionHeaderProps> = ({ info, pullInfo }) => {
5959
<a className='pull-request-link' onClick={() => {
6060
vscode.postMessage({ type: 'openPullRequestView' });
6161
}} title='Back to pull request' style={{ cursor: 'pointer' }}>
62-
<span className="icon"><i className={'codicon codicon-git-pull-request'}></i></span> {pullInfo.title} <span className="pull-request-id">#{pullInfo.pullNumber}</span>
62+
<span className="icon"><i className={'codicon codicon-git-pull-request'}></i></span> {pullInfo.title} <span className="pull-request-id">(#{pullInfo.pullNumber})</span>
6363
</a>
6464
</h3>
6565

0 commit comments

Comments
 (0)