Collapse commit list by default in sheriff-o-matic.

This CL changes the sheriff-o-matic to collapse the commit list by default.
Each repository has a button you can press to expand the list of commits.

BUG=399715
NOTRY=true

Review URL: https://codereview.chromium.org/441393002

git-svn-id: svn://svn.chromium.org/blink/trunk@180386 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 99ec352e
......@@ -5,6 +5,7 @@ found in the LICENSE file.
-->
<link rel="import" href="ct-commit.html">
<link rel="import" href="../bower_components/paper-button/paper-button.html">
<polymer-element name="ct-commit-list" attributes="commitList">
<template>
......@@ -12,19 +13,46 @@ found in the LICENSE file.
:host {
display: block;
}
paper-icon-button {
vertical-align: middle;
}
.repository-info {
display: block;
}
</style>
<template repeat="{{ repository in commitList | _repositories }}">
<template repeat="{{ commit in repository.commits }}">
<ct-commit data="{{ commit }}"></ct-commit>
</template>
<div class="repository-info">
{{ repository.name }} {{ repository.range }}
<paper-icon-button icon="unfold-more"
on-click="{{ _toggle }}" repository="{{ repository.name }}"></paper-icon-button>
<template if="{{ repository.expanded }}">
<template repeat="{{ commit in repository.commits }}">
<ct-commit data="{{ commit }}"></ct-commit>
</template>
</template>
</div>
</template>
</template>
<script>
Polymer({
repositories: undefined,
created: function() {
this.repositories = [];
},
_repositories: function() {
if (!this.commitList)
return [];
return this.commitList.repositories();
if (this.commitList)
this.repositories = this.commitList.repositories();
return this.repositories;
},
_toggle: function(event, detail, sender, target) {
var repo = sender.getAttribute('repository');
var r = this.repositories.find(function(item) {
return item.name === repo;
});
r.expanded = !r.expanded;
}
});
</script>
......
......@@ -18,27 +18,42 @@ describe('ct-commit-list', function() {
beforeEach(function(done) {
list = document.createElement('ct-commit-list');
setTimeout(done);
});
describe('commit list UI', function() {
beforeEach(function(done) {
var repos = [
{ commits: [ new CTCommitMock(), new CTCommitMock() ],
expanded: false },
{ commits: [ new CTCommitMock(), new CTCommitMock() ],
expanded: false }
];
var CommitList = Object.create(Object);
CommitList.prototype.repositories = function() {
return [
{ commits: [ new CTCommitMock(), new CTCommitMock() ] },
{ commits: [ new CTCommitMock(), new CTCommitMock() ] }
]
return repos;
};
list.commitList = CommitList;
setTimeout(done);
});
it('should show all commits in revision range', function() {
it('should show no commits by default', function() {
var commits = list.shadowRoot.querySelectorAll('ct-commit');
assert.lengthOf(commits, 4);
assert.lengthOf(commits, 0);
});
describe('expanded test', function() {
beforeEach(function(done) {
list.commitList.repositories().first().expanded = true;
list.commitList.repositories().last().expanded = true;
setTimeout(done);
});
it('should show commits when expanded', function() {
assert.lengthOf(list.shadowRoot.querySelectorAll('ct-commit'), 4);
});
});
});
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment