Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14395574
D12530.id30077.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
14 KB
Referenced Files
None
Subscribers
None
D12530.id30077.diff
View Options
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
@@ -1045,6 +1045,7 @@
'ManiphestStatusEmailCommand' => 'applications/maniphest/command/ManiphestStatusEmailCommand.php',
'ManiphestSubpriorityController' => 'applications/maniphest/controller/ManiphestSubpriorityController.php',
'ManiphestTask' => 'applications/maniphest/storage/ManiphestTask.php',
+ 'ManiphestTaskClosedStatusDatasource' => 'applications/maniphest/typeahead/ManiphestTaskClosedStatusDatasource.php',
'ManiphestTaskDependedOnByTaskEdgeType' => 'applications/maniphest/edge/ManiphestTaskDependedOnByTaskEdgeType.php',
'ManiphestTaskDependsOnTaskEdgeType' => 'applications/maniphest/edge/ManiphestTaskDependsOnTaskEdgeType.php',
'ManiphestTaskDetailController' => 'applications/maniphest/controller/ManiphestTaskDetailController.php',
@@ -1055,6 +1056,7 @@
'ManiphestTaskListController' => 'applications/maniphest/controller/ManiphestTaskListController.php',
'ManiphestTaskListView' => 'applications/maniphest/view/ManiphestTaskListView.php',
'ManiphestTaskMailReceiver' => 'applications/maniphest/mail/ManiphestTaskMailReceiver.php',
+ 'ManiphestTaskOpenStatusDatasource' => 'applications/maniphest/typeahead/ManiphestTaskOpenStatusDatasource.php',
'ManiphestTaskOwner' => 'applications/maniphest/constants/ManiphestTaskOwner.php',
'ManiphestTaskPHIDType' => 'applications/maniphest/phid/ManiphestTaskPHIDType.php',
'ManiphestTaskPriority' => 'applications/maniphest/constants/ManiphestTaskPriority.php',
@@ -1064,6 +1066,7 @@
'ManiphestTaskSearchEngine' => 'applications/maniphest/query/ManiphestTaskSearchEngine.php',
'ManiphestTaskStatus' => 'applications/maniphest/constants/ManiphestTaskStatus.php',
'ManiphestTaskStatusDatasource' => 'applications/maniphest/typeahead/ManiphestTaskStatusDatasource.php',
+ 'ManiphestTaskStatusFunctionDatasource' => 'applications/maniphest/typeahead/ManiphestTaskStatusFunctionDatasource.php',
'ManiphestTaskStatusTestCase' => 'applications/maniphest/constants/__tests__/ManiphestTaskStatusTestCase.php',
'ManiphestTaskTestCase' => 'applications/maniphest/__tests__/ManiphestTaskTestCase.php',
'ManiphestTransaction' => 'applications/maniphest/storage/ManiphestTransaction.php',
@@ -4335,6 +4338,7 @@
'PhabricatorApplicationTransactionInterface',
'PhabricatorProjectInterface',
),
+ 'ManiphestTaskClosedStatusDatasource' => 'PhabricatorTypeaheadDatasource',
'ManiphestTaskDependedOnByTaskEdgeType' => 'PhabricatorEdgeType',
'ManiphestTaskDependsOnTaskEdgeType' => 'PhabricatorEdgeType',
'ManiphestTaskDetailController' => 'ManiphestController',
@@ -4345,6 +4349,7 @@
'ManiphestTaskListController' => 'ManiphestController',
'ManiphestTaskListView' => 'ManiphestView',
'ManiphestTaskMailReceiver' => 'PhabricatorObjectMailReceiver',
+ 'ManiphestTaskOpenStatusDatasource' => 'PhabricatorTypeaheadDatasource',
'ManiphestTaskOwner' => 'ManiphestConstants',
'ManiphestTaskPHIDType' => 'PhabricatorPHIDType',
'ManiphestTaskPriority' => 'ManiphestConstants',
@@ -4354,6 +4359,7 @@
'ManiphestTaskSearchEngine' => 'PhabricatorApplicationSearchEngine',
'ManiphestTaskStatus' => 'ManiphestConstants',
'ManiphestTaskStatusDatasource' => 'PhabricatorTypeaheadDatasource',
+ 'ManiphestTaskStatusFunctionDatasource' => 'PhabricatorTypeaheadCompositeDatasource',
'ManiphestTaskStatusTestCase' => 'PhabricatorTestCase',
'ManiphestTaskTestCase' => 'PhabricatorTestCase',
'ManiphestTransaction' => 'PhabricatorApplicationTransaction',
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
@@ -139,7 +139,10 @@
$query->withOwners($assigned_phids);
}
+ $datasource = id(new ManiphestTaskStatusFunctionDatasource())
+ ->setViewer($this->requireViewer());
$statuses = $saved->getParameter('statuses');
+ $statuses = $datasource->evaluateTokens($statuses);
if ($statuses) {
$query->withStatuses($statuses);
}
@@ -274,7 +277,7 @@
->setValue($subscriber_phids))
->appendControl(
id(new AphrontFormTokenizerControl())
- ->setDatasource(new ManiphestTaskStatusDatasource())
+ ->setDatasource(new ManiphestTaskStatusFunctionDatasource())
->setLabel(pht('Statuses'))
->setName('statuses')
->setValue($statuses))
diff --git a/src/applications/maniphest/typeahead/ManiphestTaskClosedStatusDatasource.php b/src/applications/maniphest/typeahead/ManiphestTaskClosedStatusDatasource.php
new file mode 100644
--- /dev/null
+++ b/src/applications/maniphest/typeahead/ManiphestTaskClosedStatusDatasource.php
@@ -0,0 +1,73 @@
+<?php
+
+final class ManiphestTaskClosedStatusDatasource
+ extends PhabricatorTypeaheadDatasource {
+
+ const FUNCTION_TOKEN = 'closed()';
+
+ public function getBrowseTitle() {
+ return pht('Browse Any Closed Status');
+ }
+
+ public function getPlaceholderText() {
+ return pht('Type closed()...');
+ }
+
+ public function getDatasourceApplicationClass() {
+ return 'PhabricatorManiphestApplication';
+ }
+
+ public function getDatasourceFunctions() {
+ return array(
+ 'closed' => array(
+ 'name' => pht('Any Closed Status'),
+ 'summary' => pht('Find results with any closed status.'),
+ 'description' => pht(
+ 'This function includes results which have any closed status.'),
+ ),
+ );
+ }
+
+ public function loadResults() {
+ $results = array(
+ $this->buildClosedResult(),
+ );
+ return $this->filterResultsAgainstTokens($results);
+ }
+
+ protected function evaluateFunction($function, array $argv_list) {
+ $results = array();
+
+ $map = ManiphestTaskStatus::getTaskStatusMap();
+ foreach ($argv_list as $argv) {
+ foreach ($map as $status => $name) {
+ if (!ManiphestTaskStatus::isOpenStatus($status)) {
+ $results[] = $status;
+ }
+ }
+ }
+
+ return $results;
+ }
+
+ public function renderFunctionTokens($function, array $argv_list) {
+ $results = array();
+
+ foreach ($argv_list as $argv) {
+ $results[] = PhabricatorTypeaheadTokenView::newFromTypeaheadResult(
+ $this->buildClosedResult());
+ }
+
+ return $results;
+ }
+
+ private function buildClosedResult() {
+ $name = pht('Any Closed Status');
+ return $this->newFunctionResult()
+ ->setName($name.' closed')
+ ->setDisplayName($name)
+ ->setPHID(self::FUNCTION_TOKEN)
+ ->setUnique(true);
+ }
+
+}
diff --git a/src/applications/maniphest/typeahead/ManiphestTaskOpenStatusDatasource.php b/src/applications/maniphest/typeahead/ManiphestTaskOpenStatusDatasource.php
new file mode 100644
--- /dev/null
+++ b/src/applications/maniphest/typeahead/ManiphestTaskOpenStatusDatasource.php
@@ -0,0 +1,73 @@
+<?php
+
+final class ManiphestTaskOpenStatusDatasource
+ extends PhabricatorTypeaheadDatasource {
+
+ const FUNCTION_TOKEN = 'open()';
+
+ public function getBrowseTitle() {
+ return pht('Browse Any Open Status');
+ }
+
+ public function getPlaceholderText() {
+ return pht('Type open()...');
+ }
+
+ public function getDatasourceApplicationClass() {
+ return 'PhabricatorManiphestApplication';
+ }
+
+ public function getDatasourceFunctions() {
+ return array(
+ 'open' => array(
+ 'name' => pht('Any Open Status'),
+ 'summary' => pht('Find results with any open status.'),
+ 'description' => pht(
+ 'This function includes results which have any open status.'),
+ ),
+ );
+ }
+
+ public function loadResults() {
+ $results = array(
+ $this->buildOpenResult(),
+ );
+ return $this->filterResultsAgainstTokens($results);
+ }
+
+ protected function evaluateFunction($function, array $argv_list) {
+ $results = array();
+
+ $map = ManiphestTaskStatus::getTaskStatusMap();
+ foreach ($argv_list as $argv) {
+ foreach ($map as $status => $name) {
+ if (ManiphestTaskStatus::isOpenStatus($status)) {
+ $results[] = $status;
+ }
+ }
+ }
+
+ return $results;
+ }
+
+ public function renderFunctionTokens($function, array $argv_list) {
+ $results = array();
+
+ foreach ($argv_list as $argv) {
+ $results[] = PhabricatorTypeaheadTokenView::newFromTypeaheadResult(
+ $this->buildOpenResult());
+ }
+
+ return $results;
+ }
+
+ private function buildOpenResult() {
+ $name = pht('Any Open Status');
+ return $this->newFunctionResult()
+ ->setName($name.' open')
+ ->setDisplayName($name)
+ ->setPHID(self::FUNCTION_TOKEN)
+ ->setUnique(true);
+ }
+
+}
diff --git a/src/applications/maniphest/typeahead/ManiphestTaskStatusDatasource.php b/src/applications/maniphest/typeahead/ManiphestTaskStatusDatasource.php
--- a/src/applications/maniphest/typeahead/ManiphestTaskStatusDatasource.php
+++ b/src/applications/maniphest/typeahead/ManiphestTaskStatusDatasource.php
@@ -20,7 +20,8 @@
return $this->filterResultsAgainstTokens($results);
}
- public function renderTokens(array $values) {
+
+ protected function renderSpecialTokens(array $values) {
return $this->renderTokensFromResults($this->buildResults(), $values);
}
diff --git a/src/applications/maniphest/typeahead/ManiphestTaskStatusFunctionDatasource.php b/src/applications/maniphest/typeahead/ManiphestTaskStatusFunctionDatasource.php
new file mode 100644
--- /dev/null
+++ b/src/applications/maniphest/typeahead/ManiphestTaskStatusFunctionDatasource.php
@@ -0,0 +1,22 @@
+<?php
+
+final class ManiphestTaskStatusFunctionDatasource
+ extends PhabricatorTypeaheadCompositeDatasource {
+
+ public function getBrowseTitle() {
+ return pht('Browse Statuses');
+ }
+
+ public function getPlaceholderText() {
+ return pht('Type a task status name or function...');
+ }
+
+ public function getComponentDatasources() {
+ return array(
+ new ManiphestTaskStatusDatasource(),
+ new ManiphestTaskClosedStatusDatasource(),
+ new ManiphestTaskOpenStatusDatasource(),
+ );
+ }
+
+}
diff --git a/src/applications/people/typeahead/PhabricatorViewerDatasource.php b/src/applications/people/typeahead/PhabricatorViewerDatasource.php
--- a/src/applications/people/typeahead/PhabricatorViewerDatasource.php
+++ b/src/applications/people/typeahead/PhabricatorViewerDatasource.php
@@ -15,6 +15,26 @@
return 'PhabricatorPeopleApplication';
}
+ public function getDatasourceFunctions() {
+ return array(
+ 'viewer' => array(
+ 'name' => pht('Current Viewer'),
+ 'summary' => pht('Use the current viewing user.'),
+ 'description' => pht(
+ 'This function allows you to change the behavior of a query '.
+ 'based on who is running it. When you use this function, you will '.
+ 'be the current viewer, so it works like you typed your own '.
+ 'username.'.
+ "\n\n".
+ 'However, if you save a query using this function and send it '.
+ 'to someone else, it will work like //their// username was the '.
+ 'one that was typed. This can be useful for building dashboard '.
+ 'panels that always show relevant information to the user who '.
+ 'is looking at them.'),
+ ),
+ );
+ }
+
public function loadResults() {
if ($this->getViewer()->getPHID()) {
$results = array($this->renderViewerFunctionToken());
@@ -30,7 +50,7 @@
return false;
}
- return ($function == 'viewer');
+ return parent::canEvaluateFunction($function);
}
protected function evaluateFunction($function, array $argv_list) {
diff --git a/src/applications/typeahead/datasource/PhabricatorTypeaheadCompositeDatasource.php b/src/applications/typeahead/datasource/PhabricatorTypeaheadCompositeDatasource.php
--- a/src/applications/typeahead/datasource/PhabricatorTypeaheadCompositeDatasource.php
+++ b/src/applications/typeahead/datasource/PhabricatorTypeaheadCompositeDatasource.php
@@ -162,5 +162,20 @@
return parent::renderFunctionTokens($function, $argv_list);
}
+ protected function renderSpecialTokens(array $values) {
+ $result = array();
+ foreach ($this->getUsableDatasources() as $source) {
+ $special = $source->renderSpecialTokens($values);
+ foreach ($special as $key => $token) {
+ $result[$key] = $token;
+ unset($values[$key]);
+ }
+ if (!$values) {
+ break;
+ }
+ }
+ return $result;
+ }
+
}
diff --git a/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php b/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
--- a/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
+++ b/src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
@@ -229,6 +229,24 @@
}
}
+ // Give special non-function tokens which are also not PHIDs (like statuses
+ // and priorities) an opportunity to render.
+ $type_unknown = PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN;
+ $special = array();
+ foreach ($values as $key => $value) {
+ if (phid_get_type($value) == $type_unknown) {
+ $special[$key] = $value;
+ }
+ }
+
+ if ($special) {
+ $special_tokens = $this->renderSpecialTokens($special);
+ foreach ($special_tokens as $key => $token) {
+ $tokens[$key] = $token;
+ unset($phids[$key]);
+ }
+ }
+
if ($phids) {
$handles = $this->getViewer()->loadHandles($phids);
foreach ($phids as $key => $phid) {
@@ -265,6 +283,10 @@
return array_select_keys($tokens, array_keys($values));
}
+ protected function renderSpecialTokens(array $values) {
+ return array();
+ }
+
/* -( Token Functions )---------------------------------------------------- */
@@ -424,12 +446,13 @@
}
protected function renderTokensFromResults(array $results, array $values) {
- $results = array_select_keys($results, $values);
-
$tokens = array();
- foreach ($results as $result) {
- $tokens[] = PhabricatorTypeaheadTokenView::newFromTypeaheadResult(
- $result);
+ foreach ($values as $key => $value) {
+ if (empty($results[$value])) {
+ continue;
+ }
+ $tokens[$key] = PhabricatorTypeaheadTokenView::newFromTypeaheadResult(
+ $results[$value]);
}
return $tokens;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 4:42 AM (13 h, 16 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6920639
Default Alt Text
D12530.id30077.diff (14 KB)
Attached To
Mode
D12530: Implement open() and closed() Maniphest tokenizer status functions, plus cleanup
Attached
Detach File
Event Timeline
Log In to Comment