Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15448653
D18111.id43571.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
12 KB
Referenced Files
None
Subscribers
None
D18111.id43571.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
@@ -1503,6 +1503,7 @@
'ManiphestSearchConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestSearchConduitAPIMethod.php',
'ManiphestStatusConfigOptionType' => 'applications/maniphest/config/ManiphestStatusConfigOptionType.php',
'ManiphestStatusEmailCommand' => 'applications/maniphest/command/ManiphestStatusEmailCommand.php',
+ 'ManiphestStatusSearchConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestStatusSearchConduitAPIMethod.php',
'ManiphestSubpriorityController' => 'applications/maniphest/controller/ManiphestSubpriorityController.php',
'ManiphestSubtypesConfigOptionsType' => 'applications/maniphest/config/ManiphestSubtypesConfigOptionsType.php',
'ManiphestTask' => 'applications/maniphest/storage/ManiphestTask.php',
@@ -6598,6 +6599,7 @@
'ManiphestSearchConduitAPIMethod' => 'PhabricatorSearchEngineAPIMethod',
'ManiphestStatusConfigOptionType' => 'PhabricatorConfigJSONOptionType',
'ManiphestStatusEmailCommand' => 'ManiphestEmailCommand',
+ 'ManiphestStatusSearchConduitAPIMethod' => 'ManiphestConduitAPIMethod',
'ManiphestSubpriorityController' => 'ManiphestController',
'ManiphestSubtypesConfigOptionsType' => 'PhabricatorConfigJSONOptionType',
'ManiphestTask' => array(
diff --git a/src/applications/maniphest/__tests__/ManiphestTaskTestCase.php b/src/applications/maniphest/__tests__/ManiphestTaskTestCase.php
--- a/src/applications/maniphest/__tests__/ManiphestTaskTestCase.php
+++ b/src/applications/maniphest/__tests__/ManiphestTaskTestCase.php
@@ -194,11 +194,14 @@
$dst,
$is_after);
+ $keyword_map = ManiphestTaskPriority::getTaskPriorityKeywordsMap();
+ $keyword = head($keyword_map[$pri]);
+
$xactions = array();
$xactions[] = id(new ManiphestTransaction())
->setTransactionType(ManiphestTaskPriorityTransaction::TRANSACTIONTYPE)
- ->setNewValue($pri);
+ ->setNewValue($keyword);
$xactions[] = id(new ManiphestTransaction())
->setTransactionType(ManiphestTaskSubpriorityTransaction::TRANSACTIONTYPE)
@@ -217,11 +220,14 @@
$target_priority,
$is_end);
+ $keyword_map = ManiphestTaskPriority::getTaskPriorityKeywordsMap();
+ $keyword = head($keyword_map[$pri]);
+
$xactions = array();
$xactions[] = id(new ManiphestTransaction())
->setTransactionType(ManiphestTaskPriorityTransaction::TRANSACTIONTYPE)
- ->setNewValue($pri);
+ ->setNewValue($keyword);
$xactions[] = id(new ManiphestTransaction())
->setTransactionType(ManiphestTaskSubpriorityTransaction::TRANSACTIONTYPE)
diff --git a/src/applications/maniphest/command/ManiphestPriorityEmailCommand.php b/src/applications/maniphest/command/ManiphestPriorityEmailCommand.php
--- a/src/applications/maniphest/command/ManiphestPriorityEmailCommand.php
+++ b/src/applications/maniphest/command/ManiphestPriorityEmailCommand.php
@@ -49,20 +49,10 @@
array $argv) {
$xactions = array();
- $target = phutil_utf8_strtolower(head($argv));
- $priority = null;
+ $keyword = phutil_utf8_strtolower(head($argv));
+ $priority = ManiphestTaskPriority::getTaskPriorityFromKeyword($keyword);
- $keywords = ManiphestTaskPriority::getTaskPriorityKeywordsMap();
- foreach ($keywords as $key => $words) {
- foreach ($words as $word) {
- if ($word == $target) {
- $priority = $key;
- break;
- }
- }
- }
-
- if ($priority === null) {
+ if ($keyword === null) {
return array();
}
@@ -72,7 +62,7 @@
$xactions[] = $object->getApplicationTransactionTemplate()
->setTransactionType(ManiphestTaskPriorityTransaction::TRANSACTIONTYPE)
- ->setNewValue($priority);
+ ->setNewValue($keyword);
return $xactions;
}
diff --git a/src/applications/maniphest/conduit/ManiphestConduitAPIMethod.php b/src/applications/maniphest/conduit/ManiphestConduitAPIMethod.php
--- a/src/applications/maniphest/conduit/ManiphestConduitAPIMethod.php
+++ b/src/applications/maniphest/conduit/ManiphestConduitAPIMethod.php
@@ -99,7 +99,9 @@
throw id(new ConduitException('ERR-INVALID-PARAMETER'))
->setErrorDescription(pht('Priority set to invalid value.'));
}
- $changes[ManiphestTaskPriorityTransaction::TRANSACTIONTYPE] = $priority;
+ $keyword_map = ManiphestTaskPriority::getTaskPriorityKeywordsMap();
+ $keyword = head($keyword_map[$priority]);
+ $changes[ManiphestTaskPriorityTransaction::TRANSACTIONTYPE] = $keyword;
}
$owner_phid = $request->getValue('ownerPHID');
diff --git a/src/applications/maniphest/conduit/ManiphestQueryStatusesConduitAPIMethod.php b/src/applications/maniphest/conduit/ManiphestQueryStatusesConduitAPIMethod.php
--- a/src/applications/maniphest/conduit/ManiphestQueryStatusesConduitAPIMethod.php
+++ b/src/applications/maniphest/conduit/ManiphestQueryStatusesConduitAPIMethod.php
@@ -33,4 +33,14 @@
return $results;
}
+ public function getMethodStatus() {
+ return self::METHOD_STATUS_FROZEN;
+ }
+
+ public function getMethodStatusDescription() {
+ return pht(
+ 'This method is frozen and will eventually be deprecated. New code '.
+ 'should use "maniphest.status.search" instead.');
+ }
+
}
diff --git a/src/applications/maniphest/conduit/ManiphestStatusSearchConduitAPIMethod.php b/src/applications/maniphest/conduit/ManiphestStatusSearchConduitAPIMethod.php
new file mode 100644
--- /dev/null
+++ b/src/applications/maniphest/conduit/ManiphestStatusSearchConduitAPIMethod.php
@@ -0,0 +1,52 @@
+<?php
+
+final class ManiphestStatusSearchConduitAPIMethod
+ extends ManiphestConduitAPIMethod {
+
+ public function getAPIMethodName() {
+ return 'maniphest.status.search';
+ }
+
+ public function getMethodSummary() {
+ return pht('Read information about task statuses.');
+ }
+
+ public function getMethodDescription() {
+ return pht(
+ 'Returns information about the possible statuses for Maniphest '.
+ 'tasks.');
+ }
+
+ protected function defineParamTypes() {
+ return array();
+ }
+
+ protected function defineReturnType() {
+ return 'map<string, wild>';
+ }
+
+ public function getRequiredScope() {
+ return self::SCOPE_ALWAYS;
+ }
+
+ protected function execute(ConduitAPIRequest $request) {
+ $config = PhabricatorEnv::getEnvConfig('maniphest.statuses');
+ $results = array();
+ foreach ($config as $code => $status) {
+ $stripped_status = array(
+ 'name' => $status['name'],
+ 'value' => $code,
+ 'closed' => isset($status['closed']),
+ );
+
+ if (isset($status['special'])) {
+ $stripped_status['special'] = $status['special'];
+ }
+
+ $results[] = $stripped_status;
+ }
+
+ return array('data' => $results);
+ }
+
+}
diff --git a/src/applications/maniphest/constants/ManiphestTaskPriority.php b/src/applications/maniphest/constants/ManiphestTaskPriority.php
--- a/src/applications/maniphest/constants/ManiphestTaskPriority.php
+++ b/src/applications/maniphest/constants/ManiphestTaskPriority.php
@@ -105,6 +105,18 @@
return 'fa-arrow-right';
}
+ public static function getTaskPriorityFromKeyword($keyword) {
+ $map = self::getTaskPriorityKeywordsMap();
+
+ foreach ($map as $priority => $keywords) {
+ if (in_array($keyword, $keywords)) {
+ return $priority;
+ }
+ }
+
+ return null;
+ }
+
public static function isDisabledPriority($priority) {
$config = idx(self::getConfig(), $priority, array());
return idx($config, 'disabled', false);
diff --git a/src/applications/maniphest/controller/ManiphestSubpriorityController.php b/src/applications/maniphest/controller/ManiphestSubpriorityController.php
--- a/src/applications/maniphest/controller/ManiphestSubpriorityController.php
+++ b/src/applications/maniphest/controller/ManiphestSubpriorityController.php
@@ -40,11 +40,14 @@
$is_end = false);
}
+ $keyword_map = ManiphestTaskPriority::getTaskPriorityKeywordsMap();
+ $keyword = head($keyword_map[$pri]);
+
$xactions = array();
$xactions[] = id(new ManiphestTransaction())
->setTransactionType(ManiphestTaskPriorityTransaction::TRANSACTIONTYPE)
- ->setNewValue($pri);
+ ->setNewValue($keyword);
$xactions[] = id(new ManiphestTransaction())
->setTransactionType(ManiphestTaskSubpriorityTransaction::TRANSACTIONTYPE)
diff --git a/src/applications/maniphest/editor/ManiphestEditEngine.php b/src/applications/maniphest/editor/ManiphestEditEngine.php
--- a/src/applications/maniphest/editor/ManiphestEditEngine.php
+++ b/src/applications/maniphest/editor/ManiphestEditEngine.php
@@ -215,7 +215,7 @@
->setConduitTypeDescription(pht('New task priority constant.'))
->setTransactionType(ManiphestTaskPriorityTransaction::TRANSACTIONTYPE)
->setIsCopyable(true)
- ->setValue($object->getPriority())
+ ->setValue($object->getPriorityKeyword())
->setOptions($priority_map)
->setCommentActionLabel(pht('Change Priority')),
);
@@ -289,29 +289,29 @@
private function getTaskPriorityMap(ManiphestTask $task) {
$priority_map = ManiphestTaskPriority::getTaskPriorityMap();
+ $priority_keywords = ManiphestTaskPriority::getTaskPriorityKeywordsMap();
$current_priority = $task->getPriority();
+ $results = array();
// If the current value isn't a legitimate one, put it in the dropdown
- // anyway so saving the form doesn't cause a side effects.
+ // anyway so saving the form doesn't cause any side effects.
if (idx($priority_map, $current_priority) === null) {
- $priority_map[$current_priority] = pht(
+ $priority_map['unknown'] = pht(
'<Unknown: %s>',
$current_priority);
}
foreach ($priority_map as $priority => $priority_name) {
- // Always keep the current priority.
- if ($priority == $current_priority) {
+ $disabled = ManiphestTaskPriority::isDisabledPriority($priority);
+ if ($disabled && !($priority == $current_priority)) {
continue;
}
- if (ManiphestTaskPriority::isDisabledPriority($priority)) {
- unset($priority_map[$priority]);
- continue;
- }
+ $keywords = $priority_keywords[$priority];
+ $results[$keywords[0]] = $priority_name;
}
- return $priority_map;
+ return $results;
}
protected function newEditResponse(
diff --git a/src/applications/maniphest/herald/ManiphestTaskPriorityHeraldAction.php b/src/applications/maniphest/herald/ManiphestTaskPriorityHeraldAction.php
--- a/src/applications/maniphest/herald/ManiphestTaskPriorityHeraldAction.php
+++ b/src/applications/maniphest/herald/ManiphestTaskPriorityHeraldAction.php
@@ -39,12 +39,15 @@
return;
}
+ $keyword_map = ManiphestTaskPriority::getTaskPriorityKeywordsMap();
+ $keyword = head(idx($keyword_map, $priority));
+
$xaction = $adapter->newTransaction()
->setTransactionType(ManiphestTaskPriorityTransaction::TRANSACTIONTYPE)
- ->setNewValue($priority);
+ ->setNewValue($keyword);
$adapter->queueTransaction($xaction);
- $this->logEffect(self::DO_PRIORITY, $priority);
+ $this->logEffect(self::DO_PRIORITY, $keyword);
}
public function getHeraldActionStandardType() {
diff --git a/src/applications/maniphest/storage/ManiphestTask.php b/src/applications/maniphest/storage/ManiphestTask.php
--- a/src/applications/maniphest/storage/ManiphestTask.php
+++ b/src/applications/maniphest/storage/ManiphestTask.php
@@ -245,6 +245,13 @@
);
}
+ public function getPriorityKeyword() {
+ $priority = $this->getPriority();
+ $map = ManiphestTaskPriority::getTaskPriorityKeywordsMap();
+ $keywords = idx($map, $priority);
+ return head($keywords);
+ }
+
private function comparePriorityTo(ManiphestTask $other) {
$upri = $this->getPriority();
$vpri = $other->getPriority();
diff --git a/src/applications/maniphest/xaction/ManiphestTaskPriorityTransaction.php b/src/applications/maniphest/xaction/ManiphestTaskPriorityTransaction.php
--- a/src/applications/maniphest/xaction/ManiphestTaskPriorityTransaction.php
+++ b/src/applications/maniphest/xaction/ManiphestTaskPriorityTransaction.php
@@ -12,6 +12,14 @@
return $object->getPriority();
}
+ public function generateNewValue($object, $value) {
+ if ($this->isNewObject()) {
+ return null;
+ }
+
+ return (string)ManiphestTaskPriority::getTaskPriorityFromKeyword($value);
+ }
+
public function applyInternalEffects($object, $value) {
$object->setPriority($value);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 29, 6:07 AM (1 w, 1 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7725956
Default Alt Text
D18111.id43571.diff (12 KB)
Attached To
Mode
D18111: Use keywords instead of ints to update task priority in ManiphestEditEngine
Attached
Detach File
Event Timeline
Log In to Comment