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

Side by Side Diff: go/src/infra/appengine/sheriff-o-matic/elements/som-app.html

Issue 2089493002: SOM: Fix key bug (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Changed _keyForAlert() to just alert.key Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <link rel="import" href="/bower_components/polymer/polymer.html"> 1 <link rel="import" href="/bower_components/polymer/polymer.html">
2 <link rel="import" href="/bower_components/iron-ajax/iron-ajax.html"> 2 <link rel="import" href="/bower_components/iron-ajax/iron-ajax.html">
3 <link rel="import" href="/bower_components/iron-flex-layout/classes/iron-flex-la yout.html"> 3 <link rel="import" href="/bower_components/iron-flex-layout/classes/iron-flex-la yout.html">
4 <link rel="import" href="/bower_components/iron-icons/hardware-icons.html"> 4 <link rel="import" href="/bower_components/iron-icons/hardware-icons.html">
5 <link rel="import" href="/bower_components/iron-icon/iron-icon.html"> 5 <link rel="import" href="/bower_components/iron-icon/iron-icon.html">
6 <link rel="import" href="/bower_components/iron-icons/iron-icons.html"> 6 <link rel="import" href="/bower_components/iron-icons/iron-icons.html">
7 <link rel="import" href="/bower_components/iron-location/iron-location.html"> 7 <link rel="import" href="/bower_components/iron-location/iron-location.html">
8 <link rel="import" href="/bower_components/iron-pages/iron-pages.html"> 8 <link rel="import" href="/bower_components/iron-pages/iron-pages.html">
9 <link rel="import" href="/bower_components/neon-animation/animations/scale-up-an imation.html"> 9 <link rel="import" href="/bower_components/neon-animation/animations/scale-up-an imation.html">
10 <link rel="import" href="/bower_components/neon-animation/animations/fade-out-an imation.html"> 10 <link rel="import" href="/bower_components/neon-animation/animations/fade-out-an imation.html">
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 if (!annotationsJson) { 447 if (!annotationsJson) {
448 return annotations; 448 return annotations;
449 } 449 }
450 annotationsJson.forEach(function(annotation) { 450 annotationsJson.forEach(function(annotation) {
451 annotations[annotation.key] = annotation; 451 annotations[annotation.key] = annotation;
452 }); 452 });
453 return annotations; 453 return annotations;
454 }, 454 },
455 455
456 _computeAnnotation: function(annotations, alert) { 456 _computeAnnotation: function(annotations, alert) {
457 let key = this._keyForAlert(alert); 457 let key = alert.key;
458 458
459 let ann = annotations[key]; 459 let ann = annotations[key];
460 return { 460 return {
461 key: key, 461 key: key,
462 snoozed: ann && ann.snoozeTime ? Date.now() < ann.snoozeTime : false, 462 snoozed: ann && ann.snoozeTime ? Date.now() < ann.snoozeTime : false,
463 bugs: ann && ann.bugs, 463 bugs: ann && ann.bugs,
464 }; 464 };
465 }, 465 },
466 466
467 _handleAnnotation: function(evt) { 467 _handleAnnotation: function(evt) {
468 this._sendAnnotation( 468 this._sendAnnotation(
469 this._keyForAlert(evt.model.alert), evt.detail.type, 469 evt.model.alert.key, evt.detail.type,
470 evt.detail.change); 470 evt.detail.change);
471 }, 471 },
472 472
473 _postResponse: function(evt) { 473 _postResponse: function(evt) {
474 let response = evt.detail.response; 474 let response = evt.detail.response;
475 let annotations = this.annotations; 475 let annotations = this.annotations;
476 annotations[response.key] = response; 476 annotations[response.key] = response;
477 let newArray = []; 477 let newArray = [];
478 Object.keys(annotations).forEach(function(k) { 478 Object.keys(annotations).forEach(function(k) {
479 newArray.push(annotations[k]); 479 newArray.push(annotations[k]);
480 }); 480 });
481 this.annotationsJson = newArray; 481 this.annotationsJson = newArray;
482 }, 482 },
483 483
484 _sendAnnotation: function(key, type, change) { 484 _sendAnnotation: function(key, type, change) {
485 this.$.annotationPost.body = JSON.stringify(change); 485 this.$.annotationPost.body = JSON.stringify(change);
486 this.$.annotationPost.url = '/api/v1/annotations/' + key + '/' + type; 486 this.$.annotationPost.url = '/api/v1/annotations/' + key + '/' + type;
487 this.$.annotationPost.generateRequest(); 487 this.$.annotationPost.generateRequest();
488 }, 488 },
489 489
490 _keyForAlert: function(alert) {
491 if (alert.extension && alert.extension.reasons &&
492 alert.extension.builders) {
493 return alert.extension.reasons.map(function(reason) {
494 return reason.step;
495 }).concat(alert.extension.builders.map(function(builder) {
496 return builder.name;
497 })).join('::');
498 }
499 return null;
500 },
501
502 ////////////////////// Bugs /////////////////////////// 490 ////////////////////// Bugs ///////////////////////////
503 491
504 _handleLinkBug: function(evt) { 492 _handleLinkBug: function(evt) {
505 this._bugModel = evt.model.alert; 493 this._bugModel = evt.model.alert;
506 // TODO(martiniss): make this link be customized per builder 494 // TODO(martiniss): make this link be customized per builder
507 this.$.fileBugLink.href = "https://crbug.com/new"; 495 this.$.fileBugLink.href = "https://crbug.com/new";
508 this.$.bugDialog.open(); 496 this.$.bugDialog.open();
509 }, 497 },
510 498
511 _fileBugClicked: function() { 499 _fileBugClicked: function() {
512 this._filedBug = true; 500 this._filedBug = true;
513 }, 501 },
514 502
515 _closeBugDialog: function() { 503 _closeBugDialog: function() {
516 this.$.bugDialog.close(); 504 this.$.bugDialog.close();
517 }, 505 },
518 506
519 _saveBug: function() { 507 _saveBug: function() {
520 this._sendAnnotation( 508 this._sendAnnotation(
521 this._keyForAlert(this._bugModel), 'add', { 509 this._bugModel.key, 'add', {
522 bugs: [this.$.bug.value] 510 bugs: [this.$.bug.value]
523 }); 511 });
524 }, 512 },
525 513
526 ////////////////////// Snooze /////////////////////////// 514 ////////////////////// Snooze ///////////////////////////
527 515
528 _handleSnooze: function(evt) { 516 _handleSnooze: function(evt) {
529 this._snoozeModel = evt.model.alert; 517 this._snoozeModel = evt.model.alert;
530 this.$.snoozeTime.value = DEFAULT_SNOOZE_TIME_MIN; 518 this.$.snoozeTime.value = DEFAULT_SNOOZE_TIME_MIN;
531 this.$.snoozeDialog.open(); 519 this.$.snoozeDialog.open();
532 }, 520 },
533 521
534 _closeSnooze: function() { 522 _closeSnooze: function() {
535 this.$.snoozeDialog.close(); 523 this.$.snoozeDialog.close();
536 }, 524 },
537 525
538 _snooze: function() { 526 _snooze: function() {
539 this._sendAnnotation( 527 this._sendAnnotation(
540 this._keyForAlert(this._snoozeModel), 'add', { 528 this._snoozeModel.key, 'add', {
541 snoozeTime: Date.now() + ONE_MIN_MS * this.$.snoozeTime.value 529 snoozeTime: Date.now() + ONE_MIN_MS * this.$.snoozeTime.value
542 }); 530 });
543 }, 531 },
544 532
545 }); 533 });
546 })(); 534 })();
547 </script> 535 </script>
548 </dom-module> 536 </dom-module>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698