Skip to content

Commit 51d30e5

Browse files
committed
Adds tooltip to pr-icon
1 parent 5b38c36 commit 51d30e5

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
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
@@ -193,7 +193,7 @@ export class GlActiveWork extends SignalWatcher(LitElement) {
193193
return html`<div class="branch-item__section">
194194
<p class="branch-item__grouping">
195195
<span class="branch-item__icon">
196-
<pr-icon state=${pr.state}></pr-icon>
196+
<pr-icon state=${pr.state} pr-id=${pr.id}></pr-icon>
197197
</span>
198198
<span class="branch-item__name">${pr.title}</span>
199199
<a href=${pr.url} class="branch-item__identifier">#${pr.id}</a>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ export class GlBranchCard extends LitElement {
257257

258258
private renderIcon(branch: OverviewBranch, noPr?: boolean) {
259259
if (branch.pr && !noPr) {
260-
return html`<pr-icon state=${branch.pr.state}></pr-icon>`;
260+
return html`<pr-icon state=${branch.pr.state} pr-id=${branch.pr.id}></pr-icon>`;
261261
}
262262
if (branch.worktree) {
263263
return html`<code-icon icon="gl-worktrees-view"></code-icon>`;

src/webviews/apps/shared/components/rich/pr-icon.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { customElement, property } from 'lit/decorators.js';
33
import { ifDefined } from 'lit/directives/if-defined.js';
44
import { prIconStyles } from './pr.css';
55
import '../code-icon';
6+
import '../overlays/tooltip';
67

78
@customElement('pr-icon')
89
export class PrIcon extends LitElement {
@@ -11,6 +12,9 @@ export class PrIcon extends LitElement {
1112
@property()
1213
state?: 'merged' | 'opened' | 'closed' | string;
1314

15+
@property({ attribute: 'pr-id' })
16+
prId?: string;
17+
1418
get icon() {
1519
let prIcon = 'git-pull-request';
1620
if (this.state) {
@@ -32,11 +36,24 @@ export class PrIcon extends LitElement {
3236
return `pr-icon pr-icon--${this.state}`;
3337
}
3438

39+
get label() {
40+
if (!this.state) return 'Pull request';
41+
42+
return `Pull request ${this.prId ? `#${this.prId}` : ''} is ${this.state}`;
43+
}
44+
3545
override render() {
36-
return html`<code-icon
37-
class=${this.classes}
38-
icon=${this.icon}
39-
aria-label=${ifDefined(this.state)}
40-
></code-icon>`;
46+
if (!this.state) {
47+
return html`<code-icon
48+
class=${this.classes}
49+
icon=${this.icon}
50+
aria-label=${ifDefined(this.state)}
51+
></code-icon>`;
52+
}
53+
54+
return html`<gl-tooltip>
55+
<code-icon class=${this.classes} icon=${this.icon} aria-label=${ifDefined(this.state)}></code-icon>
56+
<span slot="content">${this.label}</span>
57+
</gl-tooltip>`;
4158
}
4259
}

0 commit comments

Comments
 (0)