OwnedCommitViewer should include the preceding commit.
[WebKit.git] / Websites / perf.webkit.org / public / v3 / components / commit-log-viewer.js
index 215072a..cc20c26 100644 (file)
@@ -8,7 +8,15 @@ class CommitLogViewer extends ComponentBase {
         this._repository = null;
         this._fetchingPromise = null;
         this._commits = null;
+        this._precedingCommit = null;
         this._renderCommitListLazily = new LazilyEvaluatedFunction(this._renderCommitList.bind(this));
+        this._showRepositoryName = true;
+    }
+
+    setShowRepositoryName(shouldShow)
+    {
+        this._showRepositoryName = shouldShow;
+        this.enqueueToRender();
     }
 
     view(repository, precedingRevision, lastRevision)
@@ -28,7 +36,8 @@ class CommitLogViewer extends ComponentBase {
         }
 
         let promise;
-        if (!precedingRevision || precedingRevision == lastRevision)
+        const fetchSingleCommit = !precedingRevision || precedingRevision == lastRevision;
+        if (fetchSingleCommit)
             promise = CommitLog.fetchForSingleRevision(repository, lastRevision);
         else
             promise = CommitLog.fetchBetweenRevisions(repository, precedingRevision, lastRevision);
@@ -39,9 +48,26 @@ class CommitLogViewer extends ComponentBase {
         this._fetchingPromise.then((commits) => {
             if (this._fetchingPromise != promise)
                 return;
-            this._fetchingPromise = null;
             this._commits = commits;
-            this.enqueueToRender();
+            if (fetchSingleCommit) {
+                this._fetchingPromise = null;
+                this._precedingCommit = null;
+                this.enqueueToRender();
+                return;
+            }
+            return CommitLog.fetchForSingleRevision(repository, precedingRevision).then((precedingCommit) => {
+                if (this._fetchingPromise != promise)
+                    return;
+                this._fetchingPromise = null;
+                this._precedingCommit = precedingCommit[0];
+                this.enqueueToRender();
+            }, (error) => {
+                if (this._fetchingPromise != promise)
+                    return;
+                this._fetchingPromise = null;
+                this._precedingCommit = null;
+                this.enqueueToRender();
+            });
         }, (error) => {
             if (this._fetchingPromise != promise)
                 return;
@@ -55,23 +81,29 @@ class CommitLogViewer extends ComponentBase {
 
     render()
     {
-        const shouldShowRepositoryName = this._repository && (this._commits || this._fetchingPromise);
+        const shouldShowRepositoryName = this._repository && (this._commits || this._fetchingPromise) && this._showRepositoryName;
         this.content('repository-name').textContent = shouldShowRepositoryName ? this._repository.name() : '';
         this.content('spinner-container').style.display = this._fetchingPromise ? null : 'none';
-        this._renderCommitListLazily.evaluate(this._commits);
+        this._renderCommitListLazily.evaluate(this._commits, this._precedingCommit);
     }
 
-    _renderCommitList(commits)
+    _renderCommitList(commits, precedingCommit)
     {
         const element = ComponentBase.createElement;
         const link = ComponentBase.createLink;
+        commits = commits && precedingCommit && precedingCommit.ownsCommits() ? [precedingCommit].concat(commits) : commits;
+        let previousCommit = null;
 
         this.renderReplace(this.content('commits-list'), (commits || []).map((commit) => {
             const label = commit.label();
             const url = commit.url();
-            return element('tr', [
-                element('th', [element('h4', {class: 'revision'}, url ? link(label, commit.title(), url) : label), commit.author() || '']),
-                element('td', commit.message() ? commit.message().substring(0, 80) : '')]);
+            const ownsCommits = previousCommit && previousCommit.ownsCommits() && commit.ownsCommits();
+            const ownedCommitDifferenceRow = ownsCommits ? element('tr', element('td', {colspan: 2}, new OwnedCommitViewer(previousCommit, commit))) : [];
+            previousCommit = commit;
+            return [ownedCommitDifferenceRow,
+                element('tr', [
+                    element('th', [element('h4', {class: 'revision'}, url ? link(label, commit.title(), url) : label), commit.author() || '']),
+                    element('td', commit.message() ? commit.message().substring(0, 80) : '')])];
         }));
     }
 
@@ -96,7 +128,7 @@ class CommitLogViewer extends ComponentBase {
                 height: calc(100% - 2px);
                 overflow-y: scroll;
             }
-            
+
             #commits-viewer-table {
                 width: 100%;
                 border-collapse: collapse;