@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 the clarity of transactions that affect policies and spaces during object creation

Summary:
Ref T10004. Fixes T9527. Currently, we render two kinds of bad policy/space transactions during object creation.

First, we render a transaction showing a change from the default policy/space to the selected policy/space:

> alice shifted this object from space S1 Default to space S2 Secret.

This is a //good transaction// (it's showing that the default was changed, which could be important for policy stuff!) but it's confusing because it makes it sound like the object briefly existed in space S1, when it did not.

Instead, render this:

> alice created this object in space S2 Secret.

This retains the value (show that the object was created in an unusual space) without the confusion.

Second, when you create a "New Bug Report", we render a transaction like this:

> alice changed the visibility of this task from "All Users" to "Community".

This is distracting and not useful, becasue it's a locked default of the form. This was essentially fixed by D14810. The new behavior is to show this, //only// if the value was changed from the form value:

> alice created this object with visibility "Administrators".

This should reduce confusion, reduce fluff in the default cases, and do a better job of calling out important changes (basically, unusual spaces/policies).

Test Plan:
- Created an edit form with a default space and policies.
- Used that form to create task with:
- same values as form;
- different values from form.

When I changed the form value, I got transactions. When I left it the same, I didn't.

The transactions rendered in the non-confusing "created with ..." variant.

Editing the values created normal transactions with "changed policy from X to Y".

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9527, T10004

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

