1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-11 15:21:03 +01:00

Allow "Assign task" Herald Action in Maniphest to accept "None" to unassign

Summary:
Fixes T9206. This was also blocked on tokenizers being weird.

Also clean up some rendering stuff from the earlier changes.

Test Plan:
  - Added an "unassign" rule by typing "None", per instructions in the placeholder text.
  - Ran the rule.
  - Task got unassigned.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9206

Differential Revision: https://secure.phabricator.com/D14684
This commit is contained in:
epriestley 2015-12-05 12:36:27 -08:00
parent f22dc9d47a
commit bc331f0fbf
3 changed files with 38 additions and 15 deletions

View file

@ -101,7 +101,9 @@ abstract class HeraldAction extends Phobject {
return array(); return array();
} }
return $datasource->getWireTokens($target); return $datasource
->setViewer($viewer)
->getWireTokens($target);
} }
return $target; return $target;
@ -348,10 +350,14 @@ abstract class HeraldAction extends Phobject {
return pht( return pht(
'This action specifies no targets.'); 'This action specifies no targets.');
case self::DO_STANDARD_NO_EFFECT: case self::DO_STANDARD_NO_EFFECT:
return pht( if ($data && is_array($data)) {
'This action has no effect on %s target(s): %s.', return pht(
phutil_count($data), 'This action has no effect on %s target(s): %s.',
$this->renderHandleList($data)); phutil_count($data),
$this->renderHandleList($data));
} else {
return pht('This action has no effect.');
}
case self::DO_STANDARD_INVALID: case self::DO_STANDARD_INVALID:
return pht( return pht(
'%s target(s) are invalid or of the wrong type: %s.', '%s target(s) are invalid or of the wrong type: %s.',

View file

@ -23,12 +23,21 @@ abstract class ManiphestTaskAssignHeraldAction
PhabricatorPeopleUserPHIDType::TYPECONST, PhabricatorPeopleUserPHIDType::TYPECONST,
); );
$targets = $this->loadStandardTargets($phids, $allowed_types, $current); if (head($phids) == PhabricatorPeopleNoOwnerDatasource::FUNCTION_TOKEN) {
if (!$targets) { $phid = null;
return;
}
$phid = head_key($targets); if ($object->getOwnerPHID() == null) {
$this->logEffect(self::DO_STANDARD_NO_EFFECT);
return;
}
} else {
$targets = $this->loadStandardTargets($phids, $allowed_types, $current);
if (!$targets) {
return;
}
$phid = head_key($targets);
}
$xaction = $adapter->newTransaction() $xaction = $adapter->newTransaction()
->setTransactionType(ManiphestTransaction::TYPE_OWNER) ->setTransactionType(ManiphestTransaction::TYPE_OWNER)
@ -52,9 +61,13 @@ abstract class ManiphestTaskAssignHeraldAction
protected function renderActionEffectDescription($type, $data) { protected function renderActionEffectDescription($type, $data) {
switch ($type) { switch ($type) {
case self::DO_ASSIGN: case self::DO_ASSIGN:
return pht( if (head($data) === null) {
'Assigned task to: %s.', return pht('Unassigned task.');
$this->renderHandleList($data)); } else {
return pht(
'Assigned task to: %s.',
$this->renderHandleList($data));
}
} }
} }

View file

@ -24,11 +24,15 @@ final class ManiphestTaskAssignOtherHeraldAction
protected function getDatasource() { protected function getDatasource() {
// TODO: Eventually, it would be nice to get "limit = 1" exported from here // TODO: Eventually, it would be nice to get "limit = 1" exported from here
// up to the UI. // up to the UI.
return new PhabricatorPeopleDatasource(); return new ManiphestAssigneeDatasource();
} }
public function renderActionDescription($value) { public function renderActionDescription($value) {
return pht('Assign task to: %s.', $this->renderHandleList($value)); if (head($value) === PhabricatorPeopleNoOwnerDatasource::FUNCTION_TOKEN) {
return pht('Unassign task.');
} else {
return pht('Assign task to: %s.', $this->renderHandleList($value));
}
} }
} }