mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 14:00:56 +01:00
Add workboard trigger rule for changing task priority
Summary: This is a copy/paste/find-and-replace-all of the status rule added by D20288. Test Plan: Made some triggers, moved some tasks, edited some triggers. Grepped for the word "status" in the new file. Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D20325
This commit is contained in:
parent
71c89bd057
commit
d347b102a1
2 changed files with 96 additions and 0 deletions
|
@ -4180,6 +4180,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectTriggerEditor' => 'applications/project/editor/PhabricatorProjectTriggerEditor.php',
|
||||
'PhabricatorProjectTriggerInvalidRule' => 'applications/project/trigger/PhabricatorProjectTriggerInvalidRule.php',
|
||||
'PhabricatorProjectTriggerListController' => 'applications/project/controller/trigger/PhabricatorProjectTriggerListController.php',
|
||||
'PhabricatorProjectTriggerManiphestPriorityRule' => 'applications/project/trigger/PhabricatorProjectTriggerManiphestPriorityRule.php',
|
||||
'PhabricatorProjectTriggerManiphestStatusRule' => 'applications/project/trigger/PhabricatorProjectTriggerManiphestStatusRule.php',
|
||||
'PhabricatorProjectTriggerNameTransaction' => 'applications/project/xaction/trigger/PhabricatorProjectTriggerNameTransaction.php',
|
||||
'PhabricatorProjectTriggerPHIDType' => 'applications/project/phid/PhabricatorProjectTriggerPHIDType.php',
|
||||
|
@ -10318,6 +10319,7 @@ phutil_register_library_map(array(
|
|||
'PhabricatorProjectTriggerEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||
'PhabricatorProjectTriggerInvalidRule' => 'PhabricatorProjectTriggerRule',
|
||||
'PhabricatorProjectTriggerListController' => 'PhabricatorProjectTriggerController',
|
||||
'PhabricatorProjectTriggerManiphestPriorityRule' => 'PhabricatorProjectTriggerRule',
|
||||
'PhabricatorProjectTriggerManiphestStatusRule' => 'PhabricatorProjectTriggerRule',
|
||||
'PhabricatorProjectTriggerNameTransaction' => 'PhabricatorProjectTriggerTransactionType',
|
||||
'PhabricatorProjectTriggerPHIDType' => 'PhabricatorPHIDType',
|
||||
|
|
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
|
||||
final class PhabricatorProjectTriggerManiphestPriorityRule
|
||||
extends PhabricatorProjectTriggerRule {
|
||||
|
||||
const TRIGGERTYPE = 'task.priority';
|
||||
|
||||
public function getSelectControlName() {
|
||||
return pht('Change priority to');
|
||||
}
|
||||
|
||||
protected function assertValidRuleValue($value) {
|
||||
if (!is_string($value)) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'Priority rule value should be a string, but is not (value is "%s").',
|
||||
phutil_describe_type($value)));
|
||||
}
|
||||
|
||||
$map = ManiphestTaskPriority::getTaskPriorityMap();
|
||||
if (!isset($map[$value])) {
|
||||
throw new Exception(
|
||||
pht(
|
||||
'Rule value ("%s") is not a valid task priority.',
|
||||
$value));
|
||||
}
|
||||
}
|
||||
|
||||
protected function newDropTransactions($object, $value) {
|
||||
$value = ManiphestTaskPriority::getKeywordForTaskPriority($value);
|
||||
return array(
|
||||
$this->newTransaction()
|
||||
->setTransactionType(ManiphestTaskPriorityTransaction::TRANSACTIONTYPE)
|
||||
->setNewValue($value),
|
||||
);
|
||||
}
|
||||
|
||||
protected function newDropEffects($value) {
|
||||
$priority_name = ManiphestTaskPriority::getTaskPriorityName($value);
|
||||
$priority_icon = ManiphestTaskPriority::getTaskPriorityIcon($value);
|
||||
$priority_color = ManiphestTaskPriority::getTaskPriorityColor($value);
|
||||
|
||||
$content = pht(
|
||||
'Change priority to %s.',
|
||||
phutil_tag('strong', array(), $priority_name));
|
||||
|
||||
return array(
|
||||
$this->newEffect()
|
||||
->setIcon($priority_icon)
|
||||
->setColor($priority_color)
|
||||
->addCondition('priority', '!=', $value)
|
||||
->setContent($content),
|
||||
);
|
||||
}
|
||||
|
||||
protected function getDefaultValue() {
|
||||
return head_key(ManiphestTaskPriority::getTaskPriorityMap());
|
||||
}
|
||||
|
||||
protected function getPHUIXControlType() {
|
||||
return 'select';
|
||||
}
|
||||
|
||||
protected function getPHUIXControlSpecification() {
|
||||
$map = ManiphestTaskPriority::getTaskPriorityMap();
|
||||
|
||||
return array(
|
||||
'options' => $map,
|
||||
'order' => array_keys($map),
|
||||
);
|
||||
}
|
||||
|
||||
public function getRuleViewLabel() {
|
||||
return pht('Change Priority');
|
||||
}
|
||||
|
||||
public function getRuleViewDescription($value) {
|
||||
$priority_name = ManiphestTaskPriority::getTaskPriorityName($value);
|
||||
|
||||
return pht(
|
||||
'Change task priority to %s.',
|
||||
phutil_tag('strong', array(), $priority_name));
|
||||
}
|
||||
|
||||
public function getRuleViewIcon($value) {
|
||||
$priority_icon = ManiphestTaskPriority::getTaskPriorityIcon($value);
|
||||
$priority_color = ManiphestTaskPriority::getTaskPriorityColor($value);
|
||||
|
||||
return id(new PHUIIconView())
|
||||
->setIcon($priority_icon, $priority_color);
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in a new issue