[ARVADOS] updated: 1f168b8d94bff45ef2be842e60bed7e1c4e37317

git at public.curoverse.com git at public.curoverse.com
Mon Oct 20 10:47:44 EDT 2014


Summary of changes:
 .../app/assets/javascripts/infinite_scroll.js      | 96 +++++++++++++---------
 apps/workbench/test/integration/projects_test.rb   |  2 +-
 2 files changed, 59 insertions(+), 39 deletions(-)

       via  1f168b8d94bff45ef2be842e60bed7e1c4e37317 (commit)
      from  4335bce9369b5df234c5d68c4deff820ca2c28d1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 1f168b8d94bff45ef2be842e60bed7e1c4e37317
Author: Tom Clegg <tom at curoverse.com>
Date:   Mon Oct 20 10:47:32 2014 -0400

    4062: Do not clobber next_page_url filters with local filters.

diff --git a/apps/workbench/app/assets/javascripts/infinite_scroll.js b/apps/workbench/app/assets/javascripts/infinite_scroll.js
index 6b392c4..5de7786 100644
--- a/apps/workbench/app/assets/javascripts/infinite_scroll.js
+++ b/apps/workbench/app/assets/javascripts/infinite_scroll.js
@@ -41,45 +41,26 @@ function maybe_load_more_content(event) {
         $container.append(spinner);
         $container.attr('data-infinite-serial', serial);
 
-        // Combine infiniteContentParams from multiple sources. This
-        // mechanism allows each of several components to set and
-        // update its own set of filters, without having to worry
-        // about stomping on some other component's filters.
-        //
-        // For example, filterable.js writes filters in
-        // infiniteContentParamsFilterable ("search for text foo")
-        // without worrying about clobbering the filters set up by the
-        // tab pane ("only show jobs and pipelines in this tab").
-        params = {};
-        $.each($container.data(), function(datakey, datavalue) {
-            // Note: We attach these data to DOM elements using
-            // <element data-foo-bar="baz">. We store/retrieve them
-            // using $('element').data('foo-bar'), although
-            // .data('fooBar') would also work. The "all data" hash
-            // returned by $('element').data(), however, always has
-            // keys like 'fooBar'. In other words, where we have a
-            // choice, we stick with the 'foo-bar' style to be
-            // consistent with HTML. Here, our only option is
-            // 'fooBar'.
-            if (/^infiniteContentParams/.exec(datakey)) {
-                if (datavalue instanceof Object) {
-                    $.each(datavalue, function(hkey, hvalue) {
-                        if (hvalue instanceof Array) {
-                            params[hkey] = (params[hkey] || []).concat(hvalue);
-                        } else if (hvalue instanceof Object) {
-                            $.extend(params[hkey], hvalue);
-                        } else {
-                            params[hkey] = hvalue;
-                        }
-                    });
+        if (src == $container.attr('data-infinite-content-href0')) {
+            // If we're loading the first page, collect filters from
+            // various sources.
+            params = mergeInfiniteContentParams($container);
+            $.each(params, function(k,v) {
+                if (v instanceof Object) {
+                    params[k] = JSON.stringify(v);
                 }
-            }
-        });
-        $.each(params, function(k,v) {
-            if (v instanceof Object) {
-                params[k] = JSON.stringify(v);
-            }
-        });
+            });
+        } else {
+            // If we're loading page >1, ignore other filtering
+            // mechanisms and just use the "next page" URI from the
+            // previous page's response. Aside from avoiding race
+            // conditions (where page 2 could have different filters
+            // than page 1), this allows the server to use filters in
+            // the "next page" URI to achieve paging. (To apply any
+            // new filters effectively, we need to load page 1 again
+            // anyway.)
+            params = {};
+        }
 
         $.ajax(src,
                {dataType: 'json',
@@ -127,6 +108,45 @@ function ping_all_scrollers() {
     $('.infinite-scroller').add(window).trigger('scroll');
 }
 
+function mergeInfiniteContentParams($container) {
+    var params = {};
+    // Combine infiniteContentParams from multiple sources. This
+    // mechanism allows each of several components to set and
+    // update its own set of filters, without having to worry
+    // about stomping on some other component's filters.
+    //
+    // For example, filterable.js writes filters in
+    // infiniteContentParamsFilterable ("search for text foo")
+    // without worrying about clobbering the filters set up by the
+    // tab pane ("only show jobs and pipelines in this tab").
+    $.each($container.data(), function(datakey, datavalue) {
+        // Note: We attach these data to DOM elements using
+        // <element data-foo-bar="baz">. We store/retrieve them
+        // using $('element').data('foo-bar'), although
+        // .data('fooBar') would also work. The "all data" hash
+        // returned by $('element').data(), however, always has
+        // keys like 'fooBar'. In other words, where we have a
+        // choice, we stick with the 'foo-bar' style to be
+        // consistent with HTML. Here, our only option is
+        // 'fooBar'.
+        if (/^infiniteContentParams/.exec(datakey)) {
+            if (datavalue instanceof Object) {
+                $.each(datavalue, function(hkey, hvalue) {
+                    if (hvalue instanceof Array) {
+                        params[hkey] = (params[hkey] || []).
+                            concat(hvalue);
+                    } else if (hvalue instanceof Object) {
+                        $.extend(params[hkey], hvalue);
+                    } else {
+                        params[hkey] = hvalue;
+                    }
+                });
+            }
+        }
+    });
+    return params;
+}
+
 $(document).
     on('click', 'div.infinite-retry button', function() {
         var $retry_div = $(this).closest('.infinite-retry');
diff --git a/apps/workbench/test/integration/projects_test.rb b/apps/workbench/test/integration/projects_test.rb
index b623490..67abcc9 100644
--- a/apps/workbench/test/integration/projects_test.rb
+++ b/apps/workbench/test/integration/projects_test.rb
@@ -547,7 +547,7 @@ class ProjectsTest < ActionDispatch::IntegrationTest
   [
     ['project with 10 pipelines', 10, 0],
     ['project with 200 jobs and 10 pipelines', 10, 200],
-    ['project with 25 pipelines', 25, 0],   # 20 is the page limit for this tab; hence two pages
+    ['project with 25 pipelines', 25, 0],
   ].each do |project_name, num_pipelines, num_jobs|
     test "scroll pipeline instances tab for #{project_name} with #{num_pipelines} pipelines and #{num_jobs} jobs" do
       headless = Headless.new

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list