Page MenuHomePhabricator

Add filter by object ability to flag query
ClosedPublic

Authored by btrahan on Oct 24 2013, 7:29 PM.
Tags
None
Referenced Files
F13367746: D7392.diff
Thu, Jun 27, 3:06 AM
F13352710: D7392.id16649.diff
Sun, Jun 23, 3:10 PM
F13351845: D7392.diff
Sun, Jun 23, 10:27 AM
F13335094: D7392.diff
Wed, Jun 19, 1:27 AM
F13320484: D7392.diff
Fri, Jun 14, 5:23 AM
F13309203: D7392.diff
Mon, Jun 10, 9:45 AM
F13272100: D7392.id16678.diff
Thu, May 30, 7:48 AM
F13272099: D7392.id16649.diff
Thu, May 30, 7:48 AM

Details

Reviewers
epriestley
Maniphest Tasks
Restricted Maniphest Task
Commits
Restricted Diffusion Commit
rPda845460586c: Add filter by object ability to flag query
Summary

See title. Fixes T1809.

Test Plan

verified each type that has flaggable interface still can be flagged

verified that new custom query filter works

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

This looks great to me, see inline for discussion.

src/applications/flag/interface/PhabricatorFlaggableInterface.php
5

I think we can safely put getPHID() here now. Flags requires it and LiskDAO should always provide it.

src/applications/flag/query/PhabricatorFlagSearchEngine.php
104

This is kind of funky. The idea is that we want to render a dropdown with human-readable names, like "Task" instead of "ManiphestTask".

PHIDType already has these strings, so we can figure this out like:

$all_types = PhabricatorPHIDType::getAllTypes();
foreach ($objects as $object) {
  $phid = $object->generatePHID();
  $phid_type = phid_get_type($phid);
  $type_object = idx($all_types, $phid_type);
  if ($type_object) {
    $human_readable_name = $type_object->getTypeName();
  }
}

This will give us nice names -- "Task", "Revision", etc.

The generatePHID() part is a little funky. Possibly we should do this instead, in LiskDAO or wherever the base for generatePHID() lives:

public function getPHIDType() {
  return null;
}

public function generatePHID() {
  // return null if no phid type, or:
  return PhabricatorPHID::generatePHID($this->getPHIDType());
}

...or whatever (I don't have a copy open right now and might have goofed some method names). Basically, have subclasses like ManiphestTask just return their type instead of actually doing the generation. Only ApplicationTransaction and ApplicationTransactionComment have nontrivial logic in generatePHID().

But we could also skip this, there's no real harm in generating the PHIDs (they aren't written to the DB or anything).

btrahan updated this revision to Unknown Object (????).Oct 25 2013, 12:38 AM

using the generate_phid technique - I think we can think about something a bit cleaner if / when this comes up again.

{F74660}

is not the prettiest thing I have ever seen.

Maybe asort() the list (and then shove "All" on afterward, I guess)?

src/applications/flag/query/PhabricatorFlagQuery.php
15 ↗(On Diff #16653)

Maybe just use null as the default.

98–106 ↗(On Diff #16653)

Oh -- you should be able to do this in the DB. The table has a type column, which I believe is correctly populated.

btrahan updated this revision to Unknown Object (????).Oct 25 2013, 7:48 PM

updated...

  • use withTypes - no need to add the "withObjectType"
  • doing so moves the filtering to the DB and makes default null
  • make the list sorted and slap the default on the front at the end