Page MenuHomePhabricator

D12470.id29925.diff
No OneTemporary

D12470.id29925.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -998,6 +998,7 @@
'MacroCreateMemeConduitAPIMethod' => 'applications/macro/conduit/MacroCreateMemeConduitAPIMethod.php',
'MacroQueryConduitAPIMethod' => 'applications/macro/conduit/MacroQueryConduitAPIMethod.php',
'ManiphestAssignEmailCommand' => 'applications/maniphest/command/ManiphestAssignEmailCommand.php',
+ 'ManiphestAssigneeDatasource' => 'applications/maniphest/typeahead/ManiphestAssigneeDatasource.php',
'ManiphestBatchEditController' => 'applications/maniphest/controller/ManiphestBatchEditController.php',
'ManiphestBulkEditCapability' => 'applications/maniphest/capability/ManiphestBulkEditCapability.php',
'ManiphestClaimEmailCommand' => 'applications/maniphest/command/ManiphestClaimEmailCommand.php',
@@ -1031,6 +1032,8 @@
'ManiphestInfoConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestInfoConduitAPIMethod.php',
'ManiphestNameIndex' => 'applications/maniphest/storage/ManiphestNameIndex.php',
'ManiphestNameIndexEventListener' => 'applications/maniphest/event/ManiphestNameIndexEventListener.php',
+ 'ManiphestNoOwnerDatasource' => 'applications/maniphest/typeahead/ManiphestNoOwnerDatasource.php',
+ 'ManiphestOwnerDatasource' => 'applications/maniphest/typeahead/ManiphestOwnerDatasource.php',
'ManiphestPriorityEmailCommand' => 'applications/maniphest/command/ManiphestPriorityEmailCommand.php',
'ManiphestQueryConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestQueryConduitAPIMethod.php',
'ManiphestQueryStatusesConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestQueryStatusesConduitAPIMethod.php',
@@ -2639,8 +2642,6 @@
'PhabricatorTypeaheadInvalidTokenException' => 'applications/typeahead/exception/PhabricatorTypeaheadInvalidTokenException.php',
'PhabricatorTypeaheadModularDatasourceController' => 'applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php',
'PhabricatorTypeaheadMonogramDatasource' => 'applications/typeahead/datasource/PhabricatorTypeaheadMonogramDatasource.php',
- 'PhabricatorTypeaheadNoOwnerDatasource' => 'applications/typeahead/datasource/PhabricatorTypeaheadNoOwnerDatasource.php',
- 'PhabricatorTypeaheadOwnerDatasource' => 'applications/typeahead/datasource/PhabricatorTypeaheadOwnerDatasource.php',
'PhabricatorTypeaheadResult' => 'applications/typeahead/storage/PhabricatorTypeaheadResult.php',
'PhabricatorTypeaheadRuntimeCompositeDatasource' => 'applications/typeahead/datasource/PhabricatorTypeaheadRuntimeCompositeDatasource.php',
'PhabricatorTypeaheadTokenView' => 'applications/typeahead/view/PhabricatorTypeaheadTokenView.php',
@@ -4267,6 +4268,7 @@
'MacroCreateMemeConduitAPIMethod' => 'MacroConduitAPIMethod',
'MacroQueryConduitAPIMethod' => 'MacroConduitAPIMethod',
'ManiphestAssignEmailCommand' => 'ManiphestEmailCommand',
+ 'ManiphestAssigneeDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
'ManiphestBatchEditController' => 'ManiphestController',
'ManiphestBulkEditCapability' => 'PhabricatorPolicyCapability',
'ManiphestClaimEmailCommand' => 'ManiphestEmailCommand',
@@ -4301,6 +4303,8 @@
'ManiphestInfoConduitAPIMethod' => 'ManiphestConduitAPIMethod',
'ManiphestNameIndex' => 'ManiphestDAO',
'ManiphestNameIndexEventListener' => 'PhabricatorEventListener',
+ 'ManiphestNoOwnerDatasource' => 'PhabricatorTypeaheadDatasource',
+ 'ManiphestOwnerDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
'ManiphestPriorityEmailCommand' => 'ManiphestEmailCommand',
'ManiphestQueryConduitAPIMethod' => 'ManiphestConduitAPIMethod',
'ManiphestQueryStatusesConduitAPIMethod' => 'ManiphestConduitAPIMethod',
@@ -6050,8 +6054,6 @@
'PhabricatorTypeaheadInvalidTokenException' => 'Exception',
'PhabricatorTypeaheadModularDatasourceController' => 'PhabricatorTypeaheadDatasourceController',
'PhabricatorTypeaheadMonogramDatasource' => 'PhabricatorTypeaheadDatasource',
- 'PhabricatorTypeaheadNoOwnerDatasource' => 'PhabricatorTypeaheadDatasource',
- 'PhabricatorTypeaheadOwnerDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
'PhabricatorTypeaheadRuntimeCompositeDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
'PhabricatorTypeaheadTokenView' => 'AphrontTagView',
'PhabricatorTypeaheadUserParameterizedDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
diff --git a/src/applications/maniphest/constants/ManiphestTaskOwner.php b/src/applications/maniphest/constants/ManiphestTaskOwner.php
--- a/src/applications/maniphest/constants/ManiphestTaskOwner.php
+++ b/src/applications/maniphest/constants/ManiphestTaskOwner.php
@@ -2,7 +2,6 @@
final class ManiphestTaskOwner extends ManiphestConstants {
- const OWNER_UP_FOR_GRABS = 'PHID-!!!!-UP-FOR-GRABS';
const PROJECT_NO_PROJECT = 'PHID-!!!!-NO-PROJECT';
}
diff --git a/src/applications/maniphest/controller/ManiphestBatchEditController.php b/src/applications/maniphest/controller/ManiphestBatchEditController.php
--- a/src/applications/maniphest/controller/ManiphestBatchEditController.php
+++ b/src/applications/maniphest/controller/ManiphestBatchEditController.php
@@ -66,7 +66,7 @@
$projects_source = new PhabricatorProjectDatasource();
$mailable_source = new PhabricatorMetaMTAMailableDatasource();
$mailable_source->setViewer($user);
- $owner_source = new PhabricatorTypeaheadOwnerDatasource();
+ $owner_source = new ManiphestAssigneeDatasource();
$owner_source->setViewer($user);
require_celerity_resource('maniphest-batch-editor');
@@ -244,7 +244,8 @@
continue 2;
}
$value = head($value);
- if ($value === ManiphestTaskOwner::OWNER_UP_FOR_GRABS) {
+ $no_owner = ManiphestNoOwnerDatasource::FUNCTION_TOKEN;
+ if ($value === ManiphestNoOwnerDatasource::FUNCTION_TOKEN) {
$value = null;
}
break;
diff --git a/src/applications/maniphest/query/ManiphestTaskQuery.php b/src/applications/maniphest/query/ManiphestTaskQuery.php
--- a/src/applications/maniphest/query/ManiphestTaskQuery.php
+++ b/src/applications/maniphest/query/ManiphestTaskQuery.php
@@ -73,9 +73,11 @@
}
public function withOwners(array $owners) {
+ $no_owner = ManiphestNoOwnerDatasource::FUNCTION_TOKEN;
+
$this->includeUnowned = false;
foreach ($owners as $k => $phid) {
- if ($phid == ManiphestTaskOwner::OWNER_UP_FOR_GRABS || $phid === null) {
+ if ($phid === $no_owner || $phid === null) {
$this->includeUnowned = true;
unset($owners[$k]);
break;
diff --git a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php
--- a/src/applications/maniphest/query/ManiphestTaskSearchEngine.php
+++ b/src/applications/maniphest/query/ManiphestTaskSearchEngine.php
@@ -49,8 +49,6 @@
'assignedPHIDs',
$this->readUsersFromRequest($request, 'assigned'));
- $saved->setParameter('withUnassigned', $request->getBool('withUnassigned'));
-
$saved->setParameter(
'authorPHIDs',
$this->readUsersFromRequest($request, 'authors'));
@@ -139,14 +137,13 @@
$query->withSubscribers($subscriber_phids);
}
- $with_unassigned = $saved->getParameter('withUnassigned');
- if ($with_unassigned) {
- $query->withOwners(array(null));
- } else {
- $assigned_phids = $saved->getParameter('assignedPHIDs', array());
- if ($assigned_phids) {
- $query->withOwners($assigned_phids);
- }
+ $datasource = id(new ManiphestOwnerDatasource())
+ ->setViewer($this->requireViewer());
+
+ $assigned_phids = $this->readAssignedPHIDs($saved);
+ $assigned_phids = $datasource->evaluateTokens($assigned_phids);
+ if ($assigned_phids) {
+ $query->withOwners($assigned_phids);
}
$statuses = $saved->getParameter('statuses');
@@ -242,7 +239,8 @@
AphrontFormView $form,
PhabricatorSavedQuery $saved) {
- $assigned_phids = $saved->getParameter('assignedPHIDs', array());
+ $assigned_phids = $this->readAssignedPHIDs($saved);
+
$author_phids = $saved->getParameter('authorPHIDs', array());
$all_project_phids = $saved->getParameter(
'allProjectPHIDs',
@@ -258,7 +256,6 @@
array());
$subscriber_phids = $saved->getParameter('subscriberPHIDs', array());
- $with_unassigned = $saved->getParameter('withUnassigned');
$with_no_projects = $saved->getParameter('withNoProject');
$statuses = $saved->getParameter('statuses', array());
@@ -314,17 +311,10 @@
$form
->appendControl(
id(new AphrontFormTokenizerControl())
- ->setDatasource(new PhabricatorPeopleDatasource())
+ ->setDatasource(new ManiphestOwnerDatasource())
->setName('assigned')
->setLabel(pht('Assigned To'))
->setValue($assigned_phids))
- ->appendChild(
- id(new AphrontFormCheckboxControl())
- ->addCheckbox(
- 'withUnassigned',
- 1,
- pht('Show only unassigned tasks.'),
- $with_unassigned))
->appendControl(
id(new AphrontFormTokenizerControl())
->setDatasource(new PhabricatorProjectDatasource())
@@ -563,4 +553,17 @@
->setShowBatchControls($this->showBatchControls);
}
+ private function readAssignedPHIDs(PhabricatorSavedQuery $saved) {
+ $assigned_phids = $saved->getParameter('assignedPHIDs', array());
+
+ // This may be present in old saved queries from before parameterized
+ // typeaheads, and is retained for compatibility. We could remove it by
+ // migrating old saved queries.
+ if ($saved->getParameter('withUnassigned')) {
+ $assigned_phids[] = ManiphestNoOwnerDatasource::FUNCTION_TOKEN;
+ }
+
+ return $assigned_phids;
+ }
+
}
diff --git a/src/applications/typeahead/datasource/PhabricatorTypeaheadOwnerDatasource.php b/src/applications/maniphest/typeahead/ManiphestAssigneeDatasource.php
rename from src/applications/typeahead/datasource/PhabricatorTypeaheadOwnerDatasource.php
rename to src/applications/maniphest/typeahead/ManiphestAssigneeDatasource.php
--- a/src/applications/typeahead/datasource/PhabricatorTypeaheadOwnerDatasource.php
+++ b/src/applications/maniphest/typeahead/ManiphestAssigneeDatasource.php
@@ -1,20 +1,20 @@
<?php
-final class PhabricatorTypeaheadOwnerDatasource
+final class ManiphestAssigneeDatasource
extends PhabricatorTypeaheadCompositeDatasource {
public function getBrowseTitle() {
- return pht('Browse Owners');
+ return pht('Browse Assignees');
}
public function getPlaceholderText() {
- return pht('Type a user name or "none"...');
+ return pht('Type a username or "none"...');
}
public function getComponentDatasources() {
return array(
new PhabricatorPeopleDatasource(),
- new PhabricatorTypeaheadNoOwnerDatasource(),
+ new ManiphestNoOwnerDatasource(),
);
}
diff --git a/src/applications/maniphest/typeahead/ManiphestNoOwnerDatasource.php b/src/applications/maniphest/typeahead/ManiphestNoOwnerDatasource.php
new file mode 100644
--- /dev/null
+++ b/src/applications/maniphest/typeahead/ManiphestNoOwnerDatasource.php
@@ -0,0 +1,64 @@
+<?php
+
+final class ManiphestNoOwnerDatasource
+ extends PhabricatorTypeaheadDatasource {
+
+ const FUNCTION_TOKEN = 'none()';
+
+ public function getBrowseTitle() {
+ return pht('Browse No Owner');
+ }
+
+ public function getPlaceholderText() {
+ return pht('Type "none"...');
+ }
+
+ public function getDatasourceApplicationClass() {
+ return 'PhabricatorManiphestApplication';
+ }
+
+ public function getDatasourceFunctions() {
+ return array(
+ 'none' => array(
+ 'name' => pht('Find results which are not assigned.'),
+ ),
+ );
+ }
+
+ public function loadResults() {
+ $results = array(
+ $this->buildNoOwnerResult(),
+ );
+ return $this->filterResultsAgainstTokens($results);
+ }
+
+ protected function evaluateFunction($function, array $argv_list) {
+ $results = array();
+
+ foreach ($argv_list as $argv) {
+ $results[] = self::FUNCTION_TOKEN;
+ }
+
+ return $results;
+ }
+
+ public function renderFunctionTokens($function, array $argv_list) {
+ $results = array();
+ foreach ($argv_list as $argv) {
+ $results[] = PhabricatorTypeaheadTokenView::newFromTypeaheadResult(
+ $this->buildNoOwnerResult());
+ }
+ return $results;
+ }
+
+ private function buildNoOwnerResult() {
+ $name = pht('No Owner');
+ return $this->newFunctionResult()
+ ->setName($name.' none')
+ ->setDisplayName($name)
+ ->setIcon('fa-ban')
+ ->setPHID('none()')
+ ->setUnique(true);
+ }
+
+}
diff --git a/src/applications/typeahead/datasource/PhabricatorTypeaheadOwnerDatasource.php b/src/applications/maniphest/typeahead/ManiphestOwnerDatasource.php
rename from src/applications/typeahead/datasource/PhabricatorTypeaheadOwnerDatasource.php
rename to src/applications/maniphest/typeahead/ManiphestOwnerDatasource.php
--- a/src/applications/typeahead/datasource/PhabricatorTypeaheadOwnerDatasource.php
+++ b/src/applications/maniphest/typeahead/ManiphestOwnerDatasource.php
@@ -1,6 +1,6 @@
<?php
-final class PhabricatorTypeaheadOwnerDatasource
+final class ManiphestOwnerDatasource
extends PhabricatorTypeaheadCompositeDatasource {
public function getBrowseTitle() {
@@ -8,13 +8,15 @@
}
public function getPlaceholderText() {
- return pht('Type a user name or "none"...');
+ return pht('Type a username or function...');
}
public function getComponentDatasources() {
return array(
+ new PhabricatorViewerDatasource(),
+ new ManiphestNoOwnerDatasource(),
new PhabricatorPeopleDatasource(),
- new PhabricatorTypeaheadNoOwnerDatasource(),
+ new PhabricatorProjectMembersDatasource(),
);
}
diff --git a/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php b/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php
--- a/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php
+++ b/src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php
@@ -126,7 +126,7 @@
id(new AphrontFormTokenizerControl())
->setName('ownerPHIDs')
->setLabel('Owners')
- ->setDatasource(new PhabricatorTypeaheadOwnerDatasource())
+ ->setDatasource(new ManiphestOwnerDatasource())
->setValue($owner_phids))
->appendChild(
id(new AphrontFormCheckboxControl())
diff --git a/src/applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php b/src/applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php
--- a/src/applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php
+++ b/src/applications/typeahead/controller/PhabricatorTypeaheadModularDatasourceController.php
@@ -248,8 +248,7 @@
// format to make it easier to debug typeahead output.
foreach ($sources as $key => $source) {
- // This can happen with composite sources like user or project, as well
- // generic ones like NoOwner
+ // This can happen with composite or generic sources.
if (!$source->getDatasourceApplicationClass()) {
continue;
}
diff --git a/src/applications/typeahead/datasource/PhabricatorTypeaheadNoOwnerDatasource.php b/src/applications/typeahead/datasource/PhabricatorTypeaheadNoOwnerDatasource.php
deleted file mode 100644
--- a/src/applications/typeahead/datasource/PhabricatorTypeaheadNoOwnerDatasource.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-
-final class PhabricatorTypeaheadNoOwnerDatasource
- extends PhabricatorTypeaheadDatasource {
-
- public function getBrowseTitle() {
- return pht('Browse No Owner');
- }
-
- public function getPlaceholderText() {
- return pht('Type "none"...');
- }
-
- public function getDatasourceApplicationClass() {
- return null;
- }
-
- public function loadResults() {
- $viewer = $this->getViewer();
- $raw_query = $this->getRawQuery();
-
- $results = array();
-
- $results[] = id(new PhabricatorTypeaheadResult())
- ->setName(pht('None'))
- ->setIcon('fa-ban orange')
- ->setPHID(ManiphestTaskOwner::OWNER_UP_FOR_GRABS);
-
- return $results;
- }
-
-}

File Metadata

Mime Type
text/plain
Expires
Mon, May 13, 3:50 AM (3 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6292203
Default Alt Text
D12470.id29925.diff (16 KB)

Event Timeline