Skip to content

Commit 5215fdb

Browse files
Migrate to new 'reviewManagers' field
- Factor out code that creates HTML nodes from arrays of people records - Update renderAuthors() and renderReviewManager() to use factored code - Change renderReviewManager() to renderReviewManagers() to handle array - Update call site to check for empty array and call updated method - Update search properties to 'reviewManagers'
1 parent c1e6ccd commit 5215fdb

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

assets/javascripts/swift-evolution.js

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ function renderProposals() {
338338
var detailNodes = []
339339
detailNodes.push(renderAuthors(proposal.authors))
340340

341-
if (proposal.reviewManager.name) detailNodes.push(renderReviewManager(proposal.reviewManager))
341+
if (proposal.reviewManagers.length > 0) detailNodes.push(renderReviewManagers(proposal.reviewManagers))
342342
if (proposal.trackingBugs) detailNodes.push(renderTrackingBugs(proposal.trackingBugs))
343343
if (state === '.implemented') detailNodes.push(renderVersion(proposal.status.version))
344344
if (state === '.previewing') detailNodes.push(renderPreview())
@@ -370,36 +370,39 @@ function renderProposals() {
370370

371371
/** Authors have a `name` and optional `link`. */
372372
function renderAuthors(authors) {
373-
var authorNodes = authors.map(function (author) {
374-
if (author.link.length > 0) {
375-
return html('a', { href: author.link, target: '_blank' }, author.name)
376-
} else {
377-
return document.createTextNode(author.name)
378-
}
379-
})
380-
381-
authorNodes = _joinNodes(authorNodes, ', ')
382-
383373
return html('div', { className: 'authors proposal-detail' }, [
384374
html('div', { className: 'proposal-detail-label' },
385375
authors.length > 1 ? 'Authors: ' : 'Author: '
386376
),
387-
html('div', { className: 'proposal-detail-value' }, authorNodes)
377+
html('div', { className: 'proposal-detail-value' },
378+
personNodesForPersonArray(authors))
388379
])
389380
}
390381

391382
/** Review managers have a `name` and optional `link`. */
392-
function renderReviewManager(reviewManager) {
393-
return html('div', { className: 'review-manager proposal-detail' }, [
394-
html('div', { className: 'proposal-detail-label' }, 'Review Manager: '),
395-
html('div', { className: 'proposal-detail-value' }, [
396-
reviewManager.link
397-
? html('a', { href: reviewManager.link, target: '_blank' }, reviewManager.name)
398-
: reviewManager.name
399-
])
383+
function renderReviewManagers(reviewManagers) {
384+
return html('div', { className: 'review-managers proposal-detail' }, [
385+
html('div', { className: 'proposal-detail-label' },
386+
reviewManagers.length > 1 ? 'Review Managers: ' : 'Review Manager: '
387+
),
388+
html('div', { className: 'proposal-detail-value' },
389+
personNodesForPersonArray(reviewManagers))
400390
])
401391
}
402392

393+
/** Create nodes for arrays of authors and review managers. */
394+
function personNodesForPersonArray(personArray) {
395+
let personNodes = personArray.map(function (person) {
396+
if (person.link.length > 0) {
397+
return html('a', { href: person.link, target: '_blank' }, person.name)
398+
} else {
399+
return document.createTextNode(person.name)
400+
}
401+
})
402+
403+
return _joinNodes(personNodes, ', ')
404+
}
405+
403406
/** Tracking bugs linked in a proposal are updated via GitHub Issues. */
404407
function renderTrackingBugs(bugs) {
405408
var bugNodes = bugs.map(function (bug) {
@@ -742,7 +745,7 @@ function _searchProposals(filterText) {
742745
var searchableProperties = [
743746
['id'],
744747
['title'],
745-
['reviewManager', 'name'],
748+
['reviewManagers', 'name'],
746749
['status', 'state'],
747750
['status', 'version'],
748751
['authors', 'name'],

0 commit comments

Comments
 (0)