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

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: Rebase. 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
« no previous file with comments | « no previous file | Tools/GardeningServer/model/test/ct-failure-group-tests.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..723165866db724a63d327452e9e43c0a487f2dce
--- /dev/null
+++ b/Tools/GardeningServer/model/ct-failure-group.html
@@ -0,0 +1,63 @@
+<!--
+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, function(key, value) {
+ if (value === 'undefined') {
+ delete annotation[key];
+ } else {
+ annotation[key] = value;
+ }
+ });
+
+ if (Object.size(annotation) == 0) {
+ annotations[this.key] = annotation;
+ } else {
+ delete annotations[this.key];
+ }
+
+ 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>
« no previous file with comments | « no previous file | Tools/GardeningServer/model/test/ct-failure-group-tests.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698