diff --git a/compose-db.js b/compose-db.js index 84e3a68..87dfec0 100644 --- a/compose-db.js +++ b/compose-db.js @@ -3,6 +3,7 @@ const path = require('path'); const fetch = require('node-fetch'); const teams = {}; +const reviewers = {}; const authors = {}; const pulls = []; let page_count = 1; @@ -62,6 +63,7 @@ function processPulls(pullsRaw) { "milestone": null, "teams": [], + "reviewers": [], }; // Compose and link author information. @@ -152,6 +154,28 @@ function processPulls(pullsRaw) { pr.teams.push(team.id); } + // Add individual reviewers, if available + if (item.requested_reviewers.length > 0) { + item.requested_reviewers.forEach((reviewerItem) => { + const reviewer = { + "id": reviewerItem.id, + "name": reviewerItem.login, + "avatar": reviewerItem.avatar_url, + "slug": reviewerItem.login, + "pull_count": 0, + }; + + // Store the reviewer if it hasn't been stored before. + if (typeof reviewers[reviewer.id] == "undefined") { + reviewers[reviewer.id] = reviewer; + } + reviewers[reviewer.id].pull_count++; + + // Reference the reviewer. + pr.reviewers.push(reviewer.id); + }); + } + pulls.push(pr); }); } @@ -172,6 +196,7 @@ async function main() { const output = { "generated_at": Date.now(), "teams": teams, + "reviewers": reviewers, "authors": authors, "pulls": pulls, }; diff --git a/src/paths/index/components/prs/PullRequestList.js b/src/paths/index/components/prs/PullRequestList.js index 34d12dd..a19af6e 100644 --- a/src/paths/index/components/prs/PullRequestList.js +++ b/src/paths/index/components/prs/PullRequestList.js @@ -113,7 +113,8 @@ export default class PullRequestList extends LitElement { @property({ type: Array }) pulls = []; @property({ type: Object }) teams = {}; - @property( { type: Number }) selected_team = -1; + @property( { type: Number }) selected_group = -1; + @property({ type: Boolean }) selected_is_person = false; @property({ type: Object }) authors = {}; constructor() { @@ -270,7 +271,14 @@ export default class PullRequestList extends LitElement { ${pulls.map((item) => { const other_teams = []; item.teams.forEach((teamId) => { - if (teamId !== this.selected_team) { + if (teamId === -1) { + return; // continue + } + + if ( + this.selected_is_person + || (!this.selected_is_person && teamId !== this.selected_group) + ) { other_teams.push( this.teams[teamId].name ); diff --git a/src/paths/index/components/teams/TeamItem.js b/src/paths/index/components/teams/TeamItem.js index 06ffe0e..ee4fc2a 100644 --- a/src/paths/index/components/teams/TeamItem.js +++ b/src/paths/index/components/teams/TeamItem.js @@ -42,6 +42,7 @@ export default class TeamItem extends LitElement { :host .team-icon { background-size: cover; + border-radius: 2px; display: inline-block; width: 16px; height: 16px; diff --git a/src/paths/index/components/teams/TeamList.js b/src/paths/index/components/teams/TeamList.js index 0a18ca1..bd16fbb 100644 --- a/src/paths/index/components/teams/TeamList.js +++ b/src/paths/index/components/teams/TeamList.js @@ -10,11 +10,13 @@ export default class TeamList extends LitElement { :host { --teams-background-color: #fcfcfa; --teams-border-color: #515c6c; + --section-active-border-color: #397adf; } @media (prefers-color-scheme: dark) { :host { --teams-background-color: #0d1117; --teams-border-color: #515c6c; + --section-active-border-color: #397adf; } } @@ -29,44 +31,125 @@ export default class TeamList extends LitElement { min-height: 216px; } - :host .team-list h4 { - margin: 0 0 12px 0; + :host .team-list-switcher { + display: flex; + flex-direction: row; + justify-content: center; + } + :host .team-list-title { + cursor: pointer; + margin: 0 10px 12px 10px; + } + :host .team-list-title--active { + border-bottom: 3px solid var(--section-active-border-color); + } + + :host .team-list-section { + display: none; + } + :host .team-list-section--active { + display: block; } `; } @property({ type: Array }) teams = []; - @property({ type: Number }) selected_team = -1; + @property({ type: Array }) reviewers = []; + @property({ type: Number }) selected = -1; + @property({ type: Boolean }) selected_is_person = false; - onTabClicked(tabId, tabSlug, event) { + constructor() { + super(); + + this._currentSection = "teams"; + } + + onSwitcherClicked(switchTo, event) { + this._currentSection = switchTo; + this.requestUpdate(); + } + + onTabClicked(tabId, tabSlug, isPerson, event) { this.dispatchEvent(greports.util.createEvent("tabclick", { "tabId": tabId, + "isPerson": isPerson, })); greports.util.setHistoryHash(tabSlug); } + update(changedProperties) { + if (changedProperties.has("selected_is_person")) { + this._currentSection = (this.selected_is_person ? "reviewers" : "teams"); + } + + super.update(changedProperties); + } + render() { + const teamsClassList = [ "team-list-section", "team-list-section--teams" ]; + if (this._currentSection === "teams") { + teamsClassList.push("team-list-section--active"); + } + const reviewersClassList = [ "team-list-section", "team-list-section--reviewers" ]; + if (this._currentSection === "reviewers") { + reviewersClassList.push("team-list-section--active"); + } + return html`