Add the author information for each PR

This commit is contained in:
Yuri Sizov
2021-08-24 18:48:28 +03:00
parent b42c0f67a5
commit ed7c61cd0c
3 changed files with 49 additions and 3 deletions

View File

@@ -104,12 +104,28 @@ export default class PullRequestItem extends LitElement {
}
:host .pr-milestone-value {
font-weight: 700;
}
:host .pr-time {
}
:host .pr-time-value {
border-bottom: 1px dashed var(--g-font-color);
cursor: help;
font-weight: 700;
}
:host .pr-author {
}
:host .pr-author-value {
}
:host .pr-author-value--hot:before {
content: "★";
color: var(--draft-font-color);
}
:host .pr-stats {
@@ -194,6 +210,7 @@ export default class PullRequestItem extends LitElement {
@property({ type: String, reflect: true }) branch = '';
@property({ type: String }) created_at = '';
@property({ type: String }) updated_at = '';
@property({ type: Object }) author = null;
@property({ type: Array }) teams = [];
getStatTemp(value, factor) {
@@ -216,6 +233,11 @@ export default class PullRequestItem extends LitElement {
return 0;
});
const authorClassList = [ "pr-author-value" ];
if (this.author.pull_count > 40) {
authorClassList.push("pr-author-value--hot");
}
return html`
<div class="pr-container">
<a
@@ -266,7 +288,9 @@ export default class PullRequestItem extends LitElement {
</div>
<div>
<span>branch: </span>
<span>${this.branch}</span>
<span class="pr-milestone-value">
${this.branch}
</span>
</div>
</div>
@@ -289,6 +313,17 @@ export default class PullRequestItem extends LitElement {
${greports.format.formatDate(this.updated_at)}
</span>
</div>
<div class="pr-author">
<span>author: </span>
<a
class="${authorClassList.join(" ")}"
href="${this.author.url}"
target="_blank"
title="${this.author.user} has ${this.author.pull_count} ${(this.author.pull_count > 1) ? 'PRs' : 'PR'}"
>
${this.author.user}
</a>
</div>
</div>
</div>

View File

@@ -60,6 +60,7 @@ export default class PullRequestList extends LitElement {
@property({ type: Array }) pulls = [];
@property({ type: Object }) teams = {};
@property({ type: Object }) authors = {};
constructor() {
super();
@@ -113,7 +114,7 @@ export default class PullRequestList extends LitElement {
</div>
${pulls.map((item) => {
let other_teams = [];
const other_teams = [];
item.teams.forEach((teamId) => {
if (teamId !== this._selectedTeam) {
other_teams.push(
@@ -121,6 +122,11 @@ export default class PullRequestList extends LitElement {
);
}
});
let author = null;
if (typeof this.authors[item.authored_by] != "undefined") {
author = this.authors[item.authored_by];
}
return html`
<gr-pull-request
@@ -135,6 +141,7 @@ export default class PullRequestList extends LitElement {
.created_at="${item.created_at}"
.updated_at="${item.updated_at}"
.author="${author}"
.diff_url="${item.diff_url}"
.patch_url="${item.patch_url}"

View File

@@ -40,6 +40,7 @@ export default class EntryComponent extends LitElement {
this._orderedTeams = [];
this._selectedTeam = -1;
this._authors = {};
this._pulls = [];
this._requestData();
@@ -60,6 +61,7 @@ export default class EntryComponent extends LitElement {
if (data) {
this._generatedAt = data.generated_at;
this._teams = data.teams;
this._authors = data.authors;
this._pulls = data.pulls;
this._orderedTeams = Object.values(this._teams);
@@ -75,8 +77,9 @@ export default class EntryComponent extends LitElement {
this._generatedAt = null;
this._teams = {};
this._orderedTeams = [];
this._pulls = [];
this._selectedTeam = -1;
this._authors = {};
this._pulls = [];
}
this.requestUpdate();
@@ -117,6 +120,7 @@ export default class EntryComponent extends LitElement {
<gr-pull-list
.pulls="${pulls}"
.teams="${this._teams}"
.authors="${this._authors}"
></gr-pull-list>
</div>
</page-content>