Page MenuHomePhorge

Display default "Page Size" value in Maniphest Advanced Search form
AbandonedPublic

Authored by aklapper on Nov 27 2023, 15:45.
Tags
None
Referenced Files
Unknown Object (File)
Sat, May 4, 14:23
Unknown Object (File)
Sat, May 4, 13:24
Unknown Object (File)
Sat, May 4, 12:30
Unknown Object (File)
Thu, Apr 25, 16:59
Unknown Object (File)
Thu, Apr 25, 16:59
Unknown Object (File)
Thu, Apr 25, 04:21
Unknown Object (File)
Fri, Apr 19, 21:07
Unknown Object (File)
Wed, Apr 17, 18:15

Details

Summary

The "Page Size" field on /maniphest/query/advanced/ is empty by default though Phorge's paging shows by default only 100 results by default.
Thus make the empty field display 100 to reflect reality and reduce confusion why some of the >100 search results are missing.

Closes T15676

Test Plan

Go to /maniphest/query/advanced/ and see that the Page Size field now shows 100 by default.
Run search queries; change Page Size field to another value.

Diff Detail

Repository
rP Phorge
Branch
T15676ManiphestPageSize (branched from master)
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 955
Build 955: arc lint + arc unit

Event Timeline

Another option would be to extend the class PhabricatorSearchTextField and make the new class PhabricatorSearchPageSizeField only overwrite function getDefaultValue(), however class PhabricatorSearchTextField is marked as final and I am reluctant to change that.

Note that in theory there might be other advanced search forms apart from Maniphest which might also benefit from this and that I am not aware of; that's a future option for separate patches though.

Hmm I guess the Test Plan should also cover testing with Conduit. Not sure this may shake something up.

Is this the only place where we have a "Page size" exposed in the search?

Is this the only place where we have a "Page size" exposed in the search?

I expect so: grep -r "Page Size" . in current git master only lists a single match in ./src/applications/maniphest/query/ManiphestTaskSearchEngine.php: ->setLabel(pht('Page Size'))

maybe use an PhabricatorSearchIntField with a default provided in the buildCustomSearchFields() ?

maybe use an PhabricatorSearchIntField with a default provided in the buildCustomSearchFields() ?

Right, however not sure how to do that (but might just be me being too stupid and not understanding the code).

Parent PhabricatorSearchField class of PhabricatorSearchIntField has no set(Default)Value() function or such.
If I add a new public function setDefaultValue($value) { $this->value = $value; return $this; } to PhabricatorSearchField,
and make buildCustomSearchFields() use id(new PhabricatorSearchIntField()) with a new ->setDefaultValue(100),
I neither get any errors nor does the 100 value get set in the Page Size field of the Maniphest Advanced Search.

(Sidenote: The field is supposed to take an integer value but even after making it a PhabricatorSearchIntField it still accepts any random input.)

Yeah, looks like IntField isn't doing much now (yet?)

It could get setDefault() like PhabricatorSearchSelectField, plus validateControlValue() and type="number" for the control, to make it more useful.

This revision is now accepted and ready to land.Dec 23 2023, 10:03
src/applications/search/field/PhabricatorSearchPageSizeField.php
3

Actually, should call this PhorgeSearch....., because we're Phorge now :)

Yeah, looks like IntField isn't doing much now (yet?). It could get setDefault() like PhabricatorSearchSelectField, plus validateControlValue()

I looked into this; its behavior is a mystery to me.
PhabricatorSearchIntField is used in only one place PhabricatorProjectSearchEngine.php.
After I manually set ->setIsHidden(false) in that file to play with this type on /project/query/advanced/, some unknown magic accepts any kind of input (e.g. letters) and converts it into a 0.
Introducing a public function setValue($value) { $this->value = $value; return $this; } did not have any effect either.
I can imagine that the rendering code of AphrontFormControl simply overwrites any such attempts.

and type="number" for the control

'type' => 'text' is defined by the corresponding AphrontFormControl. If we wanted to set 'type' => 'number' we'd have to introduce a new class AphrontFormIntControl.php or such. Worth a separate ticket?

unknown magic accepts any kind of input (e.g. letters) and converts it into a 0.

That is the magic of PHP!

Worth a separate ticket?

I think a general (working) IntSearchField sounds like a reasonable feature, worthy of a ticket... We have a CustomIntField, right?
I'll file that.

Indeed ideally I'd prefer to convert the current use of PhabricatorSearchTextField for an integer value to a functioning PhabricatorSearchIntField (which should return a future new AphrontFormIntControl()) instead, thus I'm reluctant to land this (though it remains a mystery to me how to set a default value (not: placeholder) in any non-dropdown field).

Abandoning my patch becaue creating a child class for each and every single field does not scale.
Instead there should be a setDefaultValue() function on a PhabricatorSearchField level to be called by the SearchEngine.