Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14097492
D12248.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
11 KB
Referenced Files
None
Subscribers
None
D12248.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
@@ -1034,6 +1034,7 @@
'ManiphestInfoConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestInfoConduitAPIMethod.php',
'ManiphestNameIndex' => 'applications/maniphest/storage/ManiphestNameIndex.php',
'ManiphestNameIndexEventListener' => 'applications/maniphest/event/ManiphestNameIndexEventListener.php',
+ 'ManiphestPriorityEmailCommand' => 'applications/maniphest/command/ManiphestPriorityEmailCommand.php',
'ManiphestQueryConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestQueryConduitAPIMethod.php',
'ManiphestQueryStatusesConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestQueryStatusesConduitAPIMethod.php',
'ManiphestRemarkupRule' => 'applications/maniphest/remarkup/ManiphestRemarkupRule.php',
@@ -1042,6 +1043,7 @@
'ManiphestSchemaSpec' => 'applications/maniphest/storage/ManiphestSchemaSpec.php',
'ManiphestSearchIndexer' => 'applications/maniphest/search/ManiphestSearchIndexer.php',
'ManiphestStatusConfigOptionType' => 'applications/maniphest/config/ManiphestStatusConfigOptionType.php',
+ 'ManiphestStatusEmailCommand' => 'applications/maniphest/command/ManiphestStatusEmailCommand.php',
'ManiphestSubpriorityController' => 'applications/maniphest/controller/ManiphestSubpriorityController.php',
'ManiphestTask' => 'applications/maniphest/storage/ManiphestTask.php',
'ManiphestTaskDependedOnByTaskEdgeType' => 'applications/maniphest/edge/ManiphestTaskDependedOnByTaskEdgeType.php',
@@ -4284,6 +4286,7 @@
'ManiphestInfoConduitAPIMethod' => 'ManiphestConduitAPIMethod',
'ManiphestNameIndex' => 'ManiphestDAO',
'ManiphestNameIndexEventListener' => 'PhabricatorEventListener',
+ 'ManiphestPriorityEmailCommand' => 'ManiphestEmailCommand',
'ManiphestQueryConduitAPIMethod' => 'ManiphestConduitAPIMethod',
'ManiphestQueryStatusesConduitAPIMethod' => 'ManiphestConduitAPIMethod',
'ManiphestRemarkupRule' => 'PhabricatorObjectRemarkupRule',
@@ -4292,6 +4295,7 @@
'ManiphestSchemaSpec' => 'PhabricatorConfigSchemaSpec',
'ManiphestSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
'ManiphestStatusConfigOptionType' => 'PhabricatorConfigJSONOptionType',
+ 'ManiphestStatusEmailCommand' => 'ManiphestEmailCommand',
'ManiphestSubpriorityController' => 'ManiphestController',
'ManiphestTask' => array(
'ManiphestDAO',
diff --git a/src/applications/maniphest/command/ManiphestPriorityEmailCommand.php b/src/applications/maniphest/command/ManiphestPriorityEmailCommand.php
new file mode 100644
--- /dev/null
+++ b/src/applications/maniphest/command/ManiphestPriorityEmailCommand.php
@@ -0,0 +1,73 @@
+<?php
+
+final class ManiphestPriorityEmailCommand
+ extends ManiphestEmailCommand {
+
+ public function getCommand() {
+ return 'priority';
+ }
+
+ public function getCommandSyntax() {
+ return '**!priority** //priority//';
+ }
+
+ public function getCommandSummary() {
+ return pht('Change the priority of a task.');
+ }
+
+ public function getCommandDescription() {
+ $names = ManiphestTaskPriority::getTaskPriorityMap();
+ $keywords = ManiphestTaskPriority::getTaskPriorityKeywordsMap();
+
+ $table = array();
+ $table[] = '| '.pht('Priority').' | '.pht('Keywords');
+ $table[] = '|---|---|';
+ foreach ($keywords as $priority => $words) {
+ $words = implode(', ', $words);
+ $table[] = '| '.$names[$priority].' | '.$words;
+ }
+ $table = implode("\n", $table);
+
+ return pht(
+ 'To change the priority of a task, specify the desired priority, like '.
+ '`!priority high`. This table shows the configured names for priority '.
+ 'levels.'.
+ "\n\n%s\n\n".
+ 'If you specify an invalid priority, the command is ignored. This '.
+ 'command has no effect if you do not specify a priority.',
+ $table);
+ }
+
+ public function buildTransactions(
+ PhabricatorUser $viewer,
+ PhabricatorApplicationTransactionInterface $object,
+ PhabricatorMetaMTAReceivedMail $mail,
+ $command,
+ array $argv) {
+ $xactions = array();
+
+ $target = phutil_utf8_strtolower(head($argv));
+ $priority = null;
+
+ $keywords = ManiphestTaskPriority::getTaskPriorityKeywordsMap();
+ foreach ($keywords as $key => $words) {
+ foreach ($words as $word) {
+ if ($word == $target) {
+ $priority = $key;
+ break;
+ }
+ }
+ }
+
+ if ($priority === null) {
+ return array();
+ }
+
+ $xactions[] = $object->getApplicationTransactionTemplate()
+ ->setTransactionType(ManiphestTransaction::TYPE_PRIORITY)
+ ->setNewValue($priority);
+
+ return $xactions;
+ }
+
+}
diff --git a/src/applications/maniphest/command/ManiphestStatusEmailCommand.php b/src/applications/maniphest/command/ManiphestStatusEmailCommand.php
new file mode 100644
--- /dev/null
+++ b/src/applications/maniphest/command/ManiphestStatusEmailCommand.php
@@ -0,0 +1,72 @@
+<?php
+
+final class ManiphestStatusEmailCommand
+ extends ManiphestEmailCommand {
+
+ public function getCommand() {
+ return 'status';
+ }
+
+ public function getCommandSyntax() {
+ return '**!status** //status//';
+ }
+
+ public function getCommandSummary() {
+ return pht('Change the status of a task.');
+ }
+
+ public function getCommandDescription() {
+ $names = ManiphestTaskStatus::getTaskStatusMap();
+ $keywords = ManiphestTaskStatus::getTaskStatusKeywordsMap();
+
+ $table = array();
+ $table[] = '| '.pht('Status').' | '.pht('Keywords');
+ $table[] = '|---|---|';
+ foreach ($keywords as $status => $words) {
+ $words = implode(', ', $words);
+ $table[] = '| '.$names[$status].' | '.$words;
+ }
+ $table = implode("\n", $table);
+
+ return pht(
+ 'To change the status of a task, specify the desired status, like '.
+ '`!status invalid`. This table shows the configured names for statuses.'.
+ "\n\n%s\n\n".
+ 'If you specify an invalid status, the command is ignored. This '.
+ 'command has no effect if you do not specify a status.',
+ $table);
+ }
+
+ public function buildTransactions(
+ PhabricatorUser $viewer,
+ PhabricatorApplicationTransactionInterface $object,
+ PhabricatorMetaMTAReceivedMail $mail,
+ $command,
+ array $argv) {
+ $xactions = array();
+
+ $target = phutil_utf8_strtolower(head($argv));
+ $status = null;
+
+ $keywords = ManiphestTaskStatus::getTaskStatusKeywordsMap();
+ foreach ($keywords as $key => $words) {
+ foreach ($words as $word) {
+ if ($word == $target) {
+ $status = $key;
+ break;
+ }
+ }
+ }
+
+ if ($status === null) {
+ return array();
+ }
+
+ $xactions[] = $object->getApplicationTransactionTemplate()
+ ->setTransactionType(ManiphestTransaction::TYPE_STATUS)
+ ->setNewValue($status);
+
+ return $xactions;
+ }
+
+}
diff --git a/src/applications/maniphest/config/PhabricatorManiphestConfigOptions.php b/src/applications/maniphest/config/PhabricatorManiphestConfigOptions.php
--- a/src/applications/maniphest/config/PhabricatorManiphestConfigOptions.php
+++ b/src/applications/maniphest/config/PhabricatorManiphestConfigOptions.php
@@ -26,31 +26,37 @@
'name' => pht('Unbreak Now!'),
'short' => pht('Unbreak!'),
'color' => 'indigo',
+ 'keywords' => array('unbreak'),
),
90 => array(
'name' => pht('Needs Triage'),
'short' => pht('Triage'),
'color' => 'violet',
+ 'keywords' => array('triage'),
),
80 => array(
'name' => pht('High'),
'short' => pht('High'),
'color' => 'red',
+ 'keywords' => array('high'),
),
50 => array(
'name' => pht('Normal'),
'short' => pht('Normal'),
'color' => 'orange',
+ 'keywords' => array('normal'),
),
25 => array(
'name' => pht('Low'),
'short' => pht('Low'),
'color' => 'yellow',
+ 'keywords' => array('low'),
),
0 => array(
'name' => pht('Wishlist'),
'short' => pht('Wish'),
'color' => 'sky',
+ 'keywords' => array('wish', 'wishlist'),
),
);
@@ -80,6 +86,7 @@
'as resolved',
'as fixed',
),
+ 'keywords' => array('closed', 'fixed', 'resolved'),
),
'wontfix' => array(
'name' => pht('Wontfix'),
@@ -182,6 +189,9 @@
providing "as invalid" here will allow users to move tasks
to this status by writing `Closes T123 as invalid`, even if another status
is selected by the "Closes" prefix.
+ - `keywords` //Optional list<string>.// Allows you to specify a list
+ of keywords which can be used with `!status` commands in email to select
+ this status.
Statuses will appear in the UI in the order specified. Note the status marked
`special` as `duplicate` is not settable directly and will not appear in UI
@@ -257,6 +267,9 @@
' - `short` Alternate shorter name, used in UIs where there is '.
' not much space available.'."\n".
' - `color` A color for this priority, like "red" or "blue".'.
+ ' - `keywords` An optional list of keywords which can '.
+ ' be used to select this priority when using `!priority` '.
+ ' commands in email.'.
"\n\n".
'You can choose which priority is the default for newly created '.
'tasks with `maniphest.default-priority`.')),
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
@@ -17,6 +17,32 @@
/**
+ * Get the priorities and their command keywords.
+ *
+ * @return map Priorities to lists of command keywords.
+ */
+ public static function getTaskPriorityKeywordsMap() {
+ $map = self::getConfig();
+ foreach ($map as $key => $spec) {
+ $words = idx($spec, 'keywords', array());
+ if (!is_array($words)) {
+ $words = array($words);
+ }
+
+ foreach ($words as $word_key => $word) {
+ $words[$word_key] = phutil_utf8_strtolower($word);
+ }
+
+ $words = array_unique($words);
+
+ $map[$key] = $words;
+ }
+
+ return $map;
+ }
+
+
+ /**
* Get the priorities and their related short (one-word) descriptions.
*
* @return map Priorities to short descriptions.
diff --git a/src/applications/maniphest/constants/ManiphestTaskStatus.php b/src/applications/maniphest/constants/ManiphestTaskStatus.php
--- a/src/applications/maniphest/constants/ManiphestTaskStatus.php
+++ b/src/applications/maniphest/constants/ManiphestTaskStatus.php
@@ -38,6 +38,37 @@
return ipull(self::getEnabledStatusMap(), 'name');
}
+
+ /**
+ * Get the statuses and their command keywords.
+ *
+ * @return map Statuses to lists of command keywords.
+ */
+ public static function getTaskStatusKeywordsMap() {
+ $map = self::getEnabledStatusMap();
+ foreach ($map as $key => $spec) {
+ $words = idx($spec, 'keywords', array());
+ if (!is_array($words)) {
+ $words = array($words);
+ }
+
+ // For statuses, we include the status name because it's usually
+ // at least somewhat meaningful.
+ $words[] = $key;
+
+ foreach ($words as $word_key => $word) {
+ $words[$word_key] = phutil_utf8_strtolower($word);
+ }
+
+ $words = array_unique($words);
+
+ $map[$key] = $words;
+ }
+
+ return $map;
+ }
+
+
public static function getTaskStatusName($status) {
return self::getStatusAttribute($status, 'name', pht('Unknown Status'));
}
@@ -231,6 +262,7 @@
'silly' => 'optional bool',
'prefixes' => 'optional list<string>',
'suffixes' => 'optional list<string>',
+ 'keywords' => 'optional list<string>',
));
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 27, 7:11 AM (21 h, 36 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6792483
Default Alt Text
D12248.diff (11 KB)
Attached To
Mode
D12248: Implement the "!priority" and "!status" mail commands
Attached
Detach File
Event Timeline
Log In to Comment