Commit fe1965ca authored by ojan@chromium.org's avatar ojan@chromium.org

Only show tree status if the tree isn't open.

In the spirit of sheriff-o-matic only showing problems that
need solving, there's no point in showing tree open status.
We might want to reconsider this in the future where we
show you the actual status message, but right now the open
state is hard-coded to say "Tree is open", which is not
information I need to see.

Also, cleaned up a couple minor polymer things:
-No need to set the attributes attribute if we're using publish.
-Initialize all the member variables on ct-tree-status.
-Don't use setAttribute. Should basically always set element
values by property.

NOTRY=true
R=abarth@chromium.org

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

git-svn-id: svn://svn.chromium.org/blink/trunk@178524 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e9ec525a
......@@ -29,7 +29,7 @@ closedTreeJson = {
"can_commit_freely": false
}
asyncTest("basic", 7, function() {
asyncTest("basic", 9, function() {
var simulator = new NetworkSimulator();
simulator.json = function(url) {
if (url.indexOf('closed') != -1)
......@@ -39,12 +39,14 @@ asyncTest("basic", 7, function() {
else
return Promise.resolve(openTreeJson);
};
var opentree = document.createElement("ct-tree-status");
opentree.setAttribute("project", "open-tree-project");
opentree.project = "open-tree-project";
var throttledtree = document.createElement("ct-tree-status");
throttledtree.setAttribute("project", "throttled-tree-project");
throttledtree.project = "throttled-tree-project";
var closedtree = document.createElement("ct-tree-status");
closedtree.setAttribute("project", "closed-tree-project");
closedtree.project = "closed-tree-project";
simulator.runTest(function() {
var urlByName = treestatus.urlByName;
treestatus.urlByName = function(name) {
......@@ -52,7 +54,6 @@ asyncTest("basic", 7, function() {
}
Promise.all([
opentree.update().then(function() {
equal(opentree.message, "Tree is open");
equal(opentree.status, "open");
}),
throttledtree.update().then(function() {
......@@ -66,8 +67,13 @@ asyncTest("basic", 7, function() {
equal(closedtree.status, "closed");
})
]).then(function() {
start();
treestatus.urlByName = urlByName;
requestAnimationFrame(function() {
ok(!opentree.shadowRoot.textContent.trim());
ok(throttledtree.shadowRoot.textContent.has("throttled-tree-project"));
ok(closedtree.shadowRoot.textContent.has("closed-tree-project"));
start();
treestatus.urlByName = urlByName;
});
});
});
});
......
......@@ -4,32 +4,36 @@ Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<polymer-element name="ct-tree-status" attributes="project status">
<polymer-element name="ct-tree-status">
<template>
<style>
:host {
display: block;
whitespace: nowrap;
overflow: hidden;
text-overflow: ellispis;
}
<template if="{{ message }}">
<style>
:host {
display: block;
whitespace: nowrap;
overflow: hidden;
text-overflow: ellispis;
}
:host([status=throttled]) {
background-color: khaki;
}
:host([status=throttled]) {
background-color: khaki;
}
:host([status=closed]) {
color: white;
background-color: tomato;
}
</style>
{{project}}: {{message}}
:host([status=closed]) {
color: white;
background-color: tomato;
}
</style>
{{ project }}: {{ message }}
</template>
</template>
<script>
Polymer({
publish: {
project: '',
message: '',
status: {
value: 'unknown',
value: 'open',
reflect: true,
},
},
......@@ -43,18 +47,19 @@ found in the LICENSE file.
updateStatus: function(status) {
if (status.can_commit_freely) {
this.message = 'Tree is open';
this.message = null;
this.status = 'open';
return;
}
this.message = status.message + ' by ' + status.username;
var responseLowerCase = status.message.toLowerCase();
if (responseLowerCase.indexOf('throttled') != -1) {
this.status = 'throttled';
} else if (responseLowerCase.indexOf("closed") != -1) {
this.status = 'closed';
} else {
this.message = status.message + ' by ' + status.username;
var responseLowerCase = status.message.toLowerCase();
if (responseLowerCase.indexOf('throttled') != -1) {
this.status = 'throttled';
} else if (responseLowerCase.indexOf("closed") != -1) {
this.status = 'closed';
} else {
this.status = 'unknown';
}
this.status = 'unknown';
}
},
});
......
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