launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #07422
[Merge] lp:~sinzui/launchpad/progressive-enhancement-ftw-2 into lp:launchpad
Curtis Hovey has proposed merging lp:~sinzui/launchpad/progressive-enhancement-ftw-2 into lp:launchpad with lp:~sinzui/launchpad/progressive-enhancement-ftw as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~sinzui/launchpad/progressive-enhancement-ftw-2/+merge/103970
Pre-implementation: wgrant
Several features fail for less common browsers because noscript is used
for the default markup. When progressive enhancement fails, there is no
default markup to fallback to. YUI assumes progressive enhancement works.
Over the last 3 years, we have seen IE, Opera, Konquorer and Firefox 3
break because progressive enhancement failed without fallback.
The branch completes the removal of noscript by updating Code and
Translations.
--------------------------------------------------------------------
RULES
* Remove all uses of noscript that interact with YUI.
QA
# This page times out in production
* Visit https://code.qastaging.launchpad.net/+daily-builds
* Verify the js browser filters the branches when the select field
is changed.
* Verify the non-js browser shows the Filter button and submit it changes
the listed branches.
* Visit https://code.qastaging.launchpad.dev/pocket-lint/
* Verify that the branch listing updates when the status and sort fields
change in the js browser.
* Verify the non-js browser shows the Filter button and submit it changes
the listed branches.
* https://code.qastaging.launchpad.net/pocket-lint/+merges
* Verify that the branch listing updates when the status field
changes in the js browser.
* Verify the non-js browser shows the Filter button and submit it changes
the listed branches.
* Visit https://code.qastaging.launchpad.net/~vcs-imports/v8/trunk-svn
* Verify the Retry button does not appear under Import details in
the js browser; there is a retry link with a sprite.
* Verify the Retry button appears under Import details the in
non-js browser.
* Visit https://code.qastaging.launchpad.net/~sinzui/+recipe/pocket-lint-daily
* Verify the Build Now button does not appear under Build Schedule in
the js browser.
* Verify the Build Now button appears under Build Schedule in the
non-js browser.
* Visit https://translations.qastaging.launchpad.net/gdp/0.5.x/+pots/gedit-developer-plugins/es/+export
* Verify the checkbox under format does not have the italic
"PO format only:" text in the js browser.
* Verify the italic text "PO format only:" appears below the checkbox
in the non-js browser.
* Visit https://translations.launchpad.net/+imports
* Verify the statuses are choice links in the js-browser.
* Verify the statuses are select widgets in the non-js browser and
that there is a submit button below the listing.
LINT
lib/lp/code/javascript/requestbuild_overlay.js
lib/lp/code/javascript/tests/test_requestbuild_overlay.html
lib/lp/code/javascript/tests/test_requestbuild_overlay.js
lib/lp/code/javascript/tests/test_util.html
lib/lp/code/javascript/tests/test_util.js
lib/lp/code/javascript/util.js
lib/lp/code/templates/branch-import-details.pt
lib/lp/code/templates/branch-listing.pt
lib/lp/code/templates/branchmergeproposal-generic-listing.pt
lib/lp/code/templates/daily-builds-listing.pt
lib/lp/code/templates/sourcepackagerecipe-index.pt
lib/lp/translations/javascript/importqueue.js
lib/lp/translations/templates/pofile-export.pt
lib/lp/translations/templates/translation-import-queue-macros.pt
lib/lp/translations/javascript/tests/test_importqueue.html
lib/lp/translations/javascript/tests/test_importqueue.js
TEST
./bin/test -vvc --layer=YUITest lp.code
./bin/test -vvc --layer=YUITest lp.translations
IMPLEMENTATION
Added A new method to requestbuild_overlay to hide/show parts of the
build schedule when the page is setup. This was the only inline script
in the page...all the rest of the page was represented in the module
with tests. Adding a new testcase for my small change was frustrating, I
discovered that the existing tests were not cleaning up. I updated the
existing tests to tearDown to prevent duplicate ids from occurring. I
also simplified the setups to use a template.
lib/lp/code/javascript/requestbuild_overlay.js
lib/lp/code/javascript/tests/test_requestbuild_overlay.html
lib/lp/code/javascript/tests/test_requestbuild_overlay.js
lib/lp/code/templates/sourcepackagerecipe-index.pt
Replaced inline filter-listing-on-change behaviours with a module that
uses common code to support the common behaviour. I added a new YUI test
for all the methods that I changed to added.
lib/lp/code/javascript/tests/test_util.html
lib/lp/code/javascript/tests/test_util.js
lib/lp/code/javascript/util.js
lib/lp/code/templates/branch-import-details.pt
lib/lp/code/templates/branch-listing.pt
lib/lp/code/templates/branchmergeproposal-generic-listing.pt
lib/lp/code/templates/daily-builds-listing.pt
I updated the page's inline script to hide the PO format only message. I
choose not to test this because the text does not offer functionality.
lib/lp/translations/templates/pofile-export.pt
Updated Y.lp.translations.importqueue.initialize_import_queue_page() to
hide the html form selects and inputs that were hidden by noscript. I added
a YUI test. The html harness is huge :(
lib/lp/translations/templates/translation-import-queue-macros.pt
lib/lp/translations/javascript/importqueue.js
lib/lp/translations/javascript/tests/test_importqueue.html
lib/lp/translations/javascript/tests/test_importqueue.js
--
https://code.launchpad.net/~sinzui/launchpad/progressive-enhancement-ftw-2/+merge/103970
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~sinzui/launchpad/progressive-enhancement-ftw-2 into lp:launchpad.
=== modified file 'lib/lp/code/javascript/requestbuild_overlay.js'
--- lib/lp/code/javascript/requestbuild_overlay.js 2012-03-14 12:53:47 +0000
+++ lib/lp/code/javascript/requestbuild_overlay.js 2012-04-28 03:27:31 +0000
@@ -48,6 +48,21 @@
namespace.RequestResponseHandler = RequestResponseHandler;
+
+namespace.hookUpDailyBuildsSchedule = function() {
+ var logged_in = LP.links.me !== undefined;
+ if (logged_in) {
+ build_now_link = Y.one('#request-daily-build');
+ if( build_now_link !== null ) {
+ build_now_link.removeClass('unseen');
+ Y.lp.code.requestbuild_overlay.connect_requestdailybuild();
+ }
+ Y.lp.code.requestbuild_overlay.connect_requestbuilds();
+ }
+ Y.one('#request-daily-build-form').addClass('unseen');
+};
+
+
namespace.connect_requestbuilds = function(config) {
var io_provider = Y.lp.client.get_configured_io_provider(config),
request_build_handle = Y.one('#request-builds');
=== modified file 'lib/lp/code/javascript/tests/test_requestbuild_overlay.html'
--- lib/lp/code/javascript/tests/test_requestbuild_overlay.html 2012-03-14 04:41:36 +0000
+++ lib/lp/code/javascript/tests/test_requestbuild_overlay.html 2012-04-28 03:27:31 +0000
@@ -89,5 +89,21 @@
</div>
</script>
+ <script type="text/x-template" id="build-schedule-template">
+ <form action="+request-daily-build"
+ method="post" id="request-daily-build-form">
+ <input type="submit" name="field.actions.build"
+ id="field.actions.build" value="Build now" />
+ </form>
+ <a id="request-daily-build"
+ class="sprite source-package-recipe js-action unseen"
+ href="+build-now">Build now</a>
+ <div id="builds-target">
+ <div>
+ <a id="request-builds"
+ class="" href="#">Request build(s)</a>
+ </div>
+ </div>
+ </script>
</body>
</html>
=== modified file 'lib/lp/code/javascript/tests/test_requestbuild_overlay.js'
--- lib/lp/code/javascript/tests/test_requestbuild_overlay.js 2011-08-30 13:32:12 +0000
+++ lib/lp/code/javascript/tests/test_requestbuild_overlay.js 2012-04-28 03:27:31 +0000
@@ -18,18 +18,18 @@
LP.cache.context = {
web_link: "http://code.launchpad.dev/~foobar/myrecipe"};
// Prepare testbed.
- var testbed = Y.one("#testbed").set('innerHTML', '');
- testbed.append(
- Y.Node.create('<a></a>')
- .set('id', 'request-daily-build')
- .set('href', '#')
- .addClass('unseen')
- .set('text', 'Build now')
- ).append(
- Y.Node.create('<div></div>')
- .set('id', 'builds-target')
- );
- },
+ fixture = Y.one("#testbed");
+ var template = Y.one('#build-schedule-template').getContent();
+ var test_node = Y.Node.create(template);
+ fixture.append(test_node);
+ },
+
+ tearDown: function() {
+ Y.one("#testbed").empty();
+ LP.cache.context = {};
+ LP.cache.links = {};
+ },
+
_makeRequest: function() {
var mockio = new Y.lp.testing.mockio.MockIo();
@@ -112,22 +112,17 @@
web_link: "http://code.launchpad.dev/~foobar/myrecipe",
self_link: "http://api.launchpad.dev/devel/~foobar/myrecipe"};
// Prepare testbed.
- var testbed = Y.one("#testbed").set('innerHTML', '');
- testbed.append(
- Y.Node.create('<div></div>')
- .set('id', 'builds-target')
- ).append(
- Y.Node.create('<div></div>').append(
- Y.Node.create('<a></a>')
- .set('id', 'request-builds')
- .set('href', '#')
- .set('text', 'Request build(s)')
- )
- );
+ fixture = Y.one("#testbed");
+ var template = Y.one('#build-schedule-template').getContent();
+ var test_node = Y.Node.create(template);
+ fixture.append(test_node);
},
tearDown: function() {
module.destroy_requestbuilds();
+ Y.one("#testbed").empty();
+ LP.cache.context = {};
+ LP.cache.links = {};
},
_makeRequest: function() {
@@ -237,6 +232,42 @@
}
}));
+
+suite.add(new Y.Test.Case({
+ name: "lp.code.requestbuild_overlay.buildschedule",
+
+ setUp: function() {
+ fixture = Y.one("#testbed");
+ var template = Y.one('#build-schedule-template').getContent();
+ var test_node = Y.Node.create(template);
+ fixture.append(test_node);
+ },
+
+ tearDown: function() {
+ Y.one("#testbed").empty();
+ LP.cache.context = {};
+ LP.cache.links = {};
+ },
+
+ test_hookUpDailyBuildsSchedule_anonymous: function() {
+ module.hookUpDailyBuildsSchedule();
+ Y.Assert.isTrue(
+ Y.one('#request-daily-build-form').hasClass('unseen'));
+ Y.Assert.isTrue(
+ Y.one('#request-daily-build').hasClass('unseen'));
+ },
+
+ test_hookUpDailyBuildsSchedule_logged_in_user: function() {
+ LP.links.me = '/~name16';
+ module.hookUpDailyBuildsSchedule();
+ Y.Assert.isTrue(
+ Y.one('#request-daily-build-form').hasClass('unseen'));
+ Y.Assert.isFalse(
+ Y.one('#request-daily-build').hasClass('unseen'));
+ }
+}));
+
+
Y.lp.testing.Runner.run(suite);
});
=== added file 'lib/lp/code/javascript/tests/test_util.html'
--- lib/lp/code/javascript/tests/test_util.html 1970-01-01 00:00:00 +0000
+++ lib/lp/code/javascript/tests/test_util.html 2012-04-28 03:27:31 +0000
@@ -0,0 +1,85 @@
+<!DOCTYPE html>
+<!--
+Copyright 2012 Canonical Ltd. This software is licensed under the
+GNU Affero General Public License version 3 (see the file LICENSE).
+-->
+
+<html>
+ <head>
+ <title>Test requestbuild_overlay</title>
+
+ <!-- YUI and test setup -->
+ <script type="text/javascript"
+ src="../../../../../build/js/yui/yui/yui.js">
+ </script>
+ <link rel="stylesheet"
+ href="../../../../../build/js/yui/console/assets/console-core.css" />
+ <link rel="stylesheet"
+ href="../../../../../build/js/yui/console/assets/skins/sam/console.css" />
+ <link rel="stylesheet"
+ href="../../../../../build/js/yui/test/assets/skins/sam/test.css" />
+
+ <script type="text/javascript"
+ src="../../../../../build/js/lp/app/testing/testrunner.js"></script>
+ <link rel="stylesheet" href="../../../app/javascript/testing/test.css" />
+
+ <!-- The module under test. -->
+ <script type="text/javascript" src="../util.js"></script>
+
+ <!-- The test suite. -->
+ <script type="text/javascript" src="test_util.js"></script>
+ </head>
+ <body class="yui3-skin-sam">
+ <ul id="suites">
+ <li>lp.code.util.test</li>
+ </ul>
+
+ <div id="fixture"></div>
+
+ <script type="text/x-template" id="daily-builds-form">
+ <form name="filter" id="filter_form" action="/+test">
+ <select id="field.when_completed_filter"
+ name="field.when_completed_filter" size="1">
+ <option selected="selected" value="ALL">All</option>
+ <option value="WITHIN_30_DAYS">Recent</option>
+ </select>
+ <input id="filter_form_submit" type="submit" value="Filter"/>
+ </form>
+ </script>
+
+ <script type="text/x-template" id="branch-listing-form">
+ <form name="filter" id="filter_form" action="/+test">
+ <select id="field.lifecycle" name="field.lifecycle" size="1">
+ <option selected="selected" value="ALL">All</option>
+ <option value="Active">Active</option>
+ </select>
+ <select id="field.sort_by" name="field.sort_by" size="1">
+ <option selected="selected" value="NEW">Newest</option>
+ <option value="OLD">Oldest</option>
+ </select>
+ <input id="filter_form_submit" type="submit" value="Filter"/>
+ </form>
+ </script>
+
+ <script type="text/x-template" id="merge-proposal-form">
+ <form name="filter" id="filter_form" action="/+test">
+ <select id="field.status"
+ name="field.status" size="1">
+ <option selected="selected" value="ALL">All</option>
+ <option value="WITHIN_30_DAYS">Recent</option>
+ </select>
+ <input id="filter_form_submit" type="submit" value="Filter"/>
+ </form>
+ </script>
+
+ <script type="text/x-template" id="retry-import-form">
+ <form name="tryagain" id="tryagain" action="/+test">
+ <input type="hidden" name="tryagain.actions.tryagain"
+ value="" />
+ <input type="submit" id="tryagain.actions.tryagain"
+ name="tryagain.actions.tryagain" value="Try Again" />
+ <a class="unseen" id="tryagainlink" href="#">Try again</a>
+ </form>
+ </script>
+ </body>
+</html>
=== added file 'lib/lp/code/javascript/tests/test_util.js'
--- lib/lp/code/javascript/tests/test_util.js 1970-01-01 00:00:00 +0000
+++ lib/lp/code/javascript/tests/test_util.js 2012-04-28 03:27:31 +0000
@@ -0,0 +1,90 @@
+/* Copyright (c) 2012, Canonical Ltd. All rights reserved. */
+
+YUI().use('test', 'console', 'node-event-simulate', 'lp.testing.runner',
+ 'lp.code.util', function(Y) {
+
+var suite = new Y.Test.Suite("lp.code.util Tests");
+var module = Y.lp.code.util;
+
+
+suite.add(new Y.Test.Case({
+ name: "lp.code.util",
+
+ setUp: function() {
+ this.fixture = Y.one("#fixture");
+ this.listener = {event_fired: false};
+ },
+
+ tearDown: function () {
+ if (this.fixture !== null) {
+ this.fixture.empty();
+ }
+ delete this.fixture;
+ },
+
+ _setup_fixture: function(template_selector) {
+ var template =Y.one(template_selector).getContent();
+ var test_node = Y.Node.create(template);
+ this.fixture.append(test_node);
+ },
+
+ _add_submit_listener: function(form_selector) {
+ // prevent submission when the form's method is directly invoked
+ // and record that the methods was called.
+ var listener = this.listener;
+ Y.one(form_selector).submit = function(e) {
+ listener.event_fired = true;
+ e.halt();
+ };
+ },
+
+ test_hookUpDailyBuildsFilterSubmission: function() {
+ this._setup_fixture('#daily-builds-form');
+ module.hookUpDailyBuildsFilterSubmission();
+ this._add_submit_listener('#filter_form');
+ Y.one('[id=field.when_completed_filter]').simulate('change');
+ Y.Assert.isTrue(this.listener.event_fired);
+ Y.Assert.isTrue(
+ Y.one('#filter_form_submit').hasClass('unseen'));
+ },
+
+ test_hookUpBranchFilterSubmission: function() {
+ this._setup_fixture('#branch-listing-form');
+ module.hookUpBranchFilterSubmission();
+ this._add_submit_listener('#filter_form');
+ Y.one('[id=field.lifecycle]').simulate('change');
+ Y.Assert.isTrue(this.listener.event_fired);
+ this.listener.event_fired = false;
+ Y.one('[id=field.sort_by]').simulate('change');
+ Y.Assert.isTrue(this.listener.event_fired);
+ Y.Assert.isTrue(
+ Y.one('#filter_form_submit').hasClass('unseen'));
+ },
+
+ test_hookUpMergeProposalFilterSubmission: function() {
+ this._setup_fixture('#merge-proposal-form');
+ module.hookUpMergeProposalFilterSubmission();
+ this._add_submit_listener('#filter_form');
+ Y.one('[id=field.status]').simulate('change');
+ Y.Assert.isTrue(this.listener.event_fired);
+ Y.Assert.isTrue(
+ Y.one('#filter_form_submit').hasClass('unseen'));
+ },
+
+ test_hookUpRetyImportSubmission: function() {
+ this._setup_fixture('#retry-import-form');
+ module.hookUpRetyImportSubmission();
+ this._add_submit_listener('#tryagain');
+ var try_again_link = Y.one("#tryagainlink");
+ try_again_link.simulate('click');
+ Y.Assert.isTrue(this.listener.event_fired);
+ Y.Assert.isFalse(try_again_link.hasClass('unseen'));
+ Y.Assert.isTrue(
+ Y.one('[id=tryagain.actions.tryagain]').hasClass('unseen'));
+ }
+
+}));
+
+Y.lp.testing.Runner.run(suite);
+
+});
=== modified file 'lib/lp/code/javascript/util.js'
--- lib/lp/code/javascript/util.js 2012-02-07 18:38:52 +0000
+++ lib/lp/code/javascript/util.js 2012-04-28 03:27:31 +0000
@@ -1,7 +1,7 @@
/* Copyright 2012 Canonical Ltd. This software is licensed under the
* GNU Affero General Public License version 3 (see the file LICENSE).
*
- * Control enabling/disabling form elements on the +new-recipe page.
+ * Control enabling/disabling form elements on Code domain pages.
*
* @module Y.lp.code.util
* @requires node
@@ -31,30 +31,44 @@
update_branch_unique_name();
};
+var submit_filter = function (e) {
+ Y.one('#filter_form').submit();
+};
+
var hookUpBranchFilterSubmission = function() {
- var submit_filter = function (e) {
- Y.DOM.byId('filter_form').submit();
- };
-
Y.one("[id='field.lifecycle']").on('change', submit_filter);
var sortby = Y.one("[id='field.sort_by']");
if (Y.Lang.isValue(sortby)) {
sortby.on('change', submit_filter);
}
+ Y.one('#filter_form_submit').addClass('unseen');
};
var hookUpDailyBuildsFilterSubmission = function() {
- var submit_filter = function (e) {
- Y.DOM.byId('filter_form').submit();
- };
-
Y.one("[id='field.when_completed_filter']").on(
'change', submit_filter);
+ Y.one('#filter_form_submit').addClass('unseen');
+};
+
+var hookUpMergeProposalFilterSubmission = function() {
+ Y.one("[id=field.status]").on('change', submit_filter);
+ Y.one('#filter_form_submit').addClass('unseen');
+};
+
+var hookUpRetyImportSubmission = function() {
+ var try_again_link = Y.one("#tryagainlink");
+ try_again_link.on('click', function (e) {
+ Y.one('#tryagain').submit();
+ });
+ try_again_link.removeClass('unseen');
+ Y.one('[id=tryagain.actions.tryagain]').addClass('unseen');
};
ns.hookUpBranchFieldFunctions = hookUpBranchFieldFunctions;
ns.hookUpBranchFilterSubmission = hookUpBranchFilterSubmission;
ns.hookUpDailyBuildsFilterSubmission = hookUpDailyBuildsFilterSubmission;
+ns.hookUpMergeProposalFilterSubmission = hookUpMergeProposalFilterSubmission;
+ns.hookUpRetyImportSubmission = hookUpRetyImportSubmission;
}, "0.1", {"requires": ["node", "dom"]});
=== modified file 'lib/lp/code/templates/branch-import-details.pt'
--- lib/lp/code/templates/branch-import-details.pt 2012-02-01 15:31:32 +0000
+++ lib/lp/code/templates/branch-import-details.pt 2012-04-28 03:27:31 +0000
@@ -16,25 +16,24 @@
<form tal:attributes="action string:${context/fmt:url}/@@+try-again"
tal:condition="python:view.user and code_import.review_status.name == 'FAILING'"
style="display: inline; padding-left: 1em"
+ id="tryagain"
name="tryagain"
method="post"
enctype="multipart/form-data" accept-charset="UTF-8">
- <noscript>
- <img src="/@@/retry" />
- <input id="tryagain.actions.tryagain" name="tryagain.actions.tryagain" value="Try Again" class="button" type="submit" />
- </noscript>
<input
type="hidden"
name="tryagain.actions.tryagain"
value="" />
- <a href="javascript:document.tryagain.submit()" class="hidden" id="tryagainlink">
- <img src="/@@/retry" />
- Try again
- </a>
+ <input type="submit" id="tryagain.actions.tryagain"
+ name="tryagain.actions.tryagain" value="Try Again"
+ class="button" />
+ <a href="#" class="unseen sprite retry"
+ id="tryagainlink">Try again</a>
<script type="text/javascript">
- LPJS.use('event', 'node', function(Y) {
- Y.on("domready", function () { Y.one('#tryagainlink').setStyle('display', 'inline') });
- });
+ LPJS.use('lp.code.util', function(Y) {
+ Y.on("domready", function () {
+ Y.lp.code.util.hookUpRetyImportSubmission(Y);
+ }, window);});
</script>
</form>
</div>
=== modified file 'lib/lp/code/templates/branch-listing.pt'
--- lib/lp/code/templates/branch-listing.pt 2012-02-01 15:31:32 +0000
+++ lib/lp/code/templates/branch-listing.pt 2012-04-28 03:27:31 +0000
@@ -11,9 +11,7 @@
<tal:lifecycle-selector replace="structure context/view/widgets/lifecycle"/>
<tal:sort-by replace="structure context/view/widgets/sort_by"
condition="context/view/widgets/sort_by|nothing"/>
- <noscript>
- <input type="submit" value="Filter"/>
- </noscript>
+ <input id="filter_form_submit" type="submit" value="Filter"/>
</form>
<script type="text/javascript">
=== modified file 'lib/lp/code/templates/branchmergeproposal-generic-listing.pt'
--- lib/lp/code/templates/branchmergeproposal-generic-listing.pt 2012-02-01 15:31:32 +0000
+++ lib/lp/code/templates/branchmergeproposal-generic-listing.pt 2012-04-28 03:27:31 +0000
@@ -18,22 +18,14 @@
Proposals with status:
</label>
<tal:lifecycle-selector replace="structure view/widgets/status"/>
- <noscript>
- <input type="submit" value="Filter"/>
- </noscript>
+ <input id="filter_form_submit" type="submit" value="Filter"/>
</form>
<script type="text/javascript">
-LPJS.use('node', function(Y) {
-
- function submit_filter() {
- Y.one('#filter_form').submit();
- }
- Y.on('domready', function () {
- var field = Y.one("[id=field.status]");
- field.on('change', submit_filter);
- });
-
+LPJS.use("lp.code.util", function(Y) {
+ Y.on("domready", function(e) {
+ Y.lp.code.util.hookUpMergeProposalFilterSubmission(Y);
+ }, window);
});
</script>
=== modified file 'lib/lp/code/templates/daily-builds-listing.pt'
--- lib/lp/code/templates/daily-builds-listing.pt 2012-02-01 15:31:32 +0000
+++ lib/lp/code/templates/daily-builds-listing.pt 2012-04-28 03:27:31 +0000
@@ -23,9 +23,7 @@
class="sprite maybe"
> <span class="invisible-link">Tag help</span></a>build
<tal:build-age-selector replace="structure view/widgets/when_completed_filter"/>
- <noscript>
- <input type="submit" value="Filter"/>
- </noscript>
+ <input id="filter_form_submit" type="submit" value="Filter"/>
</form>
<script type="text/javascript">
=== modified file 'lib/lp/code/templates/sourcepackagerecipe-index.pt'
--- lib/lp/code/templates/sourcepackagerecipe-index.pt 2012-02-01 15:31:32 +0000
+++ lib/lp/code/templates/sourcepackagerecipe-index.pt 2012-04-28 03:27:31 +0000
@@ -92,14 +92,12 @@
tal:define="link context/menu:context/request_daily_build"
tal:condition="link/enabled"
>
- <noscript>
- <form action="+request-daily-build"
- method="post"
- id="request-daily-build-form">
- <input type="submit" name="field.actions.build"
- id="field.actions.build" value="Build now" />
- </form>
- </noscript>
+ <form action="+request-daily-build"
+ method="post"
+ id="request-daily-build-form">
+ <input type="submit" name="field.actions.build"
+ id="field.actions.build" value="Build now" />
+ </form>
<a id="request-daily-build"
class="sprite source-package-recipe js-action unseen"
tal:attributes="href link/url"
@@ -162,16 +160,7 @@
return;
}
Y.on('load', function() {
- var logged_in = LP.links['me'] !== undefined;
- if (logged_in) {
- build_now_link = Y.one('#request-daily-build');
- if( build_now_link != null ) {
- build_now_link.removeClass('unseen');
- Y.lp.code.requestbuild_overlay.connect_requestdailybuild();
- }
- Y.lp.code.requestbuild_overlay.connect_requestbuilds();
-
- }
+ Y.lp.code.requestbuild_overlay.hookUpDailyBuildsSchedule();
}, window);
});
</script>
=== modified file 'lib/lp/translations/javascript/importqueue.js'
--- lib/lp/translations/javascript/importqueue.js 2012-03-02 16:17:46 +0000
+++ lib/lp/translations/javascript/importqueue.js 2012-04-28 03:27:31 +0000
@@ -175,6 +175,10 @@
// Set up status pickers.
Y.all('.status-choice').each(init_status_choice);
+ Y.all('.status-select').each(function(content_box, index, list) {
+ content_box.addClass('hidden');
+ });
+ Y.one('#import-queue-submit').addClass('hidden');
};
}, "0.1", {
=== added file 'lib/lp/translations/javascript/tests/test_importqueue.html'
--- lib/lp/translations/javascript/tests/test_importqueue.html 1970-01-01 00:00:00 +0000
+++ lib/lp/translations/javascript/tests/test_importqueue.html 2012-04-28 03:27:31 +0000
@@ -0,0 +1,110 @@
+<!DOCTYPE html>
+<!--
+Copyright 2012 Canonical Ltd. This software is licensed under the
+GNU Affero General Public License version 3 (see the file LICENSE).
+-->
+
+<html>
+ <head>
+ <title>Test importqueue</title>
+
+ <!-- YUI and test setup -->
+ <script type="text/javascript"
+ src="../../../../../build/js/yui/yui/yui.js">
+ </script>
+ <link rel="stylesheet"
+ href="../../../../../build/js/yui/console/assets/console-core.css" />
+ <link rel="stylesheet"
+ href="../../../../../build/js/yui/console/assets/skins/sam/console.css" />
+ <link rel="stylesheet"
+ href="../../../../../build/js/yui/test/assets/skins/sam/test.css" />
+
+ <script type="text/javascript"
+ src="../../../../../build/js/lp/app/testing/testrunner.js"></script>
+
+ <link rel="stylesheet" href="../../../app/javascript/testing/test.css" />
+
+ <!-- Dependencies -->
+ <script type="text/javascript"
+ src="../../../../../build/js/lp/app/lazr/lazr.js"></script>
+ <script type="text/javascript"
+ src="../../../../../build/js/lp/app/overlay/overlay.js"></script>
+ <script type="text/javascript"
+ src="../../../../../build/js/lp/app/anim/amin.js"></script>
+ <script type="text/javascript"
+ src="../../../../../build/js/lp/app/choiceedit/choiceedit.js"></script>
+ <script type="text/javascript"
+ src="../../../../../build/js/lp/app/client.js"></script>
+ <script type="text/javascript"
+ src="../../../../../build/js/lp/app/errors.js"></script>
+
+ <!-- The module under test. -->
+ <script type="text/javascript" src="../importqueue.js"></script>
+
+ <!-- The test suite. -->
+ <script type="text/javascript" src="test_importqueue.js"></script>
+
+ </head>
+ <body class="yui3-skin-sam">
+ <ul id="suites">
+ <li>lp.translations.importqueue.test</li>
+ </ul>
+
+ <div id="fixture"></div>
+
+ <script type="text/javascript">
+ var choice_confs = [];
+ </script>
+
+ <script type="text/x-template" id="import-queue-listing">
+ <table id="import-entries-list" class="listing">
+ <tr class="import_entry_row" id="1">
+ <td class="import_source">
+ po/evolution-2.2-test.pot in Evolution trunk series
+ </td>
+
+ <td class="import_status">
+ <span class="status-select">
+ <select id="field.status_1" name="field.status_1">
+ <option value="APPROVED">Approved</option>
+ <option selected="selected"
+ value="IMPORTED">Imported</option>
+ </select>
+ </span>
+ <span class="status-choice hidden">
+ <span class="value translationimportstatusIMPORTED">
+ Imported</span>
+ <img class="editicon" src="/@@/edit" />
+ </span>
+ </td>
+ </tr>
+
+ <tr class="import_entry_row" id="2">
+ <td class="import_source">
+ po/pt_BR.po in Evolution trunk series
+ </td>
+
+ <td class="import_status">
+ <span class="status-select">
+ <select id="field.status_2" name="field.status_2">
+ <option value="APPROVED">Approved</option>
+ <option selected="selected"
+ value="IMPORTED">Imported</option>
+ </select>
+ </span>
+ <span class="status-choice hidden">
+ <span class="value translationimportstatusIMPORTED">
+ Imported</span>
+ <img class="editicon" src="/@@/edit" />
+ </span>
+ </td>
+ </tr>
+ </table>
+
+ <div id="import-queue-submit" class="actions">
+ <input type="submit" id="field.actions.change_status"
+ name="field.actions.change_status" value="Change status" />
+ </div>
+ </script>
+ </body>
+</html>
=== added file 'lib/lp/translations/javascript/tests/test_importqueue.js'
--- lib/lp/translations/javascript/tests/test_importqueue.js 1970-01-01 00:00:00 +0000
+++ lib/lp/translations/javascript/tests/test_importqueue.js 2012-04-28 03:27:31 +0000
@@ -0,0 +1,67 @@
+/* Copyright 2011 Canonical Ltd. This software is licensed under the
+ * GNU Affero General Public License version 3 (see the file LICENSE).
+ */
+
+YUI().use('lp.testing.runner', 'test', 'console',
+ 'lp.translations.importqueue', function(Y) {
+
+var suite = new Y.Test.Suite("importqueue Tests");
+var namespace = Y.lp.translations.importqueue;
+
+
+var make_choice_confs = function() {
+ // Make generic confs fot testing. The test can change these as needed.
+ var confs = [];
+ var values = ['Imported', 'Imported'];
+ var statuses = ['Approved', 'Imported'];
+ Y.Array.forEach(values, function(value) {
+ var conf = {
+ 'value': value,
+ 'items': []
+ };
+ Y.Array.forEach(statuses, function(status) {
+ conf.items.push({
+ 'style': '',
+ 'help': '',
+ 'css_class': 'translationimportstatus' + status,
+ 'description': '',
+ 'value': status,
+ 'disabled': false,
+ 'description_css_class': 'choice-description',
+ 'name': status
+ });
+ });
+ confs.push(conf);
+ });
+ return confs;
+};
+
+
+suite.add(new Y.Test.Case({
+ name: 'importqueue macros',
+
+ setUp: function() {
+ fixture = Y.one("#fixture");
+ var template = Y.one('#import-queue-listing').getContent();
+ var test_node = Y.Node.create(template);
+ fixture.append(test_node);
+ },
+
+ tearDown: function() {
+ Y.one("#fixture").empty();
+ },
+
+ test_initialize_import_queue_page: function() {
+ choice_confs = make_choice_confs(); // setup global choice_confs.
+ namespace.initialize_import_queue_page(Y);
+ Y.Assert.isTrue(
+ Y.one('#import-queue-submit').hasClass('hidden'));
+ Y.Assert.isTrue(
+ Y.one('.status-select').hasClass('hidden'));
+ status_choice = Y.one('.status-choice');
+ Y.Assert.isFalse(status_choice.hasClass('hidden'));
+ }
+}));
+
+Y.lp.testing.Runner.run(suite);
+});
=== modified file 'lib/lp/translations/templates/pofile-export.pt'
--- lib/lp/translations/templates/pofile-export.pt 2012-02-01 15:31:32 +0000
+++ lib/lp/translations/templates/pofile-export.pt 2012-04-28 03:27:31 +0000
@@ -32,6 +32,7 @@
formatlist.on('change', toggle_pochanged);
// Initialize the state of the controls.
toggle_pochanged();
+ Y.one('#po-format-only').addClass('unseen');
});
});
</script>
@@ -65,7 +66,7 @@
<input type="checkbox" name="pochanged" id="cb_pochanged"
value="POCHANGED" />
<label for="cb_pochanged">
- <span><noscript><em>PO format only:</em></noscript>
+ <span><em id="po-format-only">PO format only:</em>
Only strings that differ from imported versions
(<a href="https://help.launchpad.net/Translations/PartialPOExport"
target="_blank">What's this?</a>).</span>
=== modified file 'lib/lp/translations/templates/translation-import-queue-macros.pt'
--- lib/lp/translations/templates/translation-import-queue-macros.pt 2012-03-02 16:17:46 +0000
+++ lib/lp/translations/templates/translation-import-queue-macros.pt 2012-04-28 03:27:31 +0000
@@ -93,10 +93,10 @@
omit-tag="">
<td class="import_status"
tal:condition="entry/required:launchpad.Edit">
- <noscript>
+ <span class="status-select">
<tal:status define="name string:status_${entry/id}"
replace="structure view/widgets/?name" />
- </noscript>
+ </span>
<span class="status-choice hidden">
<span tal:attributes="class string:value ${css_status}"
tal:content="entry/status/title">
@@ -171,18 +171,16 @@
<tal:navigation
replace="structure view/batchnav/@@+navigation-links-lower" />
+ <tal:block define="user request/lp:person" condition="user">
+ <div id="import-queue-submit" class="actions">
+ <input
+ tal:replace="structure view/change_status_action/render" />
+ </div>
+ </tal:block>
<script type="text/javascript"
tal:define="script view/focusedElementScript"
tal:condition="script"
tal:content="structure script" />
- <tal:block define="user request/lp:person" condition="user">
- <noscript>
- <div class="actions">
- <input
- tal:replace="structure view/change_status_action/render" />
- </div>
- </noscript>
- </tal:block>
</form>
</tal:block>
</div>
Follow ups