- ${this.workflows.map((item) => {
+ ${workflows.map((item) => {
return html`
${item.name}
diff --git a/src/paths/index/components/commits/CommitList.js b/src/paths/index/components/commits/CommitList.js
index 6bbe140..17e7f42 100644
--- a/src/paths/index/components/commits/CommitList.js
+++ b/src/paths/index/components/commits/CommitList.js
@@ -1,6 +1,7 @@
import { LitElement, html, css, customElement, property } from 'lit-element';
import CommitItem from "./CommitItem";
+import LatestItem from "./LatestItem";
@customElement('gr-commit-list')
export default class CommitList extends LitElement {
@@ -57,11 +58,60 @@ export default class CommitList extends LitElement {
@property({ type: Object }) checks = {};
@property({ type: Object }) runs = {};
@property({ type: Object }) artifacts = {};
+ @property({ type: Object }) latest = {};
@property({ type: String }) selectedRepository = "";
@property({ type: String }) selectedBranch = "";
@property({ type: Boolean, reflect: true }) loading = false;
+ constructor() {
+ super();
+
+ this._workflowsPerCommit = {};
+ }
+
+ _updateWorkflows() {
+ this._workflowsPerCommit = {};
+
+ this.commits.forEach((item) => {
+ let workflows = [];
+
+ for (let checkId in this.checks) {
+ const check = this.checks[checkId];
+ if (item.checks.indexOf(check.check_id) < 0) {
+ continue;
+ }
+
+ if (check.workflow === "" || typeof this.runs[check.workflow] === "undefined") {
+ continue;
+ }
+
+ const run = this.runs[check.workflow];
+ if (run.artifacts.length === 0) {
+ continue;
+ }
+
+ workflows.push({
+ "name": run.name,
+ "name_sanitized": run.name.replace(/([^a-zA-Z0-9_\- ]+)/g, "").trim().toLowerCase(),
+ "check_id": check.check_id,
+ "artifacts": run.artifacts,
+ });
+ }
+
+ this._workflowsPerCommit[item.hash] = workflows;
+ });
+ }
+
+ update(changedProperties) {
+ // Only recalculate when class properties change; skip for manual updates.
+ if (changedProperties.size > 0) {
+ this._updateWorkflows();
+ }
+
+ super.update(changedProperties);
+ }
+
render(){
if (this.selectedBranch === "") {
return html``;
@@ -69,42 +119,19 @@ export default class CommitList extends LitElement {
if (this.loading) {
return html`
Loading artifacts...
- `
+ `;
}
return html`
+
+
${this.commits.map((item) => {
- let workflows = [];
-
- for (let checkId in this.checks) {
- const check = this.checks[checkId];
- if (item.checks.indexOf(check.check_id) < 0) {
- continue;
- }
-
- if (check.workflow == null || typeof this.runs[check.workflow] === "undefined") {
- continue;
- }
-
- const run = this.runs[check.workflow];
- if (run.artifacts.length === 0) {
- continue;
- }
-
- workflows.push({
- "name": run.name,
- "name_sanitized": run.name.replace(/([^a-zA-Z0-9_\- ]+)/g, "").trim().toLowerCase(),
- "check_id": check.check_id,
- "artifacts": run.artifacts,
- });
- }
-
- workflows.sort((a,b) => {
- if (a.name_sanitized > b.name_sanitized) return 1;
- if (a.name_sanitized < b.name_sanitized) return -1;
- return 0;
- });
+ const workflows = this._workflowsPerCommit[item.hash];
return html`
{
+ if (a.name_sanitized > b.name_sanitized) return 1;
+ if (a.name_sanitized < b.name_sanitized) return -1;
+ return 0;
+ });
+ }
+
+ update(changedProperties) {
+ // Only recalculate when class properties change; skip for manual updates.
+ if (changedProperties.size > 0) {
+ this._updateWorkflows();
+ }
+
+ super.update(changedProperties);
+ }
+
+ render(){
+ return html`
+
+
+ Latest
+
+
Builds may be from different runs, depending on their availability.
+
+ ${this._latestByWorkflow.map((item) => {
+ return html`
+
+
${item.name}
+
+ ${item.artifacts.map((artifact) => {
+ return html`
+
+
+ ${artifact.artifact_name}
+
+ (${greports.format.humanizeBytes(artifact.artifact_size)})
+
+ `;
+ })}
+
+
+ `;
+ })}
+
+
+ `;
+ }
+}
diff --git a/src/paths/index/entry.js b/src/paths/index/entry.js
index 2e60704..e1a0dee 100644
--- a/src/paths/index/entry.js
+++ b/src/paths/index/entry.js
@@ -120,6 +120,7 @@ export default class EntryComponent extends LitElement {
let checks = {};
let runs = {};
let artifacts = {};
+ let latest = {};
if (this._selectedBranch !== "" && typeof this._branchData[this._selectedBranch] !== "undefined") {
const branchData = this._branchData[this._selectedBranch];
@@ -128,6 +129,7 @@ export default class EntryComponent extends LitElement {
checks = branchData.checks;
runs = branchData.runs;
artifacts = branchData.artifacts;
+ latest = branchData.latest;
}
return html`
@@ -153,6 +155,7 @@ export default class EntryComponent extends LitElement {
.checks="${checks}"
.runs="${runs}"
.artifacts="${artifacts}"
+ .latest="${latest}"
.selectedRepository="${this._selectedRepository}"
.selectedBranch="${this._selectedBranch}"