+82 -32
+13 -6
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 306 306 case PhabricatorTransactions::TYPE_SUBSCRIBERS: 307 307 return array_values($this->subscribers); 308 308 case PhabricatorTransactions::TYPE_VIEW_POLICY: 309 + if ($this->getIsNewObject()) { 310 + return null; 311 + } 309 312 return $object->getViewPolicy(); 310 313 case PhabricatorTransactions::TYPE_EDIT_POLICY: 314 + if ($this->getIsNewObject()) { 315 + return null; 316 + } 311 317 return $object->getEditPolicy(); 312 318 case PhabricatorTransactions::TYPE_JOIN_POLICY: 319 + if ($this->getIsNewObject()) { 320 + return null; 321 + } 313 322 return $object->getJoinPolicy(); 314 323 case PhabricatorTransactions::TYPE_SPACE: 324 + if ($this->getIsNewObject()) { 325 + return null; 326 + } 327 + 315 328 $space_phid = $object->getSpacePHID(); 316 329 if ($space_phid === null) { 317 - if ($this->getIsNewObject()) { 318 - // In this case, just return `null` so we know this is the initial 319 - // transaction and it should be hidden. 320 - return null; 321 - } 322 - 323 330 $default_space = PhabricatorSpacesNamespaceQuery::getDefaultSpace(); 324 331 if ($default_space) { 325 332 $space_phid = $default_space->getPHID();
+69 -26
src/applications/transactions/storage/PhabricatorApplicationTransaction.php
··· 481 481 // transactions like "alice set the task tile to: ...", which are 482 482 // essentially never interesting. 483 483 if ($this->getIsCreateTransaction()) { 484 - $old = $this->getOldValue(); 484 + switch ($this->getTransactionType()) { 485 + case PhabricatorTransactions::TYPE_VIEW_POLICY: 486 + case PhabricatorTransactions::TYPE_EDIT_POLICY: 487 + case PhabricatorTransactions::TYPE_JOIN_POLICY: 488 + case PhabricatorTransactions::TYPE_SPACE: 489 + break; 490 + default: 491 + $old = $this->getOldValue(); 485 492 486 - if (is_array($old) && !$old) { 487 - return true; 488 - } 493 + if (is_array($old) && !$old) { 494 + return true; 495 + } 489 496 490 - if (!strlen($old)) { 491 - return true; 497 + if (!strlen($old)) { 498 + return true; 499 + } 492 500 } 493 501 } 494 502 ··· 510 518 case PhabricatorTransactions::TYPE_EDIT_POLICY: 511 519 case PhabricatorTransactions::TYPE_JOIN_POLICY: 512 520 case PhabricatorTransactions::TYPE_SPACE: 521 + if ($this->getIsCreateTransaction()) { 522 + break; 523 + } 524 + 525 + // TODO: Remove this eventually, this is handling old changes during 526 + // object creation prior to the introduction of "create" and "default" 527 + // transaction display flags. 513 528 if ($this->getOldValue() === null) { 514 529 return true; 515 530 } else { ··· 692 707 '%s added a comment.', 693 708 $this->renderHandleLink($author_phid)); 694 709 case PhabricatorTransactions::TYPE_VIEW_POLICY: 695 - return pht( 696 - '%s changed the visibility from "%s" to "%s".', 697 - $this->renderHandleLink($author_phid), 698 - $this->renderPolicyName($old, 'old'), 699 - $this->renderPolicyName($new, 'new')); 710 + if ($this->getIsCreateTransaction()) { 711 + return pht( 712 + '%s created this object with visibility "%s".', 713 + $this->renderHandleLink($author_phid), 714 + $this->renderPolicyName($new, 'new')); 715 + } else { 716 + return pht( 717 + '%s changed the visibility from "%s" to "%s".', 718 + $this->renderHandleLink($author_phid), 719 + $this->renderPolicyName($old, 'old'), 720 + $this->renderPolicyName($new, 'new')); 721 + } 700 722 case PhabricatorTransactions::TYPE_EDIT_POLICY: 701 - return pht( 702 - '%s changed the edit policy from "%s" to "%s".', 703 - $this->renderHandleLink($author_phid), 704 - $this->renderPolicyName($old, 'old'), 705 - $this->renderPolicyName($new, 'new')); 723 + if ($this->getIsCreateTransaction()) { 724 + return pht( 725 + '%s created this object with edit policy "%s".', 726 + $this->renderHandleLink($author_phid), 727 + $this->renderPolicyName($new, 'new')); 728 + } else { 729 + return pht( 730 + '%s changed the edit policy from "%s" to "%s".', 731 + $this->renderHandleLink($author_phid), 732 + $this->renderPolicyName($old, 'old'), 733 + $this->renderPolicyName($new, 'new')); 734 + } 706 735 case PhabricatorTransactions::TYPE_JOIN_POLICY: 707 - return pht( 708 - '%s changed the join policy from "%s" to "%s".', 709 - $this->renderHandleLink($author_phid), 710 - $this->renderPolicyName($old, 'old'), 711 - $this->renderPolicyName($new, 'new')); 736 + if ($this->getIsCreateTransaction()) { 737 + return pht( 738 + '%s created this object with join policy "%s".', 739 + $this->renderHandleLink($author_phid), 740 + $this->renderPolicyName($new, 'new')); 741 + } else { 742 + return pht( 743 + '%s changed the join policy from "%s" to "%s".', 744 + $this->renderHandleLink($author_phid), 745 + $this->renderPolicyName($old, 'old'), 746 + $this->renderPolicyName($new, 'new')); 747 + } 712 748 case PhabricatorTransactions::TYPE_SPACE: 713 - return pht( 714 - '%s shifted this object from the %s space to the %s space.', 715 - $this->renderHandleLink($author_phid), 716 - $this->renderHandleLink($old), 717 - $this->renderHandleLink($new)); 749 + if ($this->getIsCreateTransaction()) { 750 + return pht( 751 + '%s created this object in space %s.', 752 + $this->renderHandleLink($author_phid), 753 + $this->renderHandleLink($new)); 754 + } else { 755 + return pht( 756 + '%s shifted this object from the %s space to the %s space.', 757 + $this->renderHandleLink($author_phid), 758 + $this->renderHandleLink($old), 759 + $this->renderHandleLink($new)); 760 + } 718 761 case PhabricatorTransactions::TYPE_SUBSCRIBERS: 719 762 $add = array_diff($new, $old); 720 763 $rem = array_diff($old, $new);