Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2169)

Unified Diff: Tools/GardeningServer/model/ct-failure-group.html

Issue 448503003: Adds a snooze button to the sheriff-o-matic ui (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove unused import. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Tools/GardeningServer/model/ct-failure-group.html
diff --git a/Tools/GardeningServer/model/ct-failure-group.html b/Tools/GardeningServer/model/ct-failure-group.html
new file mode 100644
index 0000000000000000000000000000000000000000..e814bb0290ba0bcf5131063665d3b002baacf621
--- /dev/null
+++ b/Tools/GardeningServer/model/ct-failure-group.html
@@ -0,0 +1,64 @@
+<!--
+Copyright 2014 The Chromium Authors. All rights reserved.
+Use of this source code is governed by a BSD-style license that can be
+found in the LICENSE file.
+-->
+
+<script>
+function CTFailureGroup(key, failures, annotation) {
+ this.key = key;
+ this.failures = failures;
+ this.annotation = annotation || {};
+ this._computeProperties();
+}
+
+CTFailureGroup.prototype.snoozeUntil = function(time) {
+ return this._annotate({
+ snoozeTime: time,
+ });
+};
+
+CTFailureGroup.prototype.unsnooze = function() {
+ return this._annotate({
+ snoozeTime: undefined,
+ });
+};
+
+CTFailureGroup.prototype._computeProperties = function() {
+ this.isSnoozed = Date.now() < this.annotation.snoozeTime;
+};
+
+CTFailureGroup.prototype._annotate = function(newAnnotation) {
+ // FIXME: Post the new annotation to frontend rather than storing locally.
+ return CTFailureGroup.fetchAnnotations().then(function(annotations) {
+ var annotation = annotations[this.key] || {};
+
+ Object.keys(newAnnotation).forEach(function(key) {
ojan 2014/08/07 00:09:57 Nit: The sugarjs Object.keys takes a callback func
dstockwell 2014/08/11 01:20:42 Done.
+ var value = newAnnotation[key];
+ if (typeof value == 'undefined') {
ojan 2014/08/07 00:09:58 Nit: I'd just do: if (value === undefined) ... e
dstockwell 2014/08/11 01:20:42 Done.
+ delete annotation[key];
+ } else {
+ annotation[key] = value;
+ }
+ });
+
+ if (Object.keys(annotation).length == 0) {
ojan 2014/08/07 00:09:57 sugarjs has Object.size. So this can just be if (O
dstockwell 2014/08/11 01:20:42 Done.
+ delete annotations[this.key];
+ } else {
+ annotations[this.key] = annotation;
+ }
+
+ localStorage.CTFailureGroupAnnotations = JSON.stringify(annotations);
+
+ this.annotation = annotation;
+ this._computeProperties();
+ }.bind(this));
+};
+
+CTFailureGroup.fetchAnnotations = function() {
+ // FIXME: Fetch annotations from frontend.
+ var stored = localStorage.CTFailureGroupAnnotations;
+ var annotations = stored ? JSON.parse(stored) : {};
+ return Promise.resolve(annotations);
+};
+</script>

Powered by Google App Engine
This is Rietveld 408576698