diff --git a/src/applications/herald/action/HeraldAction.php b/src/applications/herald/action/HeraldAction.php --- a/src/applications/herald/action/HeraldAction.php +++ b/src/applications/herald/action/HeraldAction.php @@ -86,6 +86,23 @@ return $value; } + public function getEditorValue(PhabricatorUser $viewer, $target) { + try { + $type = $this->getHeraldActionStandardType(); + } catch (PhutilMethodNotImplementedException $ex) { + return $target; + } + + switch ($type) { + case self::STANDARD_PHID_LIST: + $handles = $viewer->loadHandles($target); + $handles = iterator_to_array($handles); + return mpull($handles, 'getName', 'getPHID'); + } + + return $target; + } + final public function setAdapter(HeraldAdapter $adapter) { $this->adapter = $adapter; return $this; diff --git a/src/applications/herald/adapter/HeraldAdapter.php b/src/applications/herald/adapter/HeraldAdapter.php --- a/src/applications/herald/adapter/HeraldAdapter.php +++ b/src/applications/herald/adapter/HeraldAdapter.php @@ -770,8 +770,7 @@ public function getEditorValueForCondition( PhabricatorUser $viewer, - HeraldCondition $condition, - array $handles) { + HeraldCondition $condition) { $field = $this->requireFieldImplementation($condition->getFieldName()); @@ -781,6 +780,17 @@ $condition->getValue()); } + public function getEditorValueForAction( + PhabricatorUser $viewer, + HeraldActionRecord $action_record) { + + $action = $this->requireActionImplementation($action_record->getAction()); + + return $action->getEditorValue( + $viewer, + $action_record->getTarget()); + } + public function renderRuleAsText( HeraldRule $rule, PhabricatorHandleList $handles, diff --git a/src/applications/herald/controller/HeraldRuleController.php b/src/applications/herald/controller/HeraldRuleController.php --- a/src/applications/herald/controller/HeraldRuleController.php +++ b/src/applications/herald/controller/HeraldRuleController.php @@ -348,8 +348,7 @@ foreach ($rule->getConditions() as $condition) { $value = $adapter->getEditorValueForCondition( $this->getViewer(), - $condition, - $handles); + $condition); $serial_conditions[] = array( $condition->getFieldName(), @@ -366,26 +365,13 @@ if ($rule->getActions()) { $serial_actions = array(); foreach ($rule->getActions() as $action) { - switch ($action->getAction()) { - case HeraldAdapter::ACTION_BLOCK: - $current_value = $action->getTarget(); - break; - default: - if (is_array($action->getTarget())) { - $target_map = array(); - foreach ((array)$action->getTarget() as $fbid) { - $target_map[$fbid] = $handles[$fbid]->getName(); - } - $current_value = $target_map; - } else { - $current_value = $action->getTarget(); - } - break; - } + $value = $adapter->getEditorValueForAction( + $this->getViewer(), + $action); $serial_actions[] = array( $action->getAction(), - $current_value, + $value, ); } }