Differential D20594 Diff 49127 src/applications/transactions/storage/PhabricatorEditEngineConfigurationTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/storage/PhabricatorEditEngineConfigurationTransaction.php
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | switch ($type) { | ||||
'%s updated the preamble for this form.', | '%s updated the preamble for this form.', | ||||
$this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
case self::TYPE_ORDER: | case self::TYPE_ORDER: | ||||
return pht( | return pht( | ||||
'%s reordered the fields in this form.', | '%s reordered the fields in this form.', | ||||
$this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
case self::TYPE_DEFAULT: | case self::TYPE_DEFAULT: | ||||
$key = $this->getMetadataValue('field.key'); | $key = $this->getMetadataValue('field.key'); | ||||
$object = $this->getObject(); | |||||
$engine = $object->getEngine(); | |||||
$fields = $engine->getFieldsForConfig($object); | |||||
$field = idx($fields, $key); | |||||
if (!$field) { | |||||
return pht( | return pht( | ||||
'%s changed the default value for field "%s".', | '%s changed the default value for field "%s".', | ||||
$this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
$key); | $key); | ||||
} | |||||
return pht( | |||||
'%s changed the default value for field "%s".', | |||||
$this->renderHandleLink($author_phid), | |||||
$field->getLabel()); | |||||
case self::TYPE_LOCKS: | case self::TYPE_LOCKS: | ||||
return pht( | return pht( | ||||
'%s changed locked and hidden fields.', | '%s changed locked and hidden fields.', | ||||
$this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
case self::TYPE_DEFAULTCREATE: | case self::TYPE_DEFAULTCREATE: | ||||
if ($new) { | if ($new) { | ||||
return pht( | return pht( | ||||
'%s added this form to the "Create" menu.', | '%s added this form to the "Create" menu.', | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | switch ($type) { | ||||
->setOldValue($this->getOldValue()) | ->setOldValue($this->getOldValue()) | ||||
->setNewValue($this->getNewValue()); | ->setNewValue($this->getNewValue()); | ||||
break; | break; | ||||
} | } | ||||
return $changes; | return $changes; | ||||
} | } | ||||
public function hasChangeDetails() { | |||||
switch ($this->getTransactionType()) { | |||||
case self::TYPE_DEFAULT: | |||||
return true; | |||||
} | |||||
return parent::hasChangeDetails(); | |||||
} | |||||
public function renderChangeDetails(PhabricatorUser $viewer) { | |||||
switch ($this->getTransactionType()) { | |||||
case self::TYPE_DEFAULT: | |||||
$old_value = $this->getOldValue(); | |||||
$new_value = $this->getNewValue(); | |||||
$old_value = $this->renderDefaultValueAsFallbackText($old_value); | |||||
$new_value = $this->renderDefaultValueAsFallbackText($new_value); | |||||
return $this->renderTextCorpusChangeDetails( | |||||
$viewer, | |||||
$old_value, | |||||
$new_value); | |||||
} | |||||
return parent::renderChangeDetails($viewer); | |||||
} | |||||
private function renderDefaultValueAsFallbackText($default_value) { | |||||
// See T13319. When rendering an "alice changed the default value for | |||||
// field X." story on custom forms, we may fall back to a generic | |||||
// rendering. Try to present the value change in a comprehensible way | |||||
// even if it isn't especially human readable (for example, it may | |||||
// contain PHIDs or other internal identifiers). | |||||
if (is_scalar($default_value) || is_null($default_value)) { | |||||
return $default_value; | |||||
} | |||||
if (phutil_is_natural_list($default_value)) { | |||||
return id(new PhutilJSON())->encodeAsList($default_value); | |||||
} | |||||
return id(new PhutilJSON())->encodeAsObject($default_value); | |||||
} | |||||
} | } |