mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-15 11:22:40 +01:00
f22dc9d47a
Summary: Ref T7848. This is a companion to "Change status to: ...". (I'm pretty sure the only reason I didn't originally write these was the tokenizer bug in D14682, I just forgot about it). This is basically a copy/paste of the "status" action. Test Plan: - Wrote a rule to change task priorities. - Edited a task. - Saw rule fire properly. - Tokens also stick around correctly. Reviewers: chad Reviewed By: chad Maniphest Tasks: T7848 Differential Revision: https://secure.phabricator.com/D14683
87 lines
2.2 KiB
PHP
87 lines
2.2 KiB
PHP
<?php
|
|
|
|
final class ManiphestTaskPriorityHeraldAction
|
|
extends HeraldAction {
|
|
|
|
const ACTIONCONST = 'maniphest.priority';
|
|
const DO_PRIORITY = 'do.priority';
|
|
|
|
public function supportsObject($object) {
|
|
return ($object instanceof ManiphestTask);
|
|
}
|
|
|
|
public function getActionGroupKey() {
|
|
return HeraldApplicationActionGroup::ACTIONGROUPKEY;
|
|
}
|
|
|
|
public function getHeraldActionName() {
|
|
return pht('Change priority to');
|
|
}
|
|
|
|
public function supportsRuleType($rule_type) {
|
|
return ($rule_type != HeraldRuleTypeConfig::RULE_TYPE_PERSONAL);
|
|
}
|
|
|
|
public function applyEffect($object, HeraldEffect $effect) {
|
|
$priority = head($effect->getTarget());
|
|
|
|
if (!$priority) {
|
|
$this->logEffect(self::DO_STANDARD_EMPTY);
|
|
return;
|
|
}
|
|
|
|
$adapter = $this->getAdapter();
|
|
$object = $adapter->getObject();
|
|
$current = $object->getPriority();
|
|
|
|
if ($current == $priority) {
|
|
$this->logEffect(self::DO_STANDARD_NO_EFFECT, $priority);
|
|
return;
|
|
}
|
|
|
|
$xaction = $adapter->newTransaction()
|
|
->setTransactionType(ManiphestTransaction::TYPE_PRIORITY)
|
|
->setNewValue($priority);
|
|
|
|
$adapter->queueTransaction($xaction);
|
|
$this->logEffect(self::DO_PRIORITY, $priority);
|
|
}
|
|
|
|
public function getHeraldActionStandardType() {
|
|
return self::STANDARD_PHID_LIST;
|
|
}
|
|
|
|
public function renderActionDescription($value) {
|
|
$priority = head($value);
|
|
$name = ManiphestTaskPriority::getTaskPriorityName($priority);
|
|
return pht('Change priority to: %s.', $name);
|
|
}
|
|
|
|
protected function getDatasource() {
|
|
return new ManiphestTaskPriorityDatasource();
|
|
}
|
|
|
|
protected function getDatasourceValueMap() {
|
|
return ManiphestTaskPriority::getTaskPriorityMap();
|
|
}
|
|
|
|
protected function getActionEffectMap() {
|
|
return array(
|
|
self::DO_PRIORITY => array(
|
|
'icon' => 'fa-pencil',
|
|
'color' => 'green',
|
|
'name' => pht('Changed Task Priority'),
|
|
),
|
|
);
|
|
}
|
|
|
|
protected function renderActionEffectDescription($type, $data) {
|
|
switch ($type) {
|
|
case self::DO_PRIORITY:
|
|
return pht(
|
|
'Changed task priority to "%s".',
|
|
ManiphestTaskPriority::getTaskPriorityName($data));
|
|
}
|
|
}
|
|
|
|
}
|