Bug 1173842 - Embed trychooser into mozreview; r?davidwalsh
MozReview-Commit-ID: Az9qbRACXmA
--- a/pylib/mozreview/mozreview/hostingservice/hmo_repository.py
+++ b/pylib/mozreview/mozreview/hostingservice/hmo_repository.py
@@ -21,16 +21,23 @@ class HMORepositoryForm(HostingServiceFo
try_repository_url = forms.CharField(
label=_('Try Repository URL'),
max_length=255,
required=False,
widget=forms.TextInput(attrs={'size': '60'}),
help_text=_('URL for associated Try repository (if any)'))
+ trychooser_url = forms.CharField(
+ label=_('Trychooser URL'),
+ max_length=255,
+ required=False,
+ widget=forms.TextInput(attrs={'size': '60'}),
+ help_text=_('URL for associated trychooser page (if any)'))
+
autolanding_enabled = forms.BooleanField(
initial=False,
label=_('Autoland to landing repository'),
required=False,
help_text=_('Allow Autolanding to landing repository'))
landing_repository_url = forms.CharField(
label=_('Autoland Repository URL'),
@@ -60,16 +67,17 @@ class HMORepository(HostingService):
supports_repositories = True
form = HMORepositoryForm
supported_scmtools = ['Mercurial']
repository_fields = {
'Mercurial': {
'path': '%(repository_url)s',
'try_repository_url': '%(try_repository_url)s',
+ 'trychooser_url': '%(trychooser_url)s',
'landing_repository_url': '%(landing_repository_url)s',
'landing_bookmark': '%(landing_bookmark)s',
'required_ldap_group': '%(required_ldap_group)s',
},
}
def check_repository(self, *args, **kwargs):
return True
--- a/pylib/mozreview/mozreview/static/mozreview/css/review.less
+++ b/pylib/mozreview/mozreview/static/mozreview/css/review.less
@@ -70,16 +70,21 @@
}
}
.mozreview-autoland-try-chooser-element {
margin-bottom: 5px;
margin-top: 5px;
}
+#mozreview-trychooser-iframe {
+ width: 100%;
+ height: 200pt;
+}
+
label[for="mozreview-autoland-try-syntax"] {
font-weight: bold;
}
#mozreview-autoland-try-syntax {
width: 100%;
height: 8ch;
box-sizing: border-box;
--- a/pylib/mozreview/mozreview/static/mozreview/js/autoland.js
+++ b/pylib/mozreview/mozreview/static/mozreview/js/autoland.js
@@ -1,16 +1,17 @@
$(document).on("mozreview_ready", function() {
// TODO: Stop hardcoding endpoint urls and provide them in a template.
var TRY_AUTOLAND_URL = "/api/extensions/mozreview.extension.MozReviewExtension/try-autoland-triggers/";
var AUTOLAND_URL = "/api/extensions/mozreview.extension.MozReviewExtension/autoland-triggers/";
var COMMIT_REWRITE_URL = "/api/extensions/mozreview.extension.MozReviewExtension/commit_rewrite/";
var try_trigger = $("#autoland-try-trigger");
var autoland_trigger = $("#autoland-trigger");
+ var trychooser_url = $('#repository').data('trychooser-url') || "";
function show_error(error_text) {
$("#activity-indicator")
.addClass("error")
.text('')
.append(
$('<div/>').text(gettext('An error occurred:'))
)
@@ -49,20 +50,35 @@
.keypress(function(e) {
e.stopPropagation();
});
box.width("60em");
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. <a href="http://trychooser.pub.build.mozilla.org/" target="_blank">You can graphically build TryChooser syntax here.</a></p>',
- '<span id="try-syntax-error">You have an error in your try syntax</span>'
+ '<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>',
];
+ 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 {
+ $('#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"/>')
--- a/pylib/mozreview/mozreview/templates/mozreview/repository.html
+++ b/pylib/mozreview/mozreview/templates/mozreview/repository.html
@@ -1,7 +1,8 @@
{% load mozreview %}
<div id="repository"
data-required-ldap-group="{{ review_request.repository|required_ldap_group }}"
+ data-trychooser-url="{{ review_request.repository|trychooser_url }}"
data-autolanding-to-try-enabled="{{ review_request.repository|autolanding_to_try_enabled }}"
data-autolanding-enabled="{{ review_request.repository|autolanding_enabled }}"
data-landing-repository="{{ review_request.repository|landing_repository }}">
</div>
--- a/pylib/mozreview/mozreview/templatetags/mozreview.py
+++ b/pylib/mozreview/mozreview/templatetags/mozreview.py
@@ -97,16 +97,22 @@ def autolanding_enabled(repository):
@register.filter()
def landing_repository(repository):
try:
return repository.extra_data['landing_repository_url']
except (AttributeError, KeyError):
return ''
+@register.filter()
+def trychooser_url(repository):
+ try:
+ return repository.extra_data['trychooser_url']
+ except (AttributeError, KeyError):
+ return ''
@register.filter()
def treeherder_repo(landing_url):
mapping = {
'try': 'try',
'ssh://hg.mozilla.org/try': 'try',
'ssh://hg.mozilla.org/projects/cedar': 'cedar',
'ssh://hg.mozilla.org/integration/mozilla-inbound': 'mozilla-inbound',