1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +01:00

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
This commit is contained in:
epriestley 2015-12-17 10:29:11 -08:00
parent 6146aefcd4
commit bd7981c750
2 changed files with 82 additions and 32 deletions

View file

@ -306,20 +306,27 @@ abstract class PhabricatorApplicationTransactionEditor
case PhabricatorTransactions::TYPE_SUBSCRIBERS: case PhabricatorTransactions::TYPE_SUBSCRIBERS:
return array_values($this->subscribers); return array_values($this->subscribers);
case PhabricatorTransactions::TYPE_VIEW_POLICY: case PhabricatorTransactions::TYPE_VIEW_POLICY:
if ($this->getIsNewObject()) {
return null;
}
return $object->getViewPolicy(); return $object->getViewPolicy();
case PhabricatorTransactions::TYPE_EDIT_POLICY: case PhabricatorTransactions::TYPE_EDIT_POLICY:
if ($this->getIsNewObject()) {
return null;
}
return $object->getEditPolicy(); return $object->getEditPolicy();
case PhabricatorTransactions::TYPE_JOIN_POLICY: case PhabricatorTransactions::TYPE_JOIN_POLICY:
if ($this->getIsNewObject()) {
return null;
}
return $object->getJoinPolicy(); return $object->getJoinPolicy();
case PhabricatorTransactions::TYPE_SPACE: case PhabricatorTransactions::TYPE_SPACE:
if ($this->getIsNewObject()) {
return null;
}
$space_phid = $object->getSpacePHID(); $space_phid = $object->getSpacePHID();
if ($space_phid === null) { if ($space_phid === null) {
if ($this->getIsNewObject()) {
// In this case, just return `null` so we know this is the initial
// transaction and it should be hidden.
return null;
}
$default_space = PhabricatorSpacesNamespaceQuery::getDefaultSpace(); $default_space = PhabricatorSpacesNamespaceQuery::getDefaultSpace();
if ($default_space) { if ($default_space) {
$space_phid = $default_space->getPHID(); $space_phid = $default_space->getPHID();

View file

@ -481,14 +481,22 @@ abstract class PhabricatorApplicationTransaction
// transactions like "alice set the task tile to: ...", which are // transactions like "alice set the task tile to: ...", which are
// essentially never interesting. // essentially never interesting.
if ($this->getIsCreateTransaction()) { if ($this->getIsCreateTransaction()) {
$old = $this->getOldValue(); switch ($this->getTransactionType()) {
case PhabricatorTransactions::TYPE_VIEW_POLICY:
case PhabricatorTransactions::TYPE_EDIT_POLICY:
case PhabricatorTransactions::TYPE_JOIN_POLICY:
case PhabricatorTransactions::TYPE_SPACE:
break;
default:
$old = $this->getOldValue();
if (is_array($old) && !$old) { if (is_array($old) && !$old) {
return true; return true;
} }
if (!strlen($old)) { if (!strlen($old)) {
return true; return true;
}
} }
} }
@ -510,6 +518,13 @@ abstract class PhabricatorApplicationTransaction
case PhabricatorTransactions::TYPE_EDIT_POLICY: case PhabricatorTransactions::TYPE_EDIT_POLICY:
case PhabricatorTransactions::TYPE_JOIN_POLICY: case PhabricatorTransactions::TYPE_JOIN_POLICY:
case PhabricatorTransactions::TYPE_SPACE: case PhabricatorTransactions::TYPE_SPACE:
if ($this->getIsCreateTransaction()) {
break;
}
// TODO: Remove this eventually, this is handling old changes during
// object creation prior to the introduction of "create" and "default"
// transaction display flags.
if ($this->getOldValue() === null) { if ($this->getOldValue() === null) {
return true; return true;
} else { } else {
@ -692,29 +707,57 @@ abstract class PhabricatorApplicationTransaction
'%s added a comment.', '%s added a comment.',
$this->renderHandleLink($author_phid)); $this->renderHandleLink($author_phid));
case PhabricatorTransactions::TYPE_VIEW_POLICY: case PhabricatorTransactions::TYPE_VIEW_POLICY:
return pht( if ($this->getIsCreateTransaction()) {
'%s changed the visibility from "%s" to "%s".', return pht(
$this->renderHandleLink($author_phid), '%s created this object with visibility "%s".',
$this->renderPolicyName($old, 'old'), $this->renderHandleLink($author_phid),
$this->renderPolicyName($new, 'new')); $this->renderPolicyName($new, 'new'));
} else {
return pht(
'%s changed the visibility from "%s" to "%s".',
$this->renderHandleLink($author_phid),
$this->renderPolicyName($old, 'old'),
$this->renderPolicyName($new, 'new'));
}
case PhabricatorTransactions::TYPE_EDIT_POLICY: case PhabricatorTransactions::TYPE_EDIT_POLICY:
return pht( if ($this->getIsCreateTransaction()) {
'%s changed the edit policy from "%s" to "%s".', return pht(
$this->renderHandleLink($author_phid), '%s created this object with edit policy "%s".',
$this->renderPolicyName($old, 'old'), $this->renderHandleLink($author_phid),
$this->renderPolicyName($new, 'new')); $this->renderPolicyName($new, 'new'));
} else {
return pht(
'%s changed the edit policy from "%s" to "%s".',
$this->renderHandleLink($author_phid),
$this->renderPolicyName($old, 'old'),
$this->renderPolicyName($new, 'new'));
}
case PhabricatorTransactions::TYPE_JOIN_POLICY: case PhabricatorTransactions::TYPE_JOIN_POLICY:
return pht( if ($this->getIsCreateTransaction()) {
'%s changed the join policy from "%s" to "%s".', return pht(
$this->renderHandleLink($author_phid), '%s created this object with join policy "%s".',
$this->renderPolicyName($old, 'old'), $this->renderHandleLink($author_phid),
$this->renderPolicyName($new, 'new')); $this->renderPolicyName($new, 'new'));
} else {
return pht(
'%s changed the join policy from "%s" to "%s".',
$this->renderHandleLink($author_phid),
$this->renderPolicyName($old, 'old'),
$this->renderPolicyName($new, 'new'));
}
case PhabricatorTransactions::TYPE_SPACE: case PhabricatorTransactions::TYPE_SPACE:
return pht( if ($this->getIsCreateTransaction()) {
'%s shifted this object from the %s space to the %s space.', return pht(
$this->renderHandleLink($author_phid), '%s created this object in space %s.',
$this->renderHandleLink($old), $this->renderHandleLink($author_phid),
$this->renderHandleLink($new)); $this->renderHandleLink($new));
} else {
return pht(
'%s shifted this object from the %s space to the %s space.',
$this->renderHandleLink($author_phid),
$this->renderHandleLink($old),
$this->renderHandleLink($new));
}
case PhabricatorTransactions::TYPE_SUBSCRIBERS: case PhabricatorTransactions::TYPE_SUBSCRIBERS:
$add = array_diff($new, $old); $add = array_diff($new, $old);
$rem = array_diff($old, $new); $rem = array_diff($old, $new);