Bug 1228311 - Remember last try syntax used for a review; r?smacleod
MozReview-Commit-ID: 87dGz6I0Jdh
--- a/pylib/mozreview/mozreview/hooks.py
+++ b/pylib/mozreview/mozreview/hooks.py
@@ -62,39 +62,42 @@ class CommitContextTemplateHook(Template
cur_index = children_details.index(review_request_details)
current_child_num = cur_index + 1
next_child = (children_details[cur_index + 1]
if cur_index + 1 < n_children else None)
prev_child = (children_details[cur_index - 1]
if cur_index - 1 >= 0 else None)
latest_autoland_requests = []
+ try_syntax = ''
repo_urls = set()
autoland_requests = AutolandRequest.objects.filter(
review_request_id=parent.id).order_by('-autoland_id')
# We would like to fetch the latest AutolandRequest for each
# different repository.
for request in autoland_requests:
if request.repository_url in repo_urls:
continue
repo_urls.add(request.repository_url)
latest_autoland_requests.append(request)
+ try_syntax = try_syntax or request.extra_data.get('try_syntax', '')
return {
'review_request_details': review_request_details,
'parent_details': parent_details,
'children_details': children_details,
'num_children': n_children,
'current_child_num': current_child_num,
'next_child': next_child,
'prev_child': prev_child,
'latest_autoland_requests': latest_autoland_requests,
'user': user,
+ 'try_syntax': 'try_syntax',
}
class MozReviewApprovalHook(ReviewRequestApprovalHook):
"""Calculates landing approval for review requests.
This hook allows us to control the `approved` and `approval_failure`
fields on review request model instances, and Web API results
associated with them. By calculating landing approval and returning
--- a/pylib/mozreview/mozreview/static/mozreview/js/autoland.js
+++ b/pylib/mozreview/mozreview/static/mozreview/js/autoland.js
@@ -55,34 +55,51 @@
var html = [
'<label for="mozreview-autoland-try-syntax">TryChooser Syntax</label>',
'<textarea id="mozreview-autoland-try-syntax" name="mozreview-autoland-try-syntax" placeholder="try: -b do -p win32 -u all -t none"/>',
'<p>Enter TryChooser syntax here for your Try build.</p>',
'<p><span id="try-syntax-error">You have an error in your try syntax</span></p>',
'<p><details id="mozreview-open-try"><summary>Graphically build syntax</summary><p><iframe id="mozreview-trychooser-iframe" src="' + trychooser_url + '"/></p></details></p>',
];
+
+ var oldTrySyntax = $('#ci-actions').data('try-syntax');
+
+ if (oldTrySyntax !== undefined) {
+ box.find('#mozreview-autoland-try-syntax').val(oldTrySyntax);
+ }
+
+ box.find('#mozreview-autoland-try-syntax').on('change', function () {allowReset = true});
+
+ // in case there was no previous try push, allow the trychooser to reset
+ // the try syntax. Else, wait for it to be changed
+ var allowReset = oldTrySyntax === undefined || oldTrySyntax === "";
if (trychooser_url === "") {
html.pop();
} else {
window.onmessage = function(e) {
if (e.origin === new URL(trychooser_url).origin) {
if (e.data != "") {
$('#mozreview-autoland-try-syntax').val("try: " + e.data)
- } else {
+ } else if (allowReset) {
+ // We only reset the value if it has been changed since
+ // This prevents the first load of the page from overriding
+ // the try syntax input
$('#mozreview-autoland-try-syntax').val("")
}
}
}
}
for (var i = 0; i < html.length; ++i) {
box.append($(html[i]).addClass("mozreview-autoland-try-chooser-element"));
}
+
+
box.modalBox({
title: "Trigger a Try Build",
buttons: [
$('<input type="button"/>')
.val(gettext("Cancel")),
$('<input type="button"/>')
.val("Submit")
.click(function() {
--- a/pylib/mozreview/mozreview/templates/mozreview/commits.html
+++ b/pylib/mozreview/mozreview/templates/mozreview/commits.html
@@ -40,17 +40,17 @@ This is the template for the "Commits" l
{% if parent_details.get_review_request.id == review_request_details.get_review_request.id %}
• <a href="{{parent_details.get_review_request.get_absolute_url}}diff/#index_header">Squashed Diff</a>
{% endif %}
</div>
{% include 'mozreview/commits-requests.html' %}
{% if latest_autoland_requests %}
- <div id="ci-actions">
+ <div id="ci-actions" data-try-syntax="{{try_syntax}}">
{% for autoland_request in latest_autoland_requests %}
{% if not forloop.first %}
<div class="action-separator"></div>
{% endif %}
{% if autoland_request.last_known_status == 'P' %}
<div class="action action-failure">
<div class="action-icon rounded-icon"></div>