mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-10 08:52:39 +01:00
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 Reviewers: epriestley Reviewed By: epriestley CC: Korvin, epriestley, aran Maniphest Tasks: T1809 Differential Revision: https://secure.phabricator.com/D7392
This commit is contained in:
parent
203d82083a
commit
da84546058
19 changed files with 101 additions and 27 deletions
|
@ -1299,6 +1299,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorFlagQuery' => 'applications/flag/query/PhabricatorFlagQuery.php',
|
||||
'PhabricatorFlagSearchEngine' => 'applications/flag/query/PhabricatorFlagSearchEngine.php',
|
||||
'PhabricatorFlagSelectControl' => 'applications/flag/view/PhabricatorFlagSelectControl.php',
|
||||
'PhabricatorFlaggableInterface' => 'applications/flag/interface/PhabricatorFlaggableInterface.php',
|
||||
'PhabricatorFlagsUIEventListener' => 'applications/flag/events/PhabricatorFlagsUIEventListener.php',
|
||||
'PhabricatorFormExample' => 'applications/uiexample/examples/PhabricatorFormExample.php',
|
||||
'PhabricatorGarbageCollectorConfigOptions' => 'applications/config/option/PhabricatorGarbageCollectorConfigOptions.php',
|
||||
|
@ -2587,7 +2588,8 @@ phutil_register_library_map(array(
|
|||
0 => 'DifferentialDAO',
|
||||
1 => 'PhabricatorTokenReceiverInterface',
|
||||
2 => 'PhabricatorPolicyInterface',
|
||||
3 => 'PhrequentTrackableInterface',
|
||||
3 => 'PhabricatorFlaggableInterface',
|
||||
4 => 'PhrequentTrackableInterface',
|
||||
),
|
||||
'DifferentialRevisionCommentListView' => 'AphrontView',
|
||||
'DifferentialRevisionCommentView' => 'AphrontView',
|
||||
|
@ -2883,7 +2885,8 @@ phutil_register_library_map(array(
|
|||
'HeraldRule' =>
|
||||
array(
|
||||
0 => 'HeraldDAO',
|
||||
1 => 'PhabricatorPolicyInterface',
|
||||
1 => 'PhabricatorFlaggableInterface',
|
||||
2 => 'PhabricatorPolicyInterface',
|
||||
),
|
||||
'HeraldRuleController' => 'HeraldController',
|
||||
'HeraldRuleEdit' => 'HeraldDAO',
|
||||
|
@ -2998,8 +3001,9 @@ phutil_register_library_map(array(
|
|||
1 => 'PhabricatorMarkupInterface',
|
||||
2 => 'PhabricatorPolicyInterface',
|
||||
3 => 'PhabricatorTokenReceiverInterface',
|
||||
4 => 'PhrequentTrackableInterface',
|
||||
5 => 'PhabricatorCustomFieldInterface',
|
||||
4 => 'PhabricatorFlaggableInterface',
|
||||
5 => 'PhrequentTrackableInterface',
|
||||
6 => 'PhabricatorCustomFieldInterface',
|
||||
),
|
||||
'ManiphestTaskDescriptionPreviewController' => 'ManiphestController',
|
||||
'ManiphestTaskDetailController' => 'ManiphestController',
|
||||
|
@ -3518,7 +3522,8 @@ phutil_register_library_map(array(
|
|||
0 => 'PhabricatorFileDAO',
|
||||
1 => 'PhabricatorTokenReceiverInterface',
|
||||
2 => 'PhabricatorSubscribableInterface',
|
||||
3 => 'PhabricatorPolicyInterface',
|
||||
3 => 'PhabricatorFlaggableInterface',
|
||||
4 => 'PhabricatorPolicyInterface',
|
||||
),
|
||||
'PhabricatorFileCommentController' => 'PhabricatorFileController',
|
||||
'PhabricatorFileComposeController' => 'PhabricatorFileController',
|
||||
|
@ -3533,7 +3538,8 @@ phutil_register_library_map(array(
|
|||
0 => 'PhabricatorFileDAO',
|
||||
1 => 'PhabricatorSubscribableInterface',
|
||||
2 => 'PhabricatorApplicationTransactionInterface',
|
||||
3 => 'PhabricatorPolicyInterface',
|
||||
3 => 'PhabricatorFlaggableInterface',
|
||||
4 => 'PhabricatorPolicyInterface',
|
||||
),
|
||||
'PhabricatorFileInfoController' => 'PhabricatorFileController',
|
||||
'PhabricatorFileLinkListView' => 'AphrontView',
|
||||
|
@ -3764,7 +3770,8 @@ phutil_register_library_map(array(
|
|||
0 => 'PhabricatorPasteDAO',
|
||||
1 => 'PhabricatorSubscribableInterface',
|
||||
2 => 'PhabricatorTokenReceiverInterface',
|
||||
3 => 'PhabricatorPolicyInterface',
|
||||
3 => 'PhabricatorFlaggableInterface',
|
||||
4 => 'PhabricatorPolicyInterface',
|
||||
),
|
||||
'PhabricatorPasteCommentController' => 'PhabricatorPasteController',
|
||||
'PhabricatorPasteConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||
|
@ -3846,7 +3853,8 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProject' =>
|
||||
array(
|
||||
0 => 'PhabricatorProjectDAO',
|
||||
1 => 'PhabricatorPolicyInterface',
|
||||
1 => 'PhabricatorFlaggableInterface',
|
||||
2 => 'PhabricatorPolicyInterface',
|
||||
),
|
||||
'PhabricatorProjectBoardController' => 'PhabricatorProjectController',
|
||||
'PhabricatorProjectColumn' =>
|
||||
|
@ -3904,7 +3912,8 @@ phutil_register_library_map(array(
|
|||
array(
|
||||
0 => 'PhabricatorRepositoryDAO',
|
||||
1 => 'PhabricatorPolicyInterface',
|
||||
2 => 'PhabricatorMarkupInterface',
|
||||
2 => 'PhabricatorFlaggableInterface',
|
||||
3 => 'PhabricatorMarkupInterface',
|
||||
),
|
||||
'PhabricatorRepositoryArcanistProject' =>
|
||||
array(
|
||||
|
@ -3920,7 +3929,8 @@ phutil_register_library_map(array(
|
|||
array(
|
||||
0 => 'PhabricatorRepositoryDAO',
|
||||
1 => 'PhabricatorPolicyInterface',
|
||||
2 => 'PhabricatorTokenReceiverInterface',
|
||||
2 => 'PhabricatorFlaggableInterface',
|
||||
3 => 'PhabricatorTokenReceiverInterface',
|
||||
),
|
||||
'PhabricatorRepositoryCommitChangeParserWorker' => 'PhabricatorRepositoryCommitParserWorker',
|
||||
'PhabricatorRepositoryCommitData' => 'PhabricatorRepositoryDAO',
|
||||
|
@ -4045,7 +4055,8 @@ phutil_register_library_map(array(
|
|||
0 => 'PhabricatorSlowvoteDAO',
|
||||
1 => 'PhabricatorPolicyInterface',
|
||||
2 => 'PhabricatorSubscribableInterface',
|
||||
3 => 'PhabricatorTokenReceiverInterface',
|
||||
3 => 'PhabricatorFlaggableInterface',
|
||||
4 => 'PhabricatorTokenReceiverInterface',
|
||||
),
|
||||
'PhabricatorSlowvotePollController' => 'PhabricatorSlowvoteController',
|
||||
'PhabricatorSlowvoteQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
|
@ -4247,7 +4258,8 @@ phutil_register_library_map(array(
|
|||
'PhluxVariable' =>
|
||||
array(
|
||||
0 => 'PhluxDAO',
|
||||
1 => 'PhabricatorPolicyInterface',
|
||||
1 => 'PhabricatorFlaggableInterface',
|
||||
2 => 'PhabricatorPolicyInterface',
|
||||
),
|
||||
'PhluxVariableEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||
'PhluxVariableQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
|
||||
|
@ -4280,7 +4292,8 @@ phutil_register_library_map(array(
|
|||
2 => 'PhabricatorPolicyInterface',
|
||||
3 => 'PhabricatorSubscribableInterface',
|
||||
4 => 'PhabricatorTokenReceiverInterface',
|
||||
5 => 'PhabricatorApplicationTransactionInterface',
|
||||
5 => 'PhabricatorFlaggableInterface',
|
||||
6 => 'PhabricatorApplicationTransactionInterface',
|
||||
),
|
||||
'PholioMockCommentController' => 'PholioController',
|
||||
'PholioMockEditController' => 'PholioController',
|
||||
|
@ -4394,7 +4407,8 @@ phutil_register_library_map(array(
|
|||
0 => 'PhrictionDAO',
|
||||
1 => 'PhabricatorPolicyInterface',
|
||||
2 => 'PhabricatorSubscribableInterface',
|
||||
3 => 'PhabricatorTokenReceiverInterface',
|
||||
3 => 'PhabricatorFlaggableInterface',
|
||||
4 => 'PhabricatorTokenReceiverInterface',
|
||||
),
|
||||
'PhrictionDocumentController' => 'PhrictionController',
|
||||
'PhrictionDocumentEditor' => 'PhabricatorEditor',
|
||||
|
@ -4422,8 +4436,9 @@ phutil_register_library_map(array(
|
|||
1 => 'PhabricatorMarkupInterface',
|
||||
2 => 'PonderVotableInterface',
|
||||
3 => 'PhabricatorPolicyInterface',
|
||||
4 => 'PhabricatorSubscribableInterface',
|
||||
5 => 'PhabricatorTokenReceiverInterface',
|
||||
4 => 'PhabricatorFlaggableInterface',
|
||||
5 => 'PhabricatorSubscribableInterface',
|
||||
6 => 'PhabricatorTokenReceiverInterface',
|
||||
),
|
||||
'PonderAnswerCommentController' => 'PonderController',
|
||||
'PonderAnswerEditController' => 'PonderController',
|
||||
|
@ -4451,8 +4466,9 @@ phutil_register_library_map(array(
|
|||
1 => 'PhabricatorMarkupInterface',
|
||||
2 => 'PonderVotableInterface',
|
||||
3 => 'PhabricatorSubscribableInterface',
|
||||
4 => 'PhabricatorPolicyInterface',
|
||||
5 => 'PhabricatorTokenReceiverInterface',
|
||||
4 => 'PhabricatorFlaggableInterface',
|
||||
5 => 'PhabricatorPolicyInterface',
|
||||
6 => 'PhabricatorTokenReceiverInterface',
|
||||
),
|
||||
'PonderQuestionCommentController' => 'PonderController',
|
||||
'PonderQuestionEditController' => 'PonderController',
|
||||
|
|
|
@ -4,6 +4,7 @@ final class DifferentialRevision extends DifferentialDAO
|
|||
implements
|
||||
PhabricatorTokenReceiverInterface,
|
||||
PhabricatorPolicyInterface,
|
||||
PhabricatorFlaggableInterface,
|
||||
PhrequentTrackableInterface {
|
||||
|
||||
protected $title = '';
|
||||
|
|
|
@ -7,6 +7,7 @@ final class PhabricatorFile extends PhabricatorFileDAO
|
|||
implements
|
||||
PhabricatorTokenReceiverInterface,
|
||||
PhabricatorSubscribableInterface,
|
||||
PhabricatorFlaggableInterface,
|
||||
PhabricatorPolicyInterface {
|
||||
|
||||
const STORAGE_FORMAT_RAW = 'raw';
|
||||
|
|
|
@ -24,10 +24,7 @@ final class PhabricatorFlagsUIEventListener extends PhabricatorEventListener {
|
|||
return;
|
||||
}
|
||||
|
||||
if (($object instanceof PhabricatorUser)) {
|
||||
// Although there's no real reason not to let you flag users, it also
|
||||
// makes less conceptual sense than flaging other types of objects. For
|
||||
// now, don't allow it.
|
||||
if (!($object instanceof PhabricatorFlaggableInterface)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
|
||||
interface PhabricatorFlaggableInterface {
|
||||
|
||||
public function getPHID();
|
||||
|
||||
}
|
|
@ -7,6 +7,7 @@ final class PhabricatorFlagSearchEngine
|
|||
$saved = new PhabricatorSavedQuery();
|
||||
$saved->setParameter('colors', $request->getArr('colors'));
|
||||
$saved->setParameter('group', $request->getStr('group'));
|
||||
$saved->setParameter('objectFilter', $request->getStr('objectFilter'));
|
||||
return $saved;
|
||||
}
|
||||
|
||||
|
@ -25,6 +26,12 @@ final class PhabricatorFlagSearchEngine
|
|||
$query->setGroupBy($group);
|
||||
}
|
||||
|
||||
$object_filter = $saved->getParameter('objectFilter');
|
||||
$objects = $this->getObjectFilterOptions();
|
||||
if ($object_filter && isset($objects[$object_filter])) {
|
||||
$query->withTypes(array($object_filter));
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
@ -43,8 +50,13 @@ final class PhabricatorFlagSearchEngine
|
|||
->setName('group')
|
||||
->setLabel(pht('Group By'))
|
||||
->setValue($saved_query->getParameter('group'))
|
||||
->setOptions($this->getGroupOptions()));
|
||||
|
||||
->setOptions($this->getGroupOptions()))
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setName('objectFilter')
|
||||
->setLabel(pht('Object Type'))
|
||||
->setValue($saved_query->getParameter('objectFilter'))
|
||||
->setOptions($this->getObjectFilterOptions()));
|
||||
}
|
||||
|
||||
protected function getURI($path) {
|
||||
|
@ -79,4 +91,28 @@ final class PhabricatorFlagSearchEngine
|
|||
);
|
||||
}
|
||||
|
||||
private function getObjectFilterOptions() {
|
||||
$objects = id(new PhutilSymbolLoader())
|
||||
->setAncestorClass('PhabricatorFlaggableInterface')
|
||||
->loadObjects();
|
||||
$all_types = PhabricatorPHIDType::getAllTypes();
|
||||
$options = array();
|
||||
foreach ($objects as $object) {
|
||||
$phid = $object->generatePHID();
|
||||
$phid_type = phid_get_type($phid);
|
||||
$type_object = idx($all_types, $phid_type);
|
||||
if ($type_object) {
|
||||
$options[$phid_type] = $type_object->getTypeName();
|
||||
}
|
||||
}
|
||||
// sort it alphabetically...
|
||||
asort($options);
|
||||
$default_option = array(
|
||||
0 => 'All Objects');
|
||||
// ...and stick the default option on front
|
||||
$options = array_merge($default_option, $options);
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
<?php
|
||||
|
||||
final class HeraldRule extends HeraldDAO
|
||||
implements PhabricatorPolicyInterface {
|
||||
implements
|
||||
PhabricatorFlaggableInterface,
|
||||
PhabricatorPolicyInterface {
|
||||
|
||||
const TABLE_RULE_APPLIED = 'herald_ruleapplied';
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ final class PhabricatorFileImageMacro extends PhabricatorFileDAO
|
|||
implements
|
||||
PhabricatorSubscribableInterface,
|
||||
PhabricatorApplicationTransactionInterface,
|
||||
PhabricatorFlaggableInterface,
|
||||
PhabricatorPolicyInterface {
|
||||
|
||||
protected $authorPHID;
|
||||
|
|
|
@ -5,6 +5,7 @@ final class ManiphestTask extends ManiphestDAO
|
|||
PhabricatorMarkupInterface,
|
||||
PhabricatorPolicyInterface,
|
||||
PhabricatorTokenReceiverInterface,
|
||||
PhabricatorFlaggableInterface,
|
||||
PhrequentTrackableInterface,
|
||||
PhabricatorCustomFieldInterface {
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ final class PhabricatorPaste extends PhabricatorPasteDAO
|
|||
implements
|
||||
PhabricatorSubscribableInterface,
|
||||
PhabricatorTokenReceiverInterface,
|
||||
PhabricatorFlaggableInterface,
|
||||
PhabricatorPolicyInterface {
|
||||
|
||||
protected $title;
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
<?php
|
||||
|
||||
final class PhluxVariable extends PhluxDAO
|
||||
implements PhabricatorPolicyInterface {
|
||||
implements
|
||||
PhabricatorFlaggableInterface,
|
||||
PhabricatorPolicyInterface {
|
||||
|
||||
protected $variableKey;
|
||||
protected $variableValue;
|
||||
|
|
|
@ -9,6 +9,7 @@ final class PholioMock extends PholioDAO
|
|||
PhabricatorPolicyInterface,
|
||||
PhabricatorSubscribableInterface,
|
||||
PhabricatorTokenReceiverInterface,
|
||||
PhabricatorFlaggableInterface,
|
||||
PhabricatorApplicationTransactionInterface {
|
||||
|
||||
const MARKUP_FIELD_DESCRIPTION = 'markup:description';
|
||||
|
|
|
@ -7,6 +7,7 @@ final class PhrictionDocument extends PhrictionDAO
|
|||
implements
|
||||
PhabricatorPolicyInterface,
|
||||
PhabricatorSubscribableInterface,
|
||||
PhabricatorFlaggableInterface,
|
||||
PhabricatorTokenReceiverInterface {
|
||||
|
||||
protected $slug;
|
||||
|
|
|
@ -5,6 +5,7 @@ final class PonderAnswer extends PonderDAO
|
|||
PhabricatorMarkupInterface,
|
||||
PonderVotableInterface,
|
||||
PhabricatorPolicyInterface,
|
||||
PhabricatorFlaggableInterface,
|
||||
PhabricatorSubscribableInterface,
|
||||
PhabricatorTokenReceiverInterface {
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ final class PonderQuestion extends PonderDAO
|
|||
PhabricatorMarkupInterface,
|
||||
PonderVotableInterface,
|
||||
PhabricatorSubscribableInterface,
|
||||
PhabricatorFlaggableInterface,
|
||||
PhabricatorPolicyInterface,
|
||||
PhabricatorTokenReceiverInterface {
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorProject extends PhabricatorProjectDAO
|
||||
implements PhabricatorPolicyInterface {
|
||||
implements
|
||||
PhabricatorFlaggableInterface,
|
||||
PhabricatorPolicyInterface {
|
||||
|
||||
protected $name;
|
||||
protected $status = PhabricatorProjectStatus::STATUS_ACTIVE;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
||||
implements
|
||||
PhabricatorPolicyInterface,
|
||||
PhabricatorFlaggableInterface,
|
||||
PhabricatorMarkupInterface {
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,6 +4,7 @@ final class PhabricatorRepositoryCommit
|
|||
extends PhabricatorRepositoryDAO
|
||||
implements
|
||||
PhabricatorPolicyInterface,
|
||||
PhabricatorFlaggableInterface,
|
||||
PhabricatorTokenReceiverInterface {
|
||||
|
||||
protected $repositoryID;
|
||||
|
|
|
@ -7,6 +7,7 @@ final class PhabricatorSlowvotePoll extends PhabricatorSlowvoteDAO
|
|||
implements
|
||||
PhabricatorPolicyInterface,
|
||||
PhabricatorSubscribableInterface,
|
||||
PhabricatorFlaggableInterface,
|
||||
PhabricatorTokenReceiverInterface {
|
||||
|
||||
const RESPONSES_VISIBLE = 0;
|
||||
|
|
Loading…
Reference in a new issue