1
1
// @ts -check
2
2
3
+ import '@github/relative-time-element' ;
3
4
import { css , html , LitElement } from 'lit' ;
4
5
import { ifDefined } from 'lit/directives/if-defined.js' ;
5
6
import { SHARED_STYLES } from '../css/shared-css' ;
7
+ import { ExternalReviewer } from './external-reviewers' ;
6
8
7
9
// LINK_TYPES should be consistent with the server link_helpers.py
8
10
const LINK_TYPE_CHROMIUM_BUG = 'chromium_bug' ;
@@ -97,7 +99,7 @@ function enhanceGithubIssueLink(featureLink, text) {
97
99
}
98
100
const information = featureLink . information ;
99
101
const assignee = information . assignee_login ;
100
- const createdAt = information . created_at ;
102
+ const createdAt = new Date ( information . created_at ) ;
101
103
const closedAt = information . closed_at ;
102
104
const updatedAt = information . updated_at ;
103
105
const state = information . state ;
@@ -109,6 +111,45 @@ function enhanceGithubIssueLink(featureLink, text) {
109
111
const typePath = featureLink . url . split ( '/' ) . slice ( - 2 ) [ 0 ] ;
110
112
const type = typePath === 'issues' ? 'Issue' : typePath === 'pull' ? 'Pull Request' : typePath ;
111
113
114
+ // If this issue is an external review of the feature, find the summary description.
115
+ const externalReviewer = ExternalReviewer . get ( repo ) ;
116
+ let stateDescription = undefined ;
117
+ let stateVariant = undefined ;
118
+ if ( externalReviewer ) {
119
+ for ( const label of information . labels ) {
120
+ const labelInfo = externalReviewer . label ( label ) ;
121
+ if ( labelInfo ) {
122
+ ( { description : stateDescription , variant : stateVariant } = labelInfo ) ;
123
+ break ;
124
+ }
125
+ }
126
+ }
127
+
128
+ if ( stateVariant === undefined ) {
129
+ if ( state === 'open' ) {
130
+ const age = Date . now ( ) - createdAt . getTime ( ) ;
131
+ stateDescription = html `Opened < relative-time .date =${ createdAt } format ="relative" precision="day" threshold="P100Y"> on ${ _dateTimeFormat . format ( createdAt ) } </ relative-time > ` ;
132
+ const week = 7 * 24 * 60 * 60 * 1000 ;
133
+ stateVariant = 'success' ;
134
+ if ( externalReviewer ) {
135
+ // If this is an issue asking for external review, having it filed too recently is a warning
136
+ // sign, which we'll indicate using the tag's color.
137
+ if ( age < 2 * week ) {
138
+ stateVariant = 'danger' ;
139
+ } else if ( age < 4 * week ) {
140
+ stateVariant = 'warning' ;
141
+ } else {
142
+ // Still only neutral if the reviewer hasn't given a position yet.
143
+ stateVariant = 'neutral' ;
144
+ }
145
+ }
146
+ } else {
147
+ console . assert ( state === 'closed' ) ;
148
+ stateDescription = 'Closed' ;
149
+ stateVariant = 'neutral' ;
150
+ }
151
+ }
152
+
112
153
if ( ! text ) {
113
154
text = title ;
114
155
}
@@ -169,8 +210,8 @@ function enhanceGithubIssueLink(featureLink, text) {
169
210
< sl-tooltip style ="--sl-tooltip-arrow-size: 0;--max-width: 50vw; ">
170
211
< div slot ="content "> ${ renderTooltipContent ( ) } </ div >
171
212
< sl-tag >
172
- < img src =" https://docs.github.com/assets/cb-600/images/site/favicon.png " alt ="icon " class ="icon " />
173
- < sl-badge size ="small " variant =" ${ state === 'open' ? 'success' : 'neutral' } " > ${ state } </ sl-badge >
213
+ < img src =${ externalReviewer ?. icon ?? ' https://docs.github.com/assets/cb-600/images/site/favicon.png' } alt ="icon" class="icon" />
214
+ < sl-badge size ="small " variant =${ stateVariant } > ${ stateDescription } </ sl-badge >
174
215
${ _formatLongText ( `#${ number } ` + text ) }
175
216
</ sl-tag >
176
217
</ sl-tooltip >
@@ -337,8 +378,8 @@ export class ChromedashLink extends LitElement {
337
378
}
338
379
339
380
sl-badge::part(base) {
340
- height: 14px ;
341
- padding: 4px;
381
+ display: inline ;
382
+ padding: 0 4px;
342
383
border-width: 0;
343
384
text-transform: capitalize;
344
385
font-weight: 400;
0 commit comments