blob: 931dcbcb1faf1b9949c84d23d6ec0e81bab09fb9 [file] [log] [blame]
<!--
The res/js/status.js file must be included before this file.
This in an HTML Import-able file that contains the definition
of the following elements:
<commits-table-sk>
This element renders the status table. It includes a UI to filter the table by builder group
(e.g. Interesting, Comments, etc), a UI to type in a search term to filter the builders by, and
a way to change if the author name or commit subject should be displayed. It is important
to note that the filtering of the data does not happen here, it happens in commits-data-sk.
To use this file import it:
<link href="/res/imp/commits-table-sk.html" rel="import" />
Usage:
<commits-table-sk></commits-table-sk>
Properties:
// inputs
build_details: Object, a map of commit hash to an object that has the build results by builder.
builders: Object, a map of the builder names to an object that has, among other things, category, subcategory, comments and master.
builds: Object, a map of the builder names to an object that maps build numbers to build results.
categories: Object, a map of the builder categories to an object that has the subcategories and the colspan (total number of included builders).
category_list: Array<String>, an array of the builder category names.
commits: Array<Object>, the commit objects, in chronological detail.
commits_map: Object, a map of commit hash to commit objects.
highlighted_commit_hashes: Array<String>, the commit hashes which should be highlighted.
logged_in: Boolean, if the links should be for internal or external buildbot pages.
num_builders: Number, the number of builders with data, after filtering.
relanded_map: Object, a map of a commit hash that was relanded to the commit hash that relands it.
repo: String, the current repo. Used to direct comments to the right place.
repo_base: The base URL for commits. Commit hashes will be appended to this.
reverted_map: Object, a map of a commit hash that was relanded to the commit hash that relands it.
// outputs
commit_label: String, "author" or "subject", which indicates what info should be displayed about a commit.
drawing: Boolean, if the table is being drawn.
filter: String, the builder filter to be used.
search: String, the string to be used if filter is "search".
Methods:
None.
Events:
None.
-->
<link rel="import" href="/res/imp/bower_components/iron-icons/iron-icons.html">
<link rel="import" href="/res/imp/bower_components/iron-icons/communication-icons.html">
<link rel="import" href="/res/imp/bower_components/iron-icons/image-icons.html">
<link rel="import" href="/res/imp/bower_components/paper-button/paper-button.html">
<link rel="import" href="/res/imp/bower_components/paper-dialog/paper-dialog.html">
<link rel="import" href="/res/imp/bower_components/paper-input/paper-input.html">
<link rel="import" href="/res/imp/bower_components/paper-radio-group/paper-radio-group.html">
<link rel="import" href="/res/imp/bower_components/paper-radio-button/paper-radio-button.html">
<link rel="import" href="/res/common/imp/confirm-dialog-sk.html">
<link rel="import" href="commits-table-d3-sk.html">
<dom-module id="commits-table-sk">
<template>
<style>
/*Hide scrollbar on filter wrapper*/
#filterWrapper::-webkit-scrollbar {
height: 0px;
}
#filterWrapper {
overflow-x: auto;
}
.filters{
font-size: .75em;
height: 50px;
min-width: 950px;
max-width: 1250px;
}
div.tooltip {
padding-right: 12px;
display:inline-block;
}
#builderTextFilter {
max-width:144px;
display:inline-block;
--paper-input-container-label: {
font-size:0.75em;
};
}
/* Depending on if the subject or author is being shown, we may need more or less space.*/
#buildbotSelector.near {
margin-left: 80px;
}
#buildbotSelector.far {
margin-left: 380px;
}
.helpicon {
width: 12px;
height: 12px;
vertical-align: top;
}
paper-radio-group {
--paper-radio-group-item-padding: 2px;
}
:host {
/* prevent the comments-sk from making the popup super wide or super narrow*/
--comments-sk-style: {
max-width: 1200px;
min-width: 300px;
};
}
a.nodecorate {
color: #000000;
text-decoration: none;
}
</style>
<confirm-dialog-sk id="confirm_dialog"></confirm-dialog-sk>
<div>
<div id="filterWrapper">
<div class="filters">
<paper-radio-group id="commitLabelSelector" selected="{{commit_label}}">
<template is="dom-repeat" items="{{_commit_labels}}" as="label">
<paper-radio-button name="{{label}}">{{_getPrettyCommitLabel(label)}}</paper-radio-button><br/>
</template>
</paper-radio-group>
<paper-radio-group id="buildbotSelector" class$="{{_getLeftAlign(commit_label)}}" selected="{{filter}}">
<template is="dom-repeat" items="{{_short_filters}}" as="filter">
<paper-radio-button name="{{filter}}">{{_getPrettyFilterLabel(filter)}}</paper-radio-button>
<div class="tooltip" title$="{{_getPrettyFilterText(filter)}}">
<iron-icon icon="icons:help" class="helpicon"></iron-icon>
</div>
</template>
<paper-radio-button name="search"></paper-radio-button>
</paper-radio-group>
<paper-input
id="builderTextFilter"
value="{{search}}"
label="Filter builder"
on-change="_setFilterToSearch"
no-label-float>
</paper-input>
<div class="tooltip" title$="{{_getPrettyFilterText('search')}}">
<iron-icon icon="icons:help" class="helpicon"></iron-icon>
</div>
<a href$="{{_trigger_job_url}}" target="_blank" class="nodecorate" rel="noopener">
<paper-button raised>
<iron-icon icon="icons:add"></iron-icon>
Trigger a Job
</paper-button>
</a>
<paper-button raised on-click="_retryPurpleBuilds">
<iron-icon icon="icons:autorenew"></iron-icon>
Re-Run Purple Jobs
</paper-button>
<paper-dialog id="triggered_jobs_dialog" modal>
<h2>Triggered Jobs</h2>
<template is="dom-repeat" items="[[_triggered_jobs]]">
<p>
<a href$="[[task_scheduler_url]]/job/[[item]]" target="_blank" rel="noopener">[[item]]</a>
</p>
</template>
<paper-button dialog-confirm id="confirm_button" autofocus>Dismiss</paper-button>
</paper-dialog>
</div>
</div>
<commits-table-d3-sk
builders="[[builders]]"
builds="[[builds]]"
categories="[[categories]]"
category_list="[[category_list]]"
build_details="[[build_details]]"
commit_label="[[commit_label]]"
commits="[[commits]]"
commits_map="[[commits_map]]"
highlighted_commit_hashes="[[highlighted_commit_hashes]]"
logged_in="[[logged_in]]"
num_builders="[[num_builders]]"
relanded_map="[[relanded_map]]"
repo="[[repo]]"
repo_base="[[repo_base]]"
reverted_map="[[reverted_map]]"
time_points="[[time_points]]"
drawing="{{drawing}}">
</commits-table-d3-sk>
</div>
</template>
<script>
(function(){
var PRETTY_COMMIT_LABELS = {
"author": "Author",
"subject": "Subject",
};
var PRETTY_FILTER_LABELS = {
"interesting": ["Interesting", "Bots which have both successes and failures within the visible commit window."],
"failures": ["Failures", "Bots which have failures within the visible commit window."],
"comments": ["Comments", "Bots which have comments."],
"nocomment": ["Failing w/o comment", "Bots which have failures within the visible commit window but have no comments."],
"all": ["All", "Display all bots."],
"search": [" ", "Enter a search string. Substrings and regular expressions may be used, per the Javascript String match() rules."],
};
Polymer({
is: "commits-table-sk",
properties: {
// inputs from data source to render.
builders: {
type: Object,
},
categories: {
type: Object,
},
category_list: {
type: Array,
},
build_details: {
type: Object,
},
builds: {
type: Object,
},
commits: {
type: Array,
},
commits_map: {
type: Object,
},
highlighted_commit_hashes: {
type: Array,
},
logged_in: {
type: Boolean,
},
num_builders: {
type: Number,
},
purple_builds: {
type: Array,
},
relanded_map: {
type: Object,
},
repo: {
type: String,
},
repo_base: {
type: String,
},
reverted_map: {
type: Object,
},
task_scheduler_url: {
type: String,
},
time_points: {
type: Object,
},
// outputs (from UI elements)
commit_label: {
type: String,
notify:true,
},
drawing: {
type: Boolean,
notify: true,
},
filter: {
type: String,
notify: true,
},
search: {
type: String,
notify:true,
},
// private
_commit_labels: {
type: Array,
value: function(){
return ["author", "subject"];
}
},
_short_filters: {
type: Array,
value: function(){
// "search" is omitted because it is drawn seperately, being a paper-input and all.
return ["interesting","failures","comments","nocomment","all"];
}
},
_trigger_job_url: {
type: String,
computed: "_getTriggerJobUrl(task_scheduler_url)",
},
_triggered_jobs: {
type: Array,
value: function() {
return [];
},
},
},
_getPrettyCommitLabel: function(key) {
return PRETTY_COMMIT_LABELS[key];
},
_getPrettyFilterLabel: function(key) {
// index 0 is the short name, index 1 is the description
return PRETTY_FILTER_LABELS[key][0];
},
_getPrettyFilterText: function(key) {
// index 0 is the short name, index 1 is the description
return PRETTY_FILTER_LABELS[key][1];
},
_getTriggerJobUrl: function() {
return this.task_scheduler_url + "/trigger";
},
_retryPurpleBuilds: function() {
var msg = "This will trigger " + this.purple_builds.length + " jobs. Proceed?";
$$$('confirm-dialog-sk').open(msg).then(function() {
var url = this.task_scheduler_url + "/json/trigger";
var body = JSON.stringify(this.purple_builds);
sk.post(url, body, null, true).then(JSON.parse).then(function(jobIds) {
this.set("_triggered_jobs", jobIds);
this.$.triggered_jobs_dialog.open();
}.bind(this), function(err) {
sk.errorMessage("Failed to trigger tasks: " + err);
});
}.bind(this), function(){});
},
_setFilterToSearch: function() {
this.set("filter","search");
},
_getLeftAlign: function(commit_label) {
if (commit_label == "author") {
return "near";
}
return "far";
}
});
})()
</script>
</dom-module