See #1848064: Allow to filter modules by arbitrary search strings on the Modules page.

I think it would be *really* useful to have a similar search field on that page as well, especially when you are looking for a specific class that failed on the testbot. Right now, you often have to open the file to figure out the group and name so that you can find it on the huge list.

screenshots of patch from #1

Remaining Tasks

Follow-ups

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir’s picture

Status: Active » Needs review
FileSize
23.14 KB
69.56 KB
4 KB

Wow, that was easier than expected.

- Copied the JS, I expected to have to make changes but it actually just seems to work? Should we move it into a separate file/library so that it is better re-usable? Adding system.modules to that page feels wrong?
- Added the form fields and classes
- Added the class name behind the description to make it easy to also search by that.

And it just works, see attached screenshots. Amazing :)

sun’s picture

Yes, we intentionally designed the JS to make it re-usable later on. I think we want to move the behavior into a new JS file; e.g., /misc/tablefilter.js

In http://drupal.org/project/admin_ux (which I'm using persistently), I've replaced the entire test label with the class name. Since the d.o testbot does not output the human-readable labels anymore, it only makes sense to do that in the local UI, too.

Closely related: #697760: Replace getInfo() in tests with native phpDoc + annotations (following PHPUnit)

Wim Leers’s picture

Status: Needs review » Needs work

:)

It works, but it's doing more than it has to on the tests page; the tests page is simpler. So the JS can be even simpler than it already is.

To generalize this, we'd have to make things too abstract to make all aspects configurable I think.

OTOH, I think the JS on this page should do automatic uncollapsing of collapsed rows, if a collapsed row matches?


+++ b/core/modules/simpletest/simpletest.jsundefined
@@ -99,4 +99,61 @@ Drupal.behaviors.simpleTestSelectAll = {
+    var $rowsAndDetails, $rows, $details;
+
+    function hidePackageDetails(index, element) {
+      var $details = $(element);
+      var $visibleRows = $details.find('table:not(.sticky-header)').find('tbody tr:visible');
+      $details.toggle($visibleRows.length > 0);
+    }

Unnecessary for tests filtering.

+++ b/core/modules/simpletest/simpletest.jsundefined
@@ -99,4 +99,61 @@ Drupal.behaviors.simpleTestSelectAll = {
+        // Hide the package <details> if they don't have any visible rows.
+        // Note that we first show() all <details> to be able to use ':visible'.
+        $details.show().each(hidePackageDetails);

Unnecessary for tests filtering.

+++ b/core/modules/simpletest/simpletest.jsundefined
@@ -99,4 +99,61 @@ Drupal.behaviors.simpleTestSelectAll = {
+      $rowsAndDetails = $table.find('tr, details');

Unnecessary for tests filtering.

+++ b/core/modules/simpletest/simpletest.jsundefined
@@ -99,4 +99,61 @@ Drupal.behaviors.simpleTestSelectAll = {
+      $details = $table.find('details');

Unnecessary for tests filtering.

YesCT’s picture

Berdir’s picture

Status: Needs work » Needs review
FileSize
3.96 KB

Ok, here's an update.

- Removed some unnecessary parts of the JS and renamed methods.
- Performance is a bit a problem, There are 800+ table rows, while I don't notice any issues on my desktop, it is quite slow on my laptop but the other JS also has performance issues.
- Due to that, I also increased the minimum characters to 4, there are way too many matches below that anyway. Might require a description/hint?
- Added some basic handling to only show groups when the search string is removed. Currently does not check if those groups were collapsed or not before, which is a bit weird. Need some help with that :)
- Also added a flag to prevent doing the above if it's not necessary, e.g. while typing the first 3 characters

tim.plunkett’s picture

My laptop is pretty quick, so I didn't notice any real slowness. That said, this is an identical approach to the module page, so it should be fixed for both if there is a huge problem.

The only visual bug is if your search doesn't match anything, the modules page hides everything but this still shows the table header, which looks very strange.

+++ b/core/modules/simpletest/simpletest.jsundefined
@@ -99,4 +99,62 @@ Drupal.behaviors.simpleTestSelectAll = {
   }
 };
 
+
+/**

+++ b/core/modules/simpletest/simpletest.pages.incundefined
@@ -9,6 +9,28 @@
 function simpletest_test_form($form) {
+
+
+  // JS-only table filters.

Extra blank lines

+++ b/core/modules/simpletest/simpletest.jsundefined
@@ -99,4 +99,62 @@ Drupal.behaviors.simpleTestSelectAll = {
+    var searching = false;
...
+        searching = true;
...
+      else if (searching) {

This seems like a performance improvement that could be mimicked in the module filtering.

+++ b/core/modules/simpletest/simpletest.jsundefined
@@ -99,4 +99,62 @@ Drupal.behaviors.simpleTestSelectAll = {
+        var $sources = $row.find('.table-filter-text-source');
+        var textMatch = $sources.text().toLowerCase().indexOf(query) !== -1;

I would combine these two lines, personally.

+++ b/core/modules/simpletest/simpletest.jsundefined
@@ -99,4 +99,62 @@ Drupal.behaviors.simpleTestSelectAll = {
+      function hideTestRow (index, row) {
+        var $row = $(row);
+        var $sources = $row.find('.table-filter-text-source');
+        var textMatch = $sources.text().toLowerCase().indexOf(query) !== -1;
+        $row.closest('tr').toggle(textMatch);

This is unused, and looks the same as showTestRow

+++ b/core/modules/simpletest/simpletest.jsundefined
@@ -99,4 +99,62 @@ Drupal.behaviors.simpleTestSelectAll = {
+      // Filter if the length of the query is at least 4 characters.
+      if (query.length >= 4) {

I can see why 2 would be too slow, but just testing it, I found having 3 characters do nothing be frustrating. Can we try bumping it down?

+++ b/core/modules/simpletest/simpletest.jsundefined
@@ -99,4 +99,62 @@ Drupal.behaviors.simpleTestSelectAll = {
+      // @todo Use autofocus attribute when possible.

Is that something happening in D8? Is there an issue?

+++ b/core/modules/simpletest/simpletest.pages.incundefined
@@ -9,6 +9,28 @@
+      'title' => t('Enter a part of the test name or description to filter by.'),

Should this mention the 4 character limitation?

+++ b/core/modules/simpletest/simpletest.pages.incundefined
@@ -149,11 +171,11 @@ function theme_simpletest_test_table($variables) {
+        'data' => '<div class="description">' . t('@description (@class)', array('@description' => $description, '@class' => $test_name)) . '</div>',

This should be format_string, I'm pretty sure.

Berdir’s picture

This seems like a performance improvement that could be mimicked in the module filtering.

I'm not sure the modules search needs this. Unlike this, searching already starts at the second characters, so there's only a single character on which we would not have to search on. And there are also considerably more tests than modules (close to 900 table rows..)

But I'm happy to apply it there as well if this is the correct approach to do something like this.

This should be format_string, I'm pretty sure.

It is a weird thing to translate agreed, but what about rtl languages? What do you think about replacing the name with the classname? then this would no longer be necessary... We should probably discuss that in a separate issue, though.

Changed the other things....

YesCT’s picture

+++ b/core/modules/simpletest/simpletest.jsundefined
@@ -99,4 +99,53 @@ Drupal.behaviors.simpleTestSelectAll = {
+        // @todo: This does not respect the current state of the group toggle.

no : after the todo
See
http://drupal.org/node/1354#todo
Also, to be consistant with the todo just a few lines after.

That of course is a tiny, nit, so patch attached for it.

But while I was reading it, the wording of the todo seemed strange. It was saying what the code did not do, instead of what the todo was todo. So I reworded the comment with what it sounded like the todo was hoping would be accomplished.

YesCT’s picture

FileSize
149.08 KB

I also tested manually.
Still working great.
Search starts after 3 chars.
There is a tooltip type of popup with the instructions that say to enter at least 3 chars.

Here is what it looks like when there are no matches, as @tim.plunkett mentioned in #6

no-results-2013-02-22_2358.png

YesCT’s picture

@tim.plunkett asked about the autofocus todo comment.
Perhaps this is the info looking for. It's a won't fix and but also mentions just using #attributes. I'm not sure what that means for this though.
#1174936-13: Allow FAPI usage of the autofocus attribute

YesCT’s picture

aside form #9 and #10

all the comments from @tim.plunkett have been addressed.

Here are the two follow-ups for the remainder from #7

#1925492: Small optimization for search on modules page

#1925498: Convert t() to format_string that added class to the description, when search added to test list (this one is postponed on this issue)

Wim Leers’s picture

This seems like a performance improvement that could be mimicked in the module filtering.

This is in fact a mutex, and it should be documented as such. It should be documented how this helps improve performance, because at first glance it looks very odd.

Berdir’s picture

Right now, when you either start typing or delete characters, when you are between 0 and $min characters, I'm first hiding everything in the table and then display the group grows. (Happy to change that if someone has a better suggestion).

So it does a lot of processing that is completely unnecessary. With the flag, it only does that (hide all then show group rows) once when you switch from $min characters to $min - 1 characters. Might not be necessary for the modules page because there is only a single character where this happens and we're simply displaying everything.

Bojhan’s picture

Why is tests in a fieldset?

YesCT’s picture

Status: Needs review » Needs work
YesCT’s picture

Issue tags: +Needs reroll
star-szr’s picture

Status: Needs work » Needs review
FileSize
3.67 KB

Rerolled to fix a minor conflict with #1901670: Start using PHPUnit for unit tests.

star-szr’s picture

Issue tags: -Needs reroll

Missed the tag.

star-szr’s picture

@Bojhan/#14 - that sounds like a separate issue to me, this patch doesn't add or change fieldsets.

nod_’s picture

Issue tags: +JavaScript

tag

YesCT’s picture

#18: 1919470-18.patch queued for re-testing.

xjm’s picture

Category: feature » task
Issue tags: +Needs accessibility review, +Needs followup
FileSize
35.32 KB

This is totally freaking awesome. I tested with and without overlay and it works great. I can't provide a JS code review though--@nod_, @tim.plunkett?
yay.png

If it looks good codewise I'd just as soon get this in RIGHT NOW so that we all can start using it RIGHT NOW, and then handle the following in followups:

  • Not displaying the table header when it's empty.
  • Talk about the silly fieldset around the tests. (@Bojhan, as far as I can tell, it's there for the sole purpose of collapsing it so you can get to the "Clean environment" button.)
  • Making the test class name and description not so tiny. (It's seriously hard to read.)
  • Maybe the search should match the test groups as well? My search for "views plugin" above does not match the 20 items in the Views Plugins test group.

Despite that it's after feature freeze, I think it's fine to put this in by itself and add followups, since this is a developer-facing feature and a very non-intrusive patch.

Things we should do before commit:

Also, I'm marking this as a task, because it is going to save every single D8 developer time.

nod_’s picture

Js is good, based off the module filter code so nothing to worry about.

For those raising the point that we should be using the same JS in the module and simpletest filter, well, we need the same markup first.

xjm’s picture

Alright then. Thanks @nod_! Let's then do the accessibility testing and file some followups.

YesCT’s picture

Issue summary: View changes

Updated issue summary, embedded screenshots in issue summary

YesCT’s picture

Issue summary: View changes

adding remaining tasks section

YesCT’s picture

YesCT’s picture

Issue summary: View changes

making url work

YesCT’s picture

Issue summary: View changes

noting follow-ups that were already made

Bojhan’s picture

@xjm That's fine, I guess if you need you can always move the button towards the top.

Bojhan’s picture

Issue summary: View changes

noting #23 has the list of follow-ups to open

YesCT’s picture

Simplytest.me is having trouble with #1969680: Installation fails with MyISAM - key too long

So, this Contributor Task doc, for manual accessibility testing might help in the mean time: http://drupal.org/node/1853532

Berdir’s picture

Simpletest.module can currently not be installed on simplytest.me due to the PHP configuration.

mgifford’s picture

#18: 1919470-18.patch queued for re-testing.

YesCT’s picture

#18: 1919470-18.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 1919470-18.patch, failed testing.

jenlampton’s picture

Status: Needs work » Needs review
Issue tags: +JavaScript, +Needs accessibility review, +Needs followup

#18: 1919470-18.patch queued for re-testing.

star-szr’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Needs a reroll.

s_leu’s picture

FileSize
4.11 KB

Adding a rerolled patch for this.

Regarding the autofocus @todo i don't see a reason to add this because we are executing JS anyway, so i think it's an unecessary overhead to do a feature testing for support of this attribute and then adding it conditionally instead of just using .focus(). Or what would be the reason to do so?

I test the page with the keyboard shortly, and everything is accessible that way. The rest of the accessibility testing seems unnecessary because this page is working in the same way as the module list page.

s_leu’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
Issue tags: -JavaScript, -Needs accessibility review, -Needs reroll, -Needs followup

The last submitted patch, 1919470-35.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review

#35: 1919470-35.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 1919470-35.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
Issue tags: +JavaScript, +Needs accessibility review, +Needs reroll, +Needs followup

#35: 1919470-35.patch queued for re-testing.

star-szr’s picture

Issue tags: -Needs reroll
FileSize
4.41 KB

Thanks @s_leu!

Just wanted to note that #35 is not a straight reroll, here is an interdiff generated by patchutils. The two main changes I saw were that format_string() is used instead of t(), and this:

diff -u b/core/modules/simpletest/simpletest.js b/core/modules/simpletest/simpletest.js
--- b/core/modules/simpletest/simpletest.js
+++ b/core/modules/simpletest/simpletest.js
@@ -135,14 +135,13 @@
         // @todo Make this respect the current state of the group toggle.
         searching = false;
         $rows.hide();
-        $rows.filter('.simpletest-group').show();
+        $rows.filter('.simpletest-group').show().find('div.simpletest-image')
+          .html(settings.simpleTest.images[0]);
       }
     }

Also check the indentation within \Drupal\simpletest\Form\SimpletestTestForm::buildForm(), it's a bit off now.

@s_leu - Next time you reroll and want to make additional changes, I recommend posting two separate patches if possible (first just a direct reroll with no changes) with an interdiff :)

s_leu’s picture

Ok to clean that up, here's a straight reroll, a patch including the improvements and an interdiff containing only the improvements after the straight reroll

star-szr’s picture

Perfect, thanks @s_leu :)

s_leu’s picture

FileSize
986 bytes
4.24 KB

Added another change that takes care about the last remaining todo in the JS, it adds code to respect the opened test actions after the search string gets deleted again.

YesCT’s picture

I did a quick read through and standards wise looks ok to me. (for example the whitespace indent is fixed)

Status: Needs review » Needs work

The last submitted patch, 1919470-44.patch, failed testing.

nod_’s picture

JS needs a little bit of work.

$(this).show(), don't need to put that in the .each(), it can be just before the .each() and will work just as well.
it's drupalSettings now, not Drupal.settings.
not .parents() but .closest(). and the .children()[0] is pretty ugly, no better way to select that?

s_leu’s picture

Status: Needs work » Needs review
FileSize
1.02 KB
4.22 KB

Added nod_'s suggested changes.

YesCT’s picture

@xjm (or other)
this is tagged with needs followup. Does it need follow-ups that are not already created and listed in the issue summary?
If follow-ups are already created and linked, I think we can remove the needs followup tag.

YesCT’s picture

Issue summary: View changes

added conttributor task doc

Berdir’s picture

See #35, @s_leu did a keyboard test and this is the same behavior and form structure as on the module search page, so I think we are good in regards to accessibility testing?

Berdir’s picture

Issue summary: View changes

added follow-ups from #23

nod_’s picture

Thanks for the reroll s_leu, a few small details if you don't mind.

- I'd prefer we use the global drupalSettings variable instead of settings (the settings parameter will be removed from the behaviors for attach and detached functions).
- can we have .trigger('focus'); instead of .focus() ? there is an issue out there to remove all shorthand version of those things with proper .trigger and .on

Other than that, js is RTBC as far as I'm concerned. Thanks :)

nod_’s picture

Issue summary: View changes

updating remaining tasks

joelpittet’s picture

As requested in #52 by @nod_

joelpittet’s picture

Firefox was choking on keyup because of all the DOM searching so I added a little timeout delay of 200ms to allow the search a breathing period to cancel the filter function call.

Wim Leers’s picture

Firefox was choking on keyup because of all the DOM searching so I added a little timeout delay of 200ms to allow the search a breathing period to cancel the filter function call.

Really? I can't reproduce that. But given that Berdir has also indicated performance can be a problem on this page, let's keep this, but instead of using custom code, let's use Drupal.debounce, which exists precisely for this purpose.


In this reroll:

  • Fixed a bunch of comments.
  • Replaced the custom code in #54 with Drupal.debounce.
  • Renamed the searching variable to searched, which is what it really is about. It's *not* a mutex as I said in #12. It's now also documented to prevent future confusion.
  • The "select all" checkbox was still visible when the table was filtered, and clicking it would still select ALL the tests, not just the filtered ones. This is very misleading. So, whenever filtering has been applied, the "select all" checkbox is now hidden.
nod_’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, that's what debounce is for indeed. Changes are all good on my side.

YesCT’s picture

FileSize
86.74 KB

nice!

the no select all checkbox when filtered,
is consistant with how the search works on the modules (Extend) page too.

noall.png

joelpittet’s picture

@Wim Leers thanks, didn't know of debounce:) I have a couple other things that could make this preform better but that can go in a follow up. RTBC:)

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 8.x. Thanks.

xjm’s picture

Thank you thank you! Yay!

YesCT’s picture

oh yay!

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

updated remaining tasks, noting comment where accessibility testing was done.