@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve rendering of "default value changed" custom form transactions to at least have all the information

Summary:
Ref T13319. Currently, transactions about changes to a default form value use a raw internal key for the affected field and don't show the actual value change.

An ideal implementation will likely require us to specialize a great deal of rendering, but we can do much better than we currently do without too much work:

- Try to pull the actual `EditField` object for the key so we can `getLabel()` it and get a human-readable label (like `Visible To` instead of `policy.view`).
- Add a "(Show Changes)" action that dumps the raw values as more-or-less JSON, so you can at least figure out what happened if you're sophisticated enough.

Test Plan:
Before:

{F6516640}

After:

{F6516642}

The quality of "Show Details" varies a lot. For some fields, like "Description", it's pretty good:

{F6516645}

For others, like "Assigned To", it's better than nothing but pretty technical:

{F6516647}

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13319

Differential Revision: https://secure.phabricator.com/D20594

+59 -1
+59 -1
src/applications/transactions/storage/PhabricatorEditEngineConfigurationTransaction.php
··· 58 58 $this->renderHandleLink($author_phid)); 59 59 case self::TYPE_DEFAULT: 60 60 $key = $this->getMetadataValue('field.key'); 61 + 62 + $object = $this->getObject(); 63 + $engine = $object->getEngine(); 64 + $fields = $engine->getFieldsForConfig($object); 65 + 66 + $field = idx($fields, $key); 67 + if (!$field) { 68 + return pht( 69 + '%s changed the default value for field "%s".', 70 + $this->renderHandleLink($author_phid), 71 + $key); 72 + } 73 + 61 74 return pht( 62 75 '%s changed the default value for field "%s".', 63 76 $this->renderHandleLink($author_phid), 64 - $key); 77 + $field->getLabel()); 65 78 case self::TYPE_LOCKS: 66 79 return pht( 67 80 '%s changed locked and hidden fields.', ··· 162 175 } 163 176 164 177 return $changes; 178 + } 179 + 180 + public function hasChangeDetails() { 181 + switch ($this->getTransactionType()) { 182 + case self::TYPE_DEFAULT: 183 + return true; 184 + } 185 + 186 + return parent::hasChangeDetails(); 187 + } 188 + 189 + public function renderChangeDetails(PhabricatorUser $viewer) { 190 + switch ($this->getTransactionType()) { 191 + case self::TYPE_DEFAULT: 192 + $old_value = $this->getOldValue(); 193 + $new_value = $this->getNewValue(); 194 + 195 + $old_value = $this->renderDefaultValueAsFallbackText($old_value); 196 + $new_value = $this->renderDefaultValueAsFallbackText($new_value); 197 + 198 + return $this->renderTextCorpusChangeDetails( 199 + $viewer, 200 + $old_value, 201 + $new_value); 202 + } 203 + 204 + return parent::renderChangeDetails($viewer); 205 + } 206 + 207 + private function renderDefaultValueAsFallbackText($default_value) { 208 + // See T13319. When rendering an "alice changed the default value for 209 + // field X." story on custom forms, we may fall back to a generic 210 + // rendering. Try to present the value change in a comprehensible way 211 + // even if it isn't especially human readable (for example, it may 212 + // contain PHIDs or other internal identifiers). 213 + 214 + if (is_scalar($default_value) || is_null($default_value)) { 215 + return $default_value; 216 + } 217 + 218 + if (phutil_is_natural_list($default_value)) { 219 + return id(new PhutilJSON())->encodeAsList($default_value); 220 + } 221 + 222 + return id(new PhutilJSON())->encodeAsObject($default_value); 165 223 } 166 224 167 225 